Home   Help Search Login Register  

Author Topic: Working Vehicle Respawn Script  (Read 1353 times)

0 Members and 1 Guest are viewing this topic.

Viper4841

  • Guest
Working Vehicle Respawn Script
« on: 10 Apr 2003, 19:20:37 »
I have finished a very reliable respawn script for vehicles, and it works fine on a single player mission. However, there's one problem: when I use it in multiplayer, the CamCreate command I use to create a vehicle is run on the host machine, as well as on each client, so several vehicles appear right next to each other!  This is a funny effect, but not what I'm looking for...

DOES ANYONE KNOW THE COMMAND THAT CHECKS TO SEE IF THE LOCAL MACHINE IS THE HOST???

If the local machine is a client, the respawn script will not be run, but it WILL be run only on the server, creating the desired effect.

Thanks!

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re:Working Vehicle Respawn Script
« Reply #1 on: 11 Apr 2003, 16:46:22 »
Found in official forum:

When you make a map, put a gamelogic somewhere. Name it "server".
To stop a script running on a client, use this at the start:

Quote
?! (local server):exit
« Last Edit: 11 Apr 2003, 16:47:16 by DrStrangelove »

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re:Working Vehicle Respawn Script
« Reply #2 on: 11 Apr 2003, 20:07:35 »
I reworked a genuine vehicle respawn script from Doolittle (the King of Respawns). I found it on the official forum, however, i think it's in order i post it here  ???

Code: [Select]
;By Doolittle
;USE
;put into INIT FIELD of 1st vehicle on map: vehicles = [this]
;put into INIT FIELDS of any other vehicle: vehicles = vehicles + [this]
;make trigger that runs ONCE:  Condition: local Server OnActivation: [] exec "vehicles.sqs"
;make a GameLogic called Server

_vpos = []
_vdir = []
_vtime = []
_count = count vehicles
_delay = 1
_delaya = 120

_i = 0
#load
_v = vehicles select _i
_vpos = _vpos + [[getPos _v select 0, getPos _v select 1, 0]]
_vdir = _vdir + [getDir _v]
_vtime = _vtime + [0]
_i = _i + 1
?_i < _count : goto "load"

#init
_i = 0
~20
#alive
_v = vehicles select _i
?fuel _v == 1 : goto "continue"
?alive _v and count crew _v != 0 : _vtime set [_i, 0]
_vt = _vtime select _i
?_vt != 0 and _vt < _time : goto "notalive"
?count crew _v == 0 and _vt == 0 : _vtime set [_i, _time + _delaya]
?!alive _v and _vt == 0 : _vtime set [_i, _time + _delay]
#continue
_i = _i + 1
?_i < _count : goto "alive"
goto "init"

#notalive
_vtype = typeOf _v
deleteVehicle _v
~1
_v = _vtype createVehicle (_vpos select _i)
_v setDir (_vdir select _i)
vehicles set [_i, _v]
_vtime set [_i, 0]
goto "continue"

Pay attention to header how to use it. This script is the "vehicles.sqs" mentioned there of course.

What i've changed:
The original script had only 1 certain delay for respawning vehicles that are (a.) destroyed or (b.) left alone by the crew. I wanted to have seperate delay times for my MP mission.
Basically i set the above delay values to:
(delay =) 1 sek for destroyed vehicles.
(delaya =) 120 sek for abandoned vehicles that are NOT destroyed.

The script checks the vehicle status every 20 secondes (i changed that, too). I found that with a fast check rate the computer considers a vehicle abandoned too fast. That is when you, the player, see the end coming and eject from your vehicle in an emergency. Although the airvehicle goes down & explodes, it's already considered 'abandoned' and therefore take a looong time to respawn, unlike a vehicle that is destroyed instantly. Therefore the 20 seconds (every aircraft should come down during that period)  ;)

If i forgot something or you can't get it to work just blame me, not Dolittle *gg*  ;D
« Last Edit: 11 Apr 2003, 20:16:45 by DrStrangelove »

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:Working Vehicle Respawn Script
« Reply #3 on: 12 Apr 2003, 07:38:48 »
Naw, you can blame me too if you want. :)

Doolittle

Tania

  • Guest
Re:Working Vehicle Respawn Script
« Reply #4 on: 01 Jun 2003, 00:24:13 »
vechile respawn is hard.can someone sort of get in touch with me?i need assistance badly  :-\