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:

VINEWOOD

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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:

VINEWOOD

Posted

huh, i don't get you, i've tested it and has no problems.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

When i press "L" it says Vehicle unlocked/locked, and the vehicle gets locked/unlocked.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Did you copy my latest code? because i've changed it many times.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Put the code EXACTLY like it is, leave the messages.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

Does it work? or not?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

VINEWOOD

Posted

Look, i don't f** understand a word of what you say.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

VINEWOOD

Posted

are you saying, when you enter the vehicle and vehicle is locked you can't unlock it anymore?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

VINEWOOD

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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