Jump to content
Sign in to follow this  
KaRRiLLioN

2 questions for suma or other opflash programmer

Recommended Posts

I've been searching for the answer to these questions, and I cannot find them so I ask you, the experts:

1.  How can I determine the type of a vehicle?  For example in my respawn script I have to do this:

?(("M1Abrams" CountType _this) == 1):_type= "M1Abrams"

This is how I determine the type of vehicle without having to explicitly type it into an array that execs the script.  Is there some command where I could do this:

vehicletype _vehicle=_unittype.

If I put in titletext[format["%1",_vehicle],"PLAIN"] for debug information then it does show that it is a M1Abrams in that string, but I cannot seem to extract that information.

Anyway, I hope that you can help me with this.

2.  Is it possible somehow to broadcast text to all clients from a script that is running server-side only?  In my vehicle respawn script, it has this:

?!(local Server):goto "end"

That must be there to prevent multiple spawns of vehicles.  However, I have a mission where I must notify the players that a vehicle has respawned.  Since this script is server-side only though, the text will not show up on anyone's screens.

I have tried making the respawn script exec another script with text, but this does not work since any script that it execs will be running only server-side.  I have tried making triggers that react to certain variables, but this does not work either.

Is there some way to broadcast text to all clients?  The PublicVariable command also does not seem to work.  Perhaps I am doing something wrong.

Thank you very much for all of the time you take to answer questions on this forum and for the awesome wonderful game that makes my wife want to destroy my computer. =o)

Share this post


Link to post
Share on other sites

For the text, i figured out, best to use gamelogic's

waypoints. Messages, displayed out of waypoints,

are always showing up on host and client screens.

Gamelogic's waypoints are even better for that, because

you don't need a unit to use performance. Also sidechat,

or other chat-type messages will appear on all screens.

The only thing you need to do is, to find a way, to activate

and reactivate the waypoint of the gamelogic. But i guess

this won't be to hard.

I haven't tried out that yet, but try to send the gamelogic

to this waypoint again, out of the script (if it's already passed). I'll also try it, and report you if wether there's another solution.

Share this post


Link to post
Share on other sites

Hmm, so activating a gamelogic from a script in order to show text messages? I'm not sure I follow you on that. Basically I'm looking for something like this where the vehicle respawn script notifies players that a vehicle has respawned:

?!(local Server): Goto "end"

_vcl = _this select 0

_respawnpoint = _this select 1

_azimut = _this select 2

_class = _this select 3

_respawndelay = 10

#start

~1

?(Canmove _vcl):Goto "start"

~_respawndelay

deleteVehicle _vcl

_vcl = _class createVehicle getpos _respawnpoint

_vcl setdir _azimut

titletext format["A %1 has respawned",_class],"PLAIN"]

Goto "start"

#end

Exit

;;---------------------------

Unfortunately because of the server-side nature of the script, I can't get the text to show up on client computers.

Share this post


Link to post
Share on other sites

KaRRiLLioN,

Couldn t find the original post ( where you posted the mp missions, the two zipfiles )

Had great fun with them ! Especially the carjack map looool that tractor is sooo slow and the distance to base so far away its scary. But i got there biggrin.gif 10 points babyyyyy hehe

Always fun to do something different then plain old ctf !

Just wanted to say thanks, and keep up the good work !

Share this post


Link to post
Share on other sites

KaRRiLLioN,

try to put the Server condition just before the CreateVehicle command, like this

?(Local Server): _vcl = _class createVehicle getpos _respawnpoint

The script should run on all machines (printing the text) but the vehicle is only spawned on the server.

Of course you can optimize this by using the server condition also for the SetDir and the DeleteVehicle command.

Regarding your vehicle type question, I also have this problem, but as far as I know there is no command that returns the class of an object but such a command like

classstring = Class object

would be very useful (hint to BIS wink.gif )

Spinor

Share this post


Link to post
Share on other sites

That's a great idea about the Server-side respawn. I'll give it a shot!

Jap, I'm glad you liked the missions. The scavengers one is kinda like that Carjack one. I find it to be a lot of fun as well. I've updated the mission so it's NATO vs. Soviets, vs. Res now.

Share this post


Link to post
Share on other sites

