Jump to content

Vehicle own can Lock/unLock door


Jumper_Mych

Recommended Posts

Posted

Hi :mrgreen:

Vehicle Lock a Player bind key L is lock and unlock door vehicle but owner name can key unlock and lock door vehicle.

example Jumper_Mych can press L (unlock and lock) because it is your own car. Obama Barack can't press L unlock and lock the vehicle because no owner vehicle.

thanks for helping

doesn't work :(

vehicle = createVehicle ( 496, 2425, -55, 27, 0, 0, 0 ) 
setElementData(vehicle,"vehicle","car") 
setElementData(vehicle, "owner", "Jumper_Mych") 
  
function lockcar ( player ) 
    if (getElementData(source, "vehicle" ) == "car") and ( getElementData(source, "owner" ) == getPlayerName(player) ) then 
    if isVehicleLocked ( player ) then 
            setVehicleLocked ( player, false ) 
        else  
            setVehicleLocked ( player, true )  
        cancelEvent() 
    end 
end 
  
function bindLockOnSpawn ( theSpawnpoint ) 
    bindKey ( source, "l", lockcar ) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), bindLockOnSpawn ) 

If it works, delete my topic because your not allowed. Never hold my topic :redhotevil:

Posted

Your code has many errors, you got missing "end" and not needed stuff.

try this code,

vehicle = createVehicle ( 496, 2425, -55, 27, 0, 0, 0 ) 
setElementData(vehicle,"vehicle","car") 
setElementData(vehicle, "owner", "Jumper_Mych") 
  
function lockcar ( player ) 
    if (getElementData(vehicle, "vehicle" ) == "car") and ( getElementData(vehicle, "owner" ) == getPlayerName(player) ) then 
    if isVehicleLocked ( vehicle ) then 
            setVehicleLocked ( vehicle, false ) 
            outputChatBox("Vehicle unlocked!",player,0,255,0) 
        else 
            setVehicleLocked ( vehicle, true ) 
            outputChatBox("Vehicle locked!",player,255,0,0) 
        end 
    end 
end 
  
function bindLockOnSpawn ( ) 
    bindKey ( source, "l", "down", lockcar ) 
end 
addEventHandler( "onPlayerSpawn", getRootElement(), bindLockOnSpawn ) 

P.S: Stop saying "Don't copy my code" and so on because your codes always fails :P

  • Like 1
Posted

Sit in vehicle can lock and unlock is work! but exit vehicle and go lock and unlock door vehicle doesn't work.

I try sit in vehicle set lock and exit cant lock

when error :redhotevil:

Posted

Are you sure you copied it right? Because Solidsnake14's code has messages and I don't see any messages on your video ..

Posted
wow, a vehicle can sit on a player o_o? that's really strange, don't you think?

huh, Player is sit the vehicle can lock and unlock is work! but player is stay doesn't sit the vehicle doesn't work lock and unlock, do you know? :D

Does it work? or not?

Not yet finished. :|

Posted

to watch video youtube

Solidsnake14 code:

1. Player in Vehicle can Lock and unlock - work

2. Player get out vehicle can lock and unlock - Doesn't work

3. Player in vehicle is lock can't get out vehicle - Doesn't work

sure you understand it

Posted

Solidsnake14 code:

1. Player in Vehicle can Lock and unlock - work

2. Player get out vehicle can lock and unlock - Doesn't work

3. Player in vehicle is lock can't get out vehicle - Doesn't work

do not you understand? :?

I say Vehicle in ped work lock and unlock door

Ped get out the vehicle next can't lock door vehicle and unlock

Posted

I should try something???? the code works with no errors at my private server, how that comes?

P.S: You copied my word "You should at least try something first." -_-

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...