Jump to content

[HELP] Drift money options problem


NeW

Recommended Posts

Hi guys, I found the drift money script and added "paraver.lua" ı gave the money, but I can not change

drft.lua

--these are the banned vehicle ids where you cannot get drift points. 
local BannedIDs = { 432, 532 } 
  
local rootElem = getRootElement() 
local thisRoot = getResourceRootElement(getThisResource()) 
local player = getLocalPlayer() 
local vehicle 
local size = 1.2 
local modo = 0.01 
local score = 0 
local screenScore = 0 
local tick 
local idleTime 
local multTime 
local driftTime 
local Yellow = tocolor(0,207,186) 
local rr,gg,bb = getPlayerNametagColor(player) 
local Yel = tocolor(rr,gg,bb) 
local Yelx = tocolor(255,0,0) 
local Red = tocolor(234,0,3) 
local TempCol = Yellow 
local TempCol2 = tocolor(rr,gg,bb) 
local mult = 1 
local tablamult = {10,10,10,10} 
local anterior = 0 
local mejor = 0 
local total = 0 
  
local global_mejor = 0 
local global_nombre = "N/A" 
  
local screenWidth, screenHeight = guiGetScreenSize() 
local x1,y1,x2,y2 = screenWidth*0.2,screenHeight*0.1,screenWidth*0.8,screenHeight*0.8 
  
addEventHandler("onClientResourceStart", thisRoot, 
    function() 
        addEventHandler("onClientRender", rootElem, showText) 
        --outputChatBox("Waiting for server drift data...") 
        triggerServerEvent("driftClienteListo", rootElem, player) 
triggerServerEvent ( "load", player)  
    end 
) 
  
addEventHandler("onClientResourceStop", thisRoot, 
    function() 
        removeEventHandler("onClientRender", rootElem, showText) 
    end 
) 
  
function isValidVehicle() 
    local temp = getPedOccupiedVehicle(player) 
     
    if not temp or getVehicleOccupant(temp,0) ~= player or getVehicleType(temp) ~= "Automobile" then 
        return false 
    end 
     
    local vehID = getElementModel(temp) 
    for k,v in ipairs(BannedIDs) do if vehID == v then return false end end 
     
    return temp 
end 
  
function showText() 
    theName = global_nombre 
    theName = theName:gsub("#%x%x%x%x%x%x","") 
if getElementData(player,"renk") == 1 then 
    --dxDrawText(string.format("En Çok Drift: %d / %s",global_mejor,theName),15,182,screenWidth,screenHeight,Yel,1.2,"sans") 
end 
if not getElementData(player,"renk") then 
    --dxDrawText(string.format("En Çok Drift: %d / %s",global_mejor,theName),15,182,screenWidth,screenHeight,Yelx,1.2,"sans") 
end 
     
    vehicle = isValidVehicle() 
    if not vehicle then return end 
     
    if size > 1.3 then  
        modo = -0.01  
    elseif size < 1.2 then  
        modo = 0.01  
    end 
    size = size + modo 
     
    tick = getTickCount() 
    local angulo,velocidad = angle() 
     
    local tempBool = tick - (idleTime or 0) < 750 
    if not tempBool and score ~= 0 then 
        anterior = score 
        --setElementData(player, "Last Drift", anterior) 
toti = getElementData(player,"Toplam drift") 
bes = getElementData(player,"En iyi drift") 
        total = toti+anterior 
        setElementData(player, "Toplam drift", total) 
        triggerServerEvent("driftNuevoRecord", rootElem, total, getPlayerName(player)) 
triggerServerEvent ( "totaldrift", player,total)  
        if score > bes then 
            mejor = score 
            setElementData(player, "En iyi drift", mejor) 
