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:
_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
_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