Jump to content

Vehicle own can Lock/unLock door


Jumper_Mych

Recommended Posts

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:

Link to comment

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
Link to comment

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

Link to comment

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...