gonna give it a try tonight.

Nice the choppers respawn biggrin.gif needed that

Share this post


Link to post
Share on other sites

Spinor, I tried the idea you gave me, but I ran into a problem.  Everything seemed to work just fine except that after the vehicle respawns, it seems that the client doesn't recognize the variable or something and because of that it continues to loop through the respawn cycle since it doesn't have the new variable name and it assumes that it must be destroyed. I've tried declaring it a PublicVariable, but since _vcl is local, then it gives an error.  I'll paste my respawn script below and maybe you can point out a better way to do it:

;;vcl_respawn.sqs 2.0

;;Adapted from vcl_respawn 1.0 by Backoff

;;Modifications by KaRRiLLioN

;;

;;INSTRUCTIONS:

;;Create a Vehicle in the mission.  Give it a name, i.e. WTank1

;;In the Initilization field of the vehicle type in [WTank1] exec "vcl_respawn.sqs"

;;place this script in the directory of the mission you wish to use it in.

;;ENJOY!

;;?!(local Server): Goto "end"

_vcl = _this select 0

_respawndelay = 5

_dir=Getdir _vcl

_position=Getpos _vcl

;;;;This determines what type the vehicle is and passes that info on to the rest of the script.

;;;;If only there were some way of determining the type of vehicle more easily, i.e. _type = Type _vcl or something. sigh.

;TRUCKS

;;;;WEST

?(("Truck5t" CountType _this) == 1):_type= "Truck5t"

?(("Truck5tOpen" CountType _this) == 1):_type= "Truck5tOpen"

?(("Truck5tRepair" CountType _this) == 1):_type= "Truck5tRepair"

?(("Truck5tReammo" CountType _this) == 1):_type= "Truck5tReammo"

?(("Truck5tRefuel" CountType _this) == 1):_type= "Truck5tRefuel"

;;;;EAST

?(("Ural" CountType _this) == 1):_type= "Ural"

?(("UralRepair" CountType _this) == 1):_type= "UralRepair"

?(("UralReammo" CountType _this) == 1):_type= "UralReammo"

?(("UralRefuel" CountType _this) == 1):_type= "UralRefuel"

?(("SCUD" CountType _this) == 1):_type= "SCUD"

;;;;CIV and RESISTANCE

?(("TruckV3SG" CountType _this) == 1):_type= "TruckV3SG"

?(("TruckV3SGCivil" CountType _this) == 1):_type= "TruckV3SGCivil"

?(("TruckV3SGRefuel" CountType _this) == 1):_type= "TruckV3SGRefuel"

?(("TruckV3SGRepair" CountType _this) == 1):_type= "TruckV3SGRepair"

?(("TruckV3SGReammo" CountType _this) == 1):_type= "TruckV3SGReammo"

;;JEEPS

;;;;WEST

?(("JEEP" CountType _this) == 1):_type= "JEEP"

?(("JEEPMG" CountType _this) == 1):_type= "JEEPMG"

?(("HMMWV" CountType _this) == 1):_type= "HMMWV"

;;;;EAST

?(("UAZ" CountType _this) == 1):_type= "UAZ"

;;;;RESISTANCE

?(("UAZG" CountType _this) == 1):_type= "UAZG"

?(("GUAZ" CountType _this) == 1):_type= "GUAZ"

?(("SGUAZG" CountType _this) == 1):_type= "SGUAZG"

?(("GJeep" CountType _this) == 1):_type= "GJeep"

;;CARS

?(("TRACTOR" CountType _this) == 1):_type= "TRACTOR"

?(("RAPID" CountType _this) == 1):_type= "RAPID"

?(("RAPIDY" CountType _this) == 1):_type= "RAPIDY"

?(("Skoda" CountType _this) == 1):_type= "Skoda"

?(("SkodaBlue" CountType _this) == 1):_type= "SkodaBlue"

?(("SkodaRed" CountType _this) == 1):_type= "SkodaRed"

?(("SkodaGreen" CountType _this) == 1):_type= "SkodaGreen"

?(("Trabant" CountType _this) == 1):_type= "Trabant"

;;AIR

;;;;WEST

?(("A10" CountType _this) == 1):_type="A10"