triggerServerEvent ( "bestdrift", player,mejor)  
        end 
        triggerEvent("onVehicleDriftEnd", rootElem, tick-driftTime-0) 
        score = 0 
    end 
     
    if angulo ~= 0 then 
        if score == 0 then  
            triggerEvent("onVehicleDriftStart", rootElem) 
            driftTime = tick 
        end 
        if tempBool then 
            score = score + math.floor(angulo*velocidad)*mult 
        else 
            score = math.floor(angulo*velocidad)*mult 
        end 
        if TempCol == Red then 
            TempCol = Yellow 
        end 
        screenScore = score 
        idleTime = tick 
    end 
     
    --local temp2 = string.format("Factor: X%d\n%s",mult,mult~=5 and string.format("Gain X%d with %d",mult+1,tablamult[mult]) or "MAX") 
    --dxDrawText(temp2, 20,155,screenWidth,screenHeight, Yellow, 1.2, "sans","left","top", false,true,false) 
     
    if velocidad <= 0.3 and mult ~= 1 then 
        --dxDrawText("\n\nToo Slow!", 20,155,screenWidth,screenHeight, Yellow, 1.2, "sans","left","top", false,true,false) 
    end 
     
    if tick - (idleTime or 0) < 3000 then 
        local temp = "DRIFT" 
        if score >= 100000 then 
            temp = "DRIFT\n\nDrift Kralı!" 
        elseif score >= 50000 then 
            temp = "DRIFT\n\nDeli Drift!" 
        elseif score >= 20000 then 
            temp = "DRIFT\n\nMuhteşem!" 
        elseif score >= 15000 then 
            temp = "DRIFT\n\nMükemmel!" 
        elseif score >= 7000 then 
            temp = "DRIFT\n\nSüper Drift!" 
        elseif score >= 3000 then 
            temp = "DRIFT\n\nIyi Drift!" 
        elseif score >= 1000 then 
            temp = "DRIFT\n\nGüzel Drift!" 
        end 
    theName = global_nombre 
    theName = theName:gsub("#%x%x%x%x%x%x","") 
if not getElementData(player,"renk") then 
        dxDrawText(temp, x1,y1,x2,y2, TempCol, 2.2, "sans","center","top", false,true,false) 
        dxDrawText(string.format("\n%d",screenScore),  x1,y1-10,x2,y2, TempCol, size, "pricedown","center","top", false,true,false) 
end 
if getElementData(player,"renk") == 1 then 
        dxDrawText(temp, x1,y1,x2,y2, TempCol2, 2.2, "sans","center","top", false,true,false) 
        dxDrawText(string.format("\n%d",screenScore),  x1,y1-10,x2,y2, TempCol2, size, "pricedown","center","top", false,true,false) 
end 
    end 
end 
  
function angle() 
    local vx,vy,vz = getElementVelocity(vehicle) 
    local modV = math.sqrt(vx*vx + vy*vy) 
     
    if not isVehicleOnGround(vehicle) then return 0,modV end 
     
    local rx,ry,rz = getElementRotation(vehicle) 
    local sn,cs = -math.sin(math.rad(rz)), math.cos(math.rad(rz)) 
     
    local deltaT = tick - (multTime or 0) 
    if mult~= 1 and modV <= 0.3 and deltaT > 750 then 
        mult = mult-1 
        multTime = tick 
    elseif deltaT > 1500 then 
        local temp = 1 
        if score >= 10 then 
            temp = 5 
end 
        if temp>mult then 
            mult = temp 
            multTime = tick 
        end 
    end 
     
    if modV <= 0.2 then return 0,modV end --speed over 40 km/h 
     
    local cosX = (sn*vx + cs*vy)/modV 
    if cosX > 0.966 or cosX < 0 then return 0,modV end --angle between 15 and 90 degrees 
    return math.deg(math.acos(cosX))*0.5, modV 
end 
  
addEvent("driftCarCrashed", true) 
addEventHandler("driftCarCrashed", rootElem,  
    function() 
        if score ~= 0 then 
            score = 0 
            mult = 0 
            TempCol = Red 
            triggerEvent("onVehicleDriftEnd", rootElem, 0) 
triggerServerEvent ( "takemoney", player)    
end 
    end 
) 
  
addEvent("driftActualizarRecord", true) 
addEventHandler("driftActualizarRecord", rootElem, 
    function(score, name) 
        global_mejor = score 
        global_nombre = name 
    end 
) 
function resetScore() 
    anterior,mejor,total = 0,0,0 
    --setElementData(player, "Last Drift", anterior) 
    setElementData(player, "Toplam drift", total) 
    setElementData(player, "En iyi drift", mejor) 
