Jump to content

Points for something


Mefisto_PL

Recommended Posts

Posted

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) 

Posted
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

Posted

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 ) 

Posted
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?

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

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