Pierce Posted March 11, 2014 Share Posted March 11, 2014 nvehicle = createVehicle( 411, -1319.6854248047, -500.11340332031, 14.1484375 ) setVehicleDamageProof( nvehicle, true ) setVehicleLocked( nvehicle, true ) function check() if getPlayerName(test) then setVehicleLocked( nvehicle, false ) else cancelEvent () end end addEventHandler("onVehicleEnter", getRootElement(), check) I'm trying to make a private vehicle for myself,just to practice lua because i'm bored,but it's not working for me and i don't know why. it sets Vehicle locked and damageproof but getPlayerName isnt working. Please help me Link to comment
xXMADEXx Posted March 11, 2014 Share Posted March 11, 2014 Your code doesn't really make since... nvehicle = createVehicle( 411, -1319.6854248047, -500.11340332031, 14.1484375 ) setVehicleDamageProof( nvehicle, true ) setVehicleLocked( nvehicle, true ) function check( p ) if getPlayerName( p ) == "test" then setVehicleLocked( nvehicle, false ) else cancelEvent () end end addEventHandler("onStatVehicleEnter", nvehicle, check) Link to comment
Pierce Posted March 11, 2014 Author Share Posted March 11, 2014 Doesn't work xXMADEXx Link to comment
pa3ck Posted March 11, 2014 Share Posted March 11, 2014 Because 'test' is nil, you never defined it. How would the server know whom to check? -- I mean in the first code @xXxMADExXx you had a typo @ 'onVehicleStartEnter' nvehicle = createVehicle( 411, -1319.6854248047, -500.11340332031, 14.1484375 ) setVehicleDamageProof( nvehicle, true ) setVehicleLocked( nvehicle, true ) function check(enteringPlayer, seat ) -- always look for these parameters @ wiki, they're quite well explained. if getPlayerName( enteringPlayer ) == "Whatever name you want" then -- name of the player who can actually enter the car setVehicleLocked( nvehicle, false ) else cancelEvent () -- cancel the 'onVehicleStartEnter' event end end addEventHandler("onVehicleStartEnter", getRootElement(), check) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now