end 
addEvent("driftResetAllScores", true) 
addEventHandler("driftResetAllScores", rootElem, resetScore) 
addCommandHandler("resetdrift", resetScore) 
  
function resetScore() 
if not getELementData(player,"Toplam drift") and not getElementData(player,"En iyi drift") then 
    setElementData(player, "Toplam drift",0) 
    setElementData(player, "En iyi drift",0) 
end  
end 
addEventHandler("onPlayerJoin", rootElem, resetScore) 

drft_server.lua

local root = getRootElement() 
local thisResourceRoot = getResourceRootElement(getThisResource()) 
local drift_records = {} 
local drift_mejor = 0 
local drift_nombre = "N/A" 
  
addEventHandler ( "onResourceStart", thisResourceRoot, 
    function() 
        call(getResourceFromName("scoreboard"), "addScoreboardColumn", "En iyi drift") 
        --call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Last Drift") 
        call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Toplam drift") 
         
        executeSQLCreateTable("recordsDrift","pista TEXT, nombre TEXT, score INTEGER") 
         
        addEvent("driftClienteListo", true) 
        addEventHandler("driftClienteListo", root, function(player) 
            triggerClientEvent(player, "driftActualizarRecord", root, drift_mejor, drift_nombre) 
            if drift_mejor == 0 then 
                --outputChatBox("There's no record set on this map", player) 
            else 
                --outputChatBox(string.format("The current record is %d points (%s)", drift_mejor, drift_nombre), player) 
            end 
        end) 
    end 
) 
  
addEventHandler ( "onResourceStop", thisResourceRoot, 
    function() 
        call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "En iyi drift") 
        --call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "Last Drift") 
        call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "Toplam drift") 
    end 
) 
  
addEventHandler ( "onGamemodeMapStart", root, function(mapResource) 
    local mapname = getResourceInfo(mapResource, "name") or getResourceName(mapResource) 
    local command = string.format("pista='%s'",mapname) 
    local record = executeSQLSelect("recordsDrift","nombre, score",command) 
     
    if #record == 0 then 
        executeSQLInsert("recordsDrift",string.format("'%s', 'N/A', 0",mapname)) 
        drift_mejor = 0 
        drift_nombre = "N/A" 
    else 
        drift_mejor = record[1]["score"] 
        drift_nombre = record[1]["nombre"] 
    end 
    triggerClientEvent(root, "driftActualizarRecord", root, drift_mejor, drift_nombre) 
    --triggerClientEvent(root, "driftResetAllScores", root) 
    if drift_mejor == 0 then 
        --outputChatBox("There's no record set on this map") 
    else 
        --outputChatBox(string.format("The current record is %d points (%s)", drift_mejor, drift_nombre)) 
    end 
end) 
  
addEventHandler ( "onGamemodeMapStop", root, function(mapResource) 
    local mapname = getResourceInfo(mapResource, "name") or getResourceName(mapResource) 
    if not mapname then return end 
     
    local command = string.format("pista='%s'",mapname) 
    executeSQLUpdate("recordsDrift",string.format("nombre = '%s', score = %d", drift_nombre, drift_mejor), command) 
end) 
  
addEventHandler("onVehicleDamage", root, function() 
    thePlayer = getVehicleOccupant(source, 0) 
    if thePlayer then 
        triggerClientEvent(thePlayer, "driftCarCrashed", root, source) 
    end 
end) 
  
addEvent("driftNuevoRecord", true) 
addEventHandler("driftNuevoRecord", root, function(score, name) 
    if score > drift_mejor then 
        --outputChatBox(string.format("New drift record! (%d points) (%s)",score,name))  
        drift_mejor = score 
        drift_nombre = name 
        triggerClientEvent(root, "driftActualizarRecord", root, drift_mejor, drift_nombre) 
    end 
end) 
addEventHandler("onVehicleDriftEnd", root, function() 
        triggerClientEvent(thePlayer, "driftScore", root, source) 
end) 
  
