OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Jim666 on 13 Dec 2004, 21:24:00

Title: Locking Unlocking vehicles?
Post by: Jim666 on 13 Dec 2004, 21:24:00
How do i make it so a sspecific player can have like his own vehicle? and only he can lock and unlock it?
Title: Re:Locking Unlocking vehicles?
Post by: macguba on 13 Dec 2004, 21:35:06
If a given vehicle may be driven only by a certain player (I'm assuming this is for MP) then I would suggest that you use addAction to give the player the power to lock and unlock his own wagon.
Title: Re:Locking Unlocking vehicles?
Post by: Triggerhappy on 13 Dec 2004, 21:38:40
heres an idea:
in the player's init field put:
owner = this

then on the car that he will unlock put:
this addaction ["Unlock Car","unlock.sqs"]

then this is the unlock.sqs:
Code: [Select]
_car = this select 0
_unit = _this select 1
_action = _this select 2

?!(_unit == owner):hint "This isn't your car!";exit
_car removeaction _action
_car lock false
;here you could add a sound like unlocking a door
_car addaction ["Lock car","lock.sqs"]
exit

and this will be lock.sqs, which is added by the unlock script
Code: [Select]
_car = _this select 0
_unit = _this select 1
_action = _this select 2
?!(_unit == owner):hint "This isn't your car!";exit
_car removeaction _action
_car lock true
_car addaction ["Unlock car","unlock.sqs"]
exit

that will work with the car starting locked, if it starts unlocked, then switch the action to the lock script
Title: Re:Locking Unlocking vehicles?
Post by: Jim666 on 15 Dec 2004, 11:34:23
I got this error 'action_ = this select 2|#|': Error Select: Type Object, expected Array
Title: Re:Locking Unlocking vehicles?
Post by: Jim666 on 15 Dec 2004, 11:45:54
Nvm fixed it