?(("A10LGB" CountType _this) == 1):_type="A10LGB"

?(("COBRA" CountType _this) == 1):_type="COBRA"

?(("CH47D" CountType _this) == 1):_type="CH47D"

?(("OH58" CountType _this) == 1):_type="OH58"

?(("UH60" CountType _this) == 1):_type="UH60"

?(("UH60MG" CountType _this) == 1):_type= "UH60MG"

;;;;EAST

?(("SU25" CountType _this) == 1):_type= "SU25"

?(("MI24" CountType _this) == 1):_type= "MI24"

?(("MI17" CountType _this) == 1):_type= "MI17"

;;;;CIV

?(("Cessna" CountType _this) == 1):_type= "Cessna"

;ARMORED UNITS

;;;;WEST

?(("M1Abrams" CountType _this) == 1):_type= "M1Abrams"

?(("M60" CountType _this) == 1):_type= "M60"

?(("Bradley" CountType _this) == 1):_type= "Bradley"

?(("M113" CountType _this) == 1):_type= "M113"

?(("M113Ambul" CountType _this) == 1):_type= "M113Ambul"

?(("BOATW" CountType _this) == 1):_type= "BOATW"

?(("VULCAN" CountType _this) == 1):_type= "VULCAN"

?(("M2StaticMG" CountType _this) == 1): _type= "M2StaticMG"

;;;;EAST

?(("T80" CountType _this) == 1):_type= "T80"

?(("T72" CountType _this) == 1):_type= "T72"

?(("BMP" CountType _this) == 1):_type= "BMP"

?(("BMP2" CountType _this) == 1):_type= "BMP2"

?(("BMPAmbul" CountType _this) == 1):_type= "BMPAmbul"

?(("BRDM" CountType _this) == 1):_type= "BRDM"

?(("BOATE" CountType _this) == 1):_type= "BOATE"

?(("ZSU" CountType _this) == 1):_type= "ZSU"

?(("M2StaticMGE" CountType _this) == 1): _type= "M2StaticMGE"

;;;;RESISTANCE

?(("T55G" CountType _this) == 1):_type= "T55G"

;;If the vehicle cannot move then the script respawns it.  If you only want this

;;to take effect if the vehicle is destroyed or damaged, change it to read

;;?(Getdammage _vcl >.5) or  ?(!Alive _vcl), etc.

#start

~1

?(Canmove _vcl):Goto "start"

~_respawndelay

deleteVehicle _vcl

?(local Server):_vcl = _type createVehicle _position

?(local Server):_vcl setdir _dir

titletext[format["A %1 has been repaired and returned to Base.",_type],"PLAIN DOWN"]

~2

Goto "start"

#end

Exit

;--------------------------------------------------

Share this post


Link to post
Share on other sites

UPDATE:

I also tried adding this into the script:

message = format["A %1 has been repaired and returned to Base.",_vcl]

PublicVariable "message"

hint message

But this returned a null unit. I tried running the first part server side only and then declaring it Public, but then nothing would come up client side since it would only print it server-side.

There has to be some way of doing this. Otherwise, I think that the createvehicle command needs some tweaking. I ran a few tests to see what was being done when a vehicle is deleted or created, and basically, what happens is there is a ID # assigned to each vehicle, i.e. "1455d667 NOID jeep_mg" is the first incarnation of the vehicle. You destroy it, the script respawns it and it comes back as "1833b445 NOID jeep_mg". So basically a completely new id is assigned to it rather than the same id sticking with it. Most of us using this command already knew that but if I could just pass that information to the clients so that the script could print the text on the screen for them then that'd be just wonderful. Unfortunately, if I create the vehicles server-side, they show up and work just fine for the clients, but the clients don't have the variable information, and since they don't have that info, I can't use it to notify them about respawns. Also, since none of the info is passed to the clients at all it seems, the client part of the script assumes the vehicle is dead and keeps looping endlessly since it never sees that a vehicle is created insofar as the variables go.

It's rather important I figure this out, because I have a mission where certain vehicles are captureable by the other team, and they have to respawn if they are destroyed. Right now i'm using the old method of respawn for them, i.e. Setdammage _vcl 0. This is a poor method since sometimes they'll look mangled and crushed, yet be driveable. They also tend to explode numerous times ocassionally.

