Mefisto_PL Posted November 3, 2012 Share Posted November 3, 2012 Hi ! I would like to make player can jump in vehicle but if he has 50 points.. I made it but now script isn't working.. function Veh_Jump () local p_Vehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( points >= 50 ) then if p_Vehicle and isVehicleOnGround ( p_Vehicle ) then local px, py, pz = getElementVelocity ( p_Vehicle ) setElementVelocity ( p_Vehicle, px, py, pz + 0.7 ) if ( points <= 50 ) then setElementVelocity ( p_Vehicle, px, py, pz ) end end end end bindKey("lshift","down",Veh_Jump) addCommandHandler("vehjump", Veh_Jump) Link to comment
fmj02 Posted November 3, 2012 Share Posted November 3, 2012 function Veh_Jump(key, keyState) if(keyState == "down") then local p_Vehicle = getPedOccupiedVehicle(localPlayer) if(points >= 50) then if p_Vehicle and isVehicleOnGround (p_Vehicle) then local px, py, pz = getElementVelocity (p_Vehicle) setElementVelocity (p_Vehicle, px, py, pz + 0.7) end else end end end bindKey("lshift", "down", Veh_Jump) addCommandHandler("vehjump", Veh_Jump) try now Link to comment
Castillo Posted November 3, 2012 Share Posted November 3, 2012 Where is the variable 'points' defined? Link to comment
Mefisto_PL Posted November 3, 2012 Author Share Posted November 3, 2012 This is defined in server-side script function scorePoints ( ) call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Points") for theKey,thePlayer in ipairs(getElementsByType ( "player" )) do setElementData ( thePlayer, "Points", 0 ) end end addEventHandler ( "onResourceStart", getResourceRootElement(), scorePoints ) function createPoints ( ) setElementData ( thePlayer, "Points", 0 ) end addEventHandler ( "onPlayerJoin", getRootElement(), createPoints ) Link to comment
Castillo Posted November 3, 2012 Share Posted November 3, 2012 Where's: points = getElementData ( localPlayer, "Points" ) defined? Link to comment
Mefisto_PL Posted November 3, 2012 Author Share Posted November 3, 2012 I didn't send the full code but it's on first line points = getElementData ( getLocalPlayer(), "Points" ) Link to comment
Smart. Posted November 3, 2012 Share Posted November 3, 2012 I didn't send the full code but it's on first line points = getElementData ( getLocalPlayer(), "Points" ) You sure that the player actually got more than 50 points? Link to comment
Mefisto_PL Posted November 3, 2012 Author Share Posted November 3, 2012 I have it in scoreboard.. Link to comment
DiSaMe Posted November 3, 2012 Share Posted November 3, 2012 I didn't send the full code but it's on first line Then for sure it doesn't work because you check the points which the player had when resource started. You need to get the points every time before you check them. Link to comment
Mefisto_PL Posted November 3, 2012 Author Share Posted November 3, 2012 I fix that in another way, but thanks for help. 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