addEventHandler ( 'onPlayerLogin', root, 
    function () 
        local account = getPlayerAccount ( source ) 
        if ( account ) then 
            local bestLoad = getAccountData ( account, 'En iyi drift' ) 
            local totalLoad = getAccountData ( account, 'Toplam drift' ) 
            if bestLoad and totalLoad then 
                setElementData ( source, 'En iyi drift', bestLoad ) 
                setElementData ( source, 'Toplam drift', totalLoad ) 
else 
                setElementData ( source, 'En iyi drift', 0 ) 
                setElementData ( source, 'Toplam drift', 0 ) 
            end 
        end 
    end 
) 
  
function load (_,account) 
        if ( account ) then 
            local bestLoad = getAccountData ( account, 'En iyi drift' ) 
            local totalLoad = getAccountData ( account, 'Toplam drift' ) 
            if bestLoad and totalLoad then 
                setElementData ( source, 'En iyi drift', bestLoad ) 
                setElementData ( source, 'Toplam drift', totalLoad ) 
            end 
        end 
end 
addEvent( "load", true ) 
addEventHandler( "load", root, load ) 
  
function total (total) 
        local account = getPlayerAccount ( source ) 
        if ( account ) then 
        if not ( isGuestAccount ( account ) ) then 
            setAccountData ( account, 'Toplam drift',total ) 
            end 
        end 
end 
addEvent( "totaldrift", true ) 
addEventHandler( "totaldrift", root, total) 
  
function mejor (mejor) 
        local account = getPlayerAccount ( source ) 
        if ( account ) then 
        if not ( isGuestAccount ( account ) ) then 
            setAccountData ( account, 'En iyi drift',mejor ) 
            end 
        end 
end 
addEvent( "bestdrift", true ) 
addEventHandler( "bestdrift", root, mejor) 
  

paraver.lua

function asd(player) 
            givePlayerMoney(player,1) 
    end 
        addEvent("onVehicleDriftEnd", true) 
        addEventHandler("onVehicleDriftEnd", getRootElement(), asd) 

One writes, but the drift made 2-3 times more giving, I want to give you a quarter of the drift made.

My English is a little poor, sorry.

Thanks...

Link to comment

replace player with client here

function asd() 
            givePlayerMoney(client,1) -- money here 
            outputChatBox("test",client,255,0,0) 
end 
addEvent("onVehicleDriftEnd", true) 
addEventHandler("onVehicleDriftEnd", getRootElement(), asd) 

Link to comment
Money does not come, "testing" does not appear in the text.

Many things wrong in your code , sorry i can't fix them all i'm busy anyways try this one it should work.

--these are the banned vehicle ids where you cannot get drift points. 
local BannedIDs = { 432, 532 } 
  
local rootElem = getRootElement() 
local thisRoot = getResourceRootElement(getThisResource()) 
local player = getLocalPlayer() 
local vehicle 
local size = 1.2 
local modo = 0.01 
local score = 0 
local screenScore = 0 
local tick 
local idleTime 
local multTime 
local driftTime 
local Yellow = tocolor(0,207,186) 
local rr,gg,bb = getPlayerNametagColor(player) 
local Yel = tocolor(rr,gg,bb) 
local Yelx = tocolor(255,0,0) 
local Red = tocolor(234,0,3) 
local TempCol = Yellow 
local TempCol2 = tocolor(rr,gg,bb) 
local mult = 1 
local tablamult = {10,10,10,10} 
local anterior = 0 
local mejor = 0 
local total = 0 
  
local global_mejor = 0 
local global_nombre = "N/A" 
  
local screenWidth, screenHeight = guiGetScreenSize() 
local x1,y1,x2,y2 = screenWidth*0.2,screenHeight*0.1,screenWidth*0.8,screenHeight*0.8 
  
addEventHandler("onClientResourceStart", thisRoot, 
    function() 
        addEventHandler("onClientRender", rootElem, showText) 
        --outputChatBox("Waiting for server drift data...") 
        triggerServerEvent("driftClienteListo", rootElem, player) 
triggerServerEvent ( "load", player) 
    end 
) 
  
addEventHandler("onClientResourceStop", thisRoot, 
    function() 
        removeEventHandler("onClientRender", rootElem, showText) 
    end 
) 
  