Welp, if someone at BIS has any ideas, I'd LOVE to hear them!

Thanks!

Share this post


Link to post
Share on other sites

What i tried to tell you is that all messages, you send

out from a gamelogic's waypoint, would appear on both

sides (server and client side).

Also i tried out (by using a sidechat message told by a

present unit), to create a cycle through some waypoints.

For example: wp1 move (onAct: xxx sidechat "whatever")

+ a timeout of 60 seconds - then i let the unit walk to a

cycle wp, which leads it again to wp1. The result was:

the sidechat message appeared again (just to get sure,

the wp's message can be repeated).

While testing i used a real unit, but it would also work with

using a gamelogic. The only thing now, is you have to find

a way, how to send the gamelogic again to wp1.

For example: activate some variable out of your script and

deactivate it again. Or use the wp lock command for that.

Now you only need to create a waypoint cycling gamelogic,

which is only there for telling the message.

hope this helps

Sorry if i'm not clear enough, but i'm still a poor Austrian with

german language (just ask, if it isn't and i try to get more into

detail).

Share this post


Link to post
Share on other sites

Hi,

thats really a tricky one.

One possibility would be to make _vcl a global variable, i.e. vcl and then make it public. But this wouldn't work if you want to use the script multiple times because they would all use vcl as variable and get messed up.

I think the best way would something like DV Chris Death suggested: Keep the whole script local on the server (i.e. use the server condition at the head of the script) and somehow transmit only the spawn message to all computers. To do this I would suggest the following:

Rewrite your respawn loop as follows:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#start

~1

?(Canmove _vcl):Goto "start"

~_respawndelay

deleteVehicle _vcl

_vcl = _type createVehicle _position

_vcl setdir _dir

NewRespawnMessage = true

RespawnMessage = format["A %1 has been repaired and returned to Base.",_type]

PublicVariable "NewRespawnMessage"

PublicVariable "RespawnMessage"

~2

Goto "start"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

This should create two public variables NewRespawnMessage and RespawnMessage if the vehicle is respawned on the server.

To show the message on all computers create a trigger (repeating) with the condition:

NewRespawnMessage

and the On Activation field:

TitleText [RespawnMessage, "PLAIN"]; NewRespawnMessage = false; PublicVariable "NewRespawnMessage"

This trigger should thus be activated on all machines once a vehicle is respawned, it displays the message and deactivates itself, thus being ready for a new message.

This should work if you use the respawn multiple times (i.e. you need only one such trigger).

...and now I hope this stuff will work :-)

Spinor

Share this post


Link to post
Share on other sites

I tried your approach, but this is whatI got:

TitleText [RespawnMessage, "PLAIN"]; NewRespawnMessage = false; PublicVariable "NewRespawnMessage"

Error type any, expected string

It works just fine when I tested it on my computer, i.e. I was hosting it, but as soon as I put it on the dedicated server and tried it, I got that error. The problem is that the variables just are not being made public or something.

You're right, this is a very tricky issue. Obviously there must be a solution, otherwise none of the clients would be able to see respawned vehicles so there MUST be some way of passing this information on to them for use in public text messages.

Back to the drawing board....

Share this post


Link to post
Share on other sites

I think I just found the problem. As stated in the official command reference, you can use PublicVariable only for variables with types Number, Boolean, Object or Group.

So I think

TitleText ["Vehicle respawned", "PLAIN"];

NewRespawnMessage = false; PublicVariable "NewRespawnMessage"

should work.

To make the message appear with the appropriate type you could submit the vehicle like

SpawnedVehicle = _vcl; PublicVariable "SpawnedVehicle"

in your respawn script and rewrite the Action of the trigger as

TitleText [Format["Vehicle %1 has been repaired and returned to Base.", SpawnedVehicle], "PLAIN"];

NewRespawnMessage = false; PublicVariable "NewRespawnMessage"

although with a messy vehicle name.

Hope this works,

Spinor

Share this post


Link to post
Share on other sites

Or perhaps rather than the _vcl var, I could use the _type var which is dtermined in my new vehicle respawn script as well.

Thanks! I'll give it a try!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×