Jump to content

Need help with onClientPlayerStuntStart


Recommended Posts

I want this to be used in my upcoming server and I also wants players to get paid whenever they perform stunt.

Such as if they perform wheelie for 1 second they will get 10$

stoppie 1 second 20$

2wheeler 1 second 50$

addEventHandler( "onClientPlayerStuntStart", getRootElement( ), 
    function ( stuntType ) 
        outputChatBox( "You started stunt: " .. stuntType ); 
    end 
); 
  
addEventHandler( "onClientPlayerStuntFinish", getRootElement( ), 
    function ( stuntType, stuntTime, distance ) 
        outputChatBox( "You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ) ); 
    end 
); 
  

Pls help me out

Link to comment
timer = false 
  
local money = { 
    ["wheelie"] = 10, 
    ["stoppie"] = 20, 
    ["2wheeler"] = 50 
} 
  
addEventHandler( "onClientPlayerStuntStart", getRootElement( ), 
    function ( stuntType ) 
        outputChatBox( "You started stunt: " .. stuntType ); 
        timer = setTimer ( givePlayerMoney, 1000, 0, money[stuntType] ); 
    end 
); 
  
addEventHandler( "onClientPlayerStuntFinish", getRootElement( ), 
    function ( stuntType, stuntTime, distance ) 
        if isTimer ( timer ) then killTimer ( timer ) end 
    end 
); 
  

Link to comment

Try this it should work

local VehicleType =  {['BMX'] = true, ['Bike'] = true } 
local sType = {["wheelie"] = 10,["stoppie"] = 20,["2wheeler"] = 50} 
  
addEventHandler( "onClientPlayerStuntFinish", getRootElement( ),  
    function (stuntType, stuntTime, distance ) 
        if ( source ~= localPlayer ) then return end 
        local vehicle = getPedOccupiedVehicle ( source )  
        if ( not vehicle ) then return end 
        if ( not VehicleType[getVehicleType(vehicle)] ) then return end 
        local seconds = math.floor ( stuntTime / 1000 ) 
        if ( seconds >= 2 and distance == 0 ) then 
            money = seconds * sType[stuntType] 
            outputChatBox("You finished stunt: "..tostring(stuntType)..", Time: "..tostring(seconds).." seconds! #00ff00+ $"..money,255,0,0,true) 
            givePlayerMoney(tonumber(money)) 
        elseif ( seconds > 0 and distance > 0 ) then 
            money = ( seconds * sType[stuntType] ) + ( distance * 3 ) 
            outputChatBox("You finished stunt: "..tostring(stuntType)..", Time: "..tostring(seconds).." seconds, Distance: "..tostring(distance).." meters! #00ff00+ $"..money,255,0,0,true) 
        givePlayerMoney(tonumber(money)) 
    end 
end  
) 

Link to comment

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