function isValidVehicle() 
    local temp = getPedOccupiedVehicle(player) 
    
    if not temp or getVehicleOccupant(temp,0) ~= player or getVehicleType(temp) ~= "Automobile" then 
        return false 
    end 
    
    local vehID = getElementModel(temp) 
    for k,v in ipairs(BannedIDs) do if vehID == v then return false end end 
    
    return temp 
end 
  
function showText() 
    theName = global_nombre 
    theName = theName:gsub("#%x%x%x%x%x%x","") 
if getElementData(player,"renk") == 1 then 
    --dxDrawText(string.format("En Çok Drift: %d / %s",global_mejor,theName),15,182,screenWidth,screenHeight,Yel,1.2,"sans") 
end 
if not getElementData(player,"renk") then 
    --dxDrawText(string.format("En Çok Drift: %d / %s",global_mejor,theName),15,182,screenWidth,screenHeight,Yelx,1.2,"sans") 
end 
    
    vehicle = isValidVehicle() 
    if not vehicle then return end 
    
    if size > 1.3 then 
        modo = -0.01 
    elseif size < 1.2 then 
        modo = 0.01 
    end 
    size = size + modo 
    
    tick = getTickCount() 
    local angulo,velocidad = angle() 
    
    local tempBool = tick - (idleTime or 0) < 750 
    if not tempBool and score ~= 0 then 
        anterior = score 
        --setElementData(player, "Last Drift", anterior) 
        toti = getElementData(player,"Toplam drift") 
        bes = getElementData(player,"En iyi drift") 
        total = toti+anterior 
        setElementData(player, "Toplam drift", total) 
        triggerServerEvent("driftNuevoRecord", rootElem, total, getPlayerName(player)) 
triggerServerEvent ( "totaldrift", player,total) 
        if score > bes then 
            mejor = score 
            setElementData(player, "En iyi drift", mejor) 
triggerServerEvent ( "bestdrift", player,mejor) 
        end 
        triggerEvent("onVehicleDriftEnd", rootElem, player) 
        score = 0 
    end 
    
    if angulo ~= 0 then 
        if score == 0 then 
            triggerEvent("onVehicleDriftStart", rootElem) 
            driftTime = tick 
        end 
        if tempBool then 
            score = score + math.floor(angulo*velocidad)*mult 
        else 
            score = math.floor(angulo*velocidad)*mult 
        end 
        if TempCol == Red then 
            TempCol = Yellow 
        end 
        screenScore = score 
        idleTime = tick 
    end 
    
    --local temp2 = string.format("Factor: X%d\n%s",mult,mult~=5 and string.format("Gain X%d with %d",mult+1,tablamult[mult]) or "MAX") 
    --dxDrawText(temp2, 20,155,screenWidth,screenHeight, Yellow, 1.2, "sans","left","top", false,true,false) 
    
    if velocidad <= 0.3 and mult ~= 1 then 
        --dxDrawText("\n\nToo Slow!", 20,155,screenWidth,screenHeight, Yellow, 1.2, "sans","left","top", false,true,false) 
    end 
    
    if tick - (idleTime or 0) < 3000 then 
        local temp = "DRIFT" 
        if score >= 100000 then 
            temp = "DRIFT\n\nDrift Kralı!" 
        elseif score >= 50000 then 
            temp = "DRIFT\n\nDeli Drift!" 
        elseif score >= 20000 then 
            temp = "DRIFT\n\nMuhteşem!" 
        elseif score >= 15000 then 
            temp = "DRIFT\n\nMükemmel!" 
        elseif score >= 7000 then 
            temp = "DRIFT\n\nSüper Drift!" 
        elseif score >= 3000 then 
            temp = "DRIFT\n\nIyi Drift!" 
        elseif score >= 1000 then 
            temp = "DRIFT\n\nGüzel Drift!" 
        end 
    theName = global_nombre 
    theName = theName:gsub("#%x%x%x%x%x%x","") 
if not getElementData(player,"renk") then 
        dxDrawText(temp, x1,y1,x2,y2, TempCol, 2.2, "sans","center","top", false,true,false) 
        dxDrawText(string.format("\n%d",screenScore),  x1,y1-10,x2,y2, TempCol, size, "pricedown","center","top", false,true,false) 
