Reezmi Posted September 19, 2012 Share Posted September 19, 2012 function giveNitro () local theVehicle = getPedOccupiedVehicle ( thePlayer ) if theVehicle then outputDebugString('vehicle') addVehicleUpgrade ( theVehicle, 1010 ) else outputDebugString('foot') end end function bindNitro () outputDebugString('loaded') bindKey ( "fire", "both", giveNitro ) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), bindNitro) function bindNitroForJoinedPlayer() bindKey ( "fire", "both", giveNitro ) end addEventHandler("onPlayerJoin", getResourceRootElement(getThisResource()), bindNitroForJoinedPlayer) As title says, it doesnt work on cars. Am I missing something? Link to comment
Castillo Posted September 19, 2012 Share Posted September 19, 2012 That's because: 1: at getPedOccupiedVehicle you use 'thePlayer', but you never defined it. 2: You are using 'onClientResourceStart' which is client side at the same time as 'onPlayerJoin' which is server side. 3: I think your whole script should be set server side. function giveNitro ( thePlayer ) local theVehicle = getPedOccupiedVehicle ( thePlayer ) if theVehicle then outputDebugString ( 'vehicle' ) addVehicleUpgrade ( theVehicle, 1010 ) else outputDebugString ( 'foot' ) end end function bindNitro ( ) outputDebugString ( 'loaded' ) for _, player in ipairs ( getElementsByType ( "player" ) ) do bindKey ( player, "fire", "both", giveNitro ) end end addEventHandler ( "onResourceStart", resourceRoot, bindNitro ) function bindNitroForJoinedPlayer ( ) bindKey ( source, "fire", "both", giveNitro ) end addEventHandler ( "onPlayerJoin", root, bindNitroForJoinedPlayer ) This is a server side script. Link to comment
Reezmi Posted September 19, 2012 Author Share Posted September 19, 2012 Thanks, now it works. Always making stupid mistakes Link to comment
Castillo Posted September 19, 2012 Share Posted September 19, 2012 You're welcome. P.S: That's a good way to learn: trial and fail. 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