I read about 100 threads on locking and unlocking which I understand... but, I made a vehicle spawning script, the car starts out locked and I only want the person that bought it to be able to lock or unlock it...
civ1 - civ15 and cop1 - cop5 are the player names....
; Set the civ1 - civ15 and cop1 - cop5 title...
_name = "Not Set"
{call format ["if (player == %1) then {_name = ""%1""}", _x]} forEach allarray
_unit = objNull
call format ["_unit = %1", _name]
;Transaction done
#complete
call format ["%1 groupChat ""%1 you purchased: %2 and now have $%3 in your pocket and $%4 in your bank account.""",_name,_itemname,_cash,_bank]
~1
_pos = getPos _unit
call format ["_vehicle = ""%1"" createVehicle _pos; _vehicle lock true; _vehicle addaction [""[Unlock]"", ""Scripts\Vehicles\Unlock.sqs""]; [_vehicle] exec ""Scripts\Environment\Recycler.sqs""",_itemcname];
Exit
This part works by making the vehicle - some variables are in the script....
The action gets added to the vehicle, not sure it is added for the owner only or not.. but anyway this is the lock and unlock script, as copied from a thread in this forum...
Lock.sqs
_car = _this select 0
_unit = _this select 1
_action = _this select 2
_car removeaction _action
_car lock true
_car addaction ["[Unlock]","Scripts\Vehicles\Unlock.sqs"]
exit
Unlock.sqs
_car = this select 0
_unit = _this select 1
_action = _this select 2
_car removeaction _action
_car lock false
_car addaction ["[Lock]","Scripts\Vehicles\Lock.sqs"]
exit
I get the error:
_car this select 0 |#|': Error select: Type Object, expected Array