end 
if getElementData(player,"renk") == 1 then 
        dxDrawText(temp, x1,y1,x2,y2, TempCol2, 2.2, "sans","center","top", false,true,false) 
        dxDrawText(string.format("\n%d",screenScore),  x1,y1-10,x2,y2, TempCol2, size, "pricedown","center","top", false,true,false) 
end 
    end 
end 
  
function angle() 
    local vx,vy,vz = getElementVelocity(vehicle) 
    local modV = math.sqrt(vx*vx + vy*vy) 
    
    if not isVehicleOnGround(vehicle) then return 0,modV end 
    
    local rx,ry,rz = getElementRotation(vehicle) 
    local sn,cs = -math.sin(math.rad(rz)), math.cos(math.rad(rz)) 
    
    local deltaT = tick - (multTime or 0) 
    if mult~= 1 and modV <= 0.3 and deltaT > 750 then 
        mult = mult-1 
        multTime = tick 
    elseif deltaT > 1500 then 
        local temp = 1 
        if score >= 10 then 
            temp = 5 
end 
        if temp>mult then 
            mult = temp 
            multTime = tick 
        end 
    end 
    
    if modV <= 0.2 then return 0,modV end --speed over 40 km/h 
    
    local cosX = (sn*vx + cs*vy)/modV 
    if cosX > 0.966 or cosX < 0 then return 0,modV end --angle between 15 and 90 degrees 
    return math.deg(math.acos(cosX))*0.5, modV 
end 
  
addEvent("driftCarCrashed", true) 
addEventHandler("driftCarCrashed", rootElem, 
    function() 
        if score ~= 0 then 
            score = 0 
            mult = 0 
            TempCol = Red 
            triggerEvent("onVehicleDriftEnd", rootElem, source) 
triggerServerEvent ( "takemoney", player)   
end 
    end 
) 
  
addEvent("driftActualizarRecord", true) 
addEventHandler("driftActualizarRecord", rootElem, 
    function(score, name) 
        global_mejor = score 
        global_nombre = name 
    end 
) 
function resetScore() 
    anterior,mejor,total = 0,0,0 
    --setElementData(player, "Last Drift", anterior) 
    setElementData(player, "Toplam drift", total) 
    setElementData(player, "En iyi drift", mejor) 
end 
addEvent("driftResetAllScores", true) 
addEventHandler("driftResetAllScores", rootElem, resetScore) 
addCommandHandler("resetdrift", resetScore) 
  
function resetScore() 
if not getELementData(player,"Toplam drift") and not getElementData(player,"En iyi drift") then 
    setElementData(player, "Toplam drift",0) 
    setElementData(player, "En iyi drift",0) 
end  
end 
addEventHandler("onPlayerJoin", rootElem, resetScore) 
  
function asd(player) 
    givePlayerMoney(player,1) -- money here 
    outputChatBox("test",player,255,0,0) 
end 
addEvent("onVehicleDriftEnd", true) 
addEventHandler("onVehicleDriftEnd", getRootElement(), asd) 

Link to comment

you need to make the give money thing into drft_server.lua and drft.lua

something like this

drft.lua

    tick = getTickCount() 
    local angulo,velocidad = angle() 
    total = getElementData( player, "Drift Score" ) 
    mejor = getElementData( player, "Best Drift" ) 
    local tempBool = tick - (idleTime or 0) < 750 
    if not tempBool and score ~= 0 then 
        anterior = score 
        setElementData(player, "Last Drift", anterior) 
        total = total+anterior 
        cash = anterior/100 
        triggerServerEvent("updatecash", player, player, cash ) 
        checkPuntaje(anterior) 
         
        setElementData(player, "Drift Score", total) 
        if score > mejor then 
            mejor = score 
            setElementData(player, "Best Drift", mejor) 
        end 
        triggerEvent("onVehicleDriftEnd", rootElem, tick-driftTime-750) 
        score = 0 
    end 

drft_server.lua

function gcash(player,money) 
givePlayerMoney( player, tonumber(money) ) 
end 
addEvent("updatecash", true ) 
addEventHandler("updatecash", root, gcash ) 

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