Jump to content

[HELP] DERBY STATS


Recommended Posts

Posted

Hi guys, im making a derby server, I need help with storing info to the user's account, some of the information i need to store is, the player's rank from all the players in the server based on points(which also needs to be stored) and the players chosen skin, and car colour/headlight color. Help Please and thank you

Eat My Dust - DM/Deathmatch

350x20_00C3FF_FFFFFF_000000_000000.png

Posted

You can use the account data functions, that would be easier for you.

getAccountData 
setAccountData 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
You can use the account data functions, that would be easier for you.
getAccountData 
setAccountData 

YOU can do that?? Thanks!!

Eat My Dust - DM/Deathmatch

350x20_00C3FF_FFFFFF_000000_000000.png

Posted

Of course you can.

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
  
playerAccount = getPlayerAccount ( source ) 
playerVehicle = getPlayerOccupiedVehicle ( playerSource ) 
function saveColours () 
    if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
            local color1, color2, color3, color4 = getVehicleColor ( playerVehicle ) 
            local r, g, b = getVehicleHeadLightColor ( playerVehicle ) 
            setAccountData ( playerAccount, "idd.ccolor1", colour1 ) 
            setAccountData ( playerAccount, "idd.ccolor2", colour2 ) 
            setAccountData ( playerAccount, "idd.ccolor3", colour3 ) 
            setAccountData ( playerAccount, "idd.ccolor4", colour4 ) 
            setAccountData ( playerAccount, "idd.cchcr", r) 
            setAccountData ( playerAccount, "idd.cchcg", g) 
            setAccountData ( playerAccount, "idd.cchcb", b) 
    end 
end 
addCommandHandler("saveColours", getRootElement(), setColours) 
  
function setCarColours() 
    local color1 = getAccountData ( playerAccount, "idd.ccolor1") 
    local color2 = getAccountData ( playerAccount, "idd.ccolor2") 
    local color3 = getAccountData ( playerAccount, "idd.ccolor3") 
    local color4 = getAccountData ( playerAccount, "idd.ccolor4") 
    local r = getAccountData ( playerAccount, "idd.cchcr" ) 
    local g = getAccountData ( playerAccount, "idd.cchcg" ) 
    local b = getAccountData ( playerAccount, "idd.cchcb" ) 
    setVehicleColor ( playerVehicle, color1, color2, color3, color4 ) 
    getVehicleHeadLightColor ( playerVehicle, r,g,b) 
end 
addEventHandler("",getRootElement(),setCarColours) 
  

This should work right? but what handler do i use for the colours, when a car is spawned, i am using the resource race.

Eat My Dust - DM/Deathmatch

350x20_00C3FF_FFFFFF_000000_000000.png

Posted
function saveColours ( playerSource ) 
    local playerAccount = getPlayerAccount ( playerSource ) 
    local playerVehicle = getPlayerOccupiedVehicle ( playerSource ) 
    if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
        local color1, color2, color3, color4 = getVehicleColor ( playerVehicle ) 
        local r, g, b = getVehicleHeadLightColor ( playerVehicle ) 
        setAccountData ( playerAccount, "idd.ccolor1", colour1 ) 
        setAccountData ( playerAccount, "idd.ccolor2", colour2 ) 
        setAccountData ( playerAccount, "idd.ccolor3", colour3 ) 
        setAccountData ( playerAccount, "idd.ccolor4", colour4 ) 
        setAccountData ( playerAccount, "idd.cchcr", r) 
        setAccountData ( playerAccount, "idd.cchcg", g) 
        setAccountData ( playerAccount, "idd.cchcb", b) 
    end 
end 
addCommandHandler("saveColours", saveColours) 
  
function setCarColours(_, playerAccount) 
    local playerVehicle = getPlayerOccupiedVehicle ( source ) 
    local color1 = getAccountData ( playerAccount, "idd.ccolor1") 
    local color2 = getAccountData ( playerAccount, "idd.ccolor2") 
    local color3 = getAccountData ( playerAccount, "idd.ccolor3") 
    local color4 = getAccountData ( playerAccount, "idd.ccolor4") 
    local r = getAccountData ( playerAccount, "idd.cchcr" ) 
    local g = getAccountData ( playerAccount, "idd.cchcg" ) 
    local b = getAccountData ( playerAccount, "idd.cchcb" ) 
    setVehicleColor ( playerVehicle, color1, color2, color3, color4 ) 
    getVehicleHeadLightColor ( playerVehicle, r,g,b) 
end 
addEventHandler("onPlayerLogin",getRootElement(),setCarColours) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

oh sorry, i get it. in my meta i need to pu addon="race" and in my script i need to do addEvent("onMapStarting") and in the event handler i put onMapStarting,right?

Eat My Dust - DM/Deathmatch

350x20_00C3FF_FFFFFF_000000_000000.png

Posted
Yeah, that's correct. If you want your addon to start with race then you have to change race meta.xml. In the settings section you will find addons that start with race.

If i understand you correctly, this is what i am suppoesed to do right? but i get this message in the console:

"WARNING: [gamemodes]\[race]\[addons]\gr_stats\server.lua:32: Bad arguement @ 'addEventHandler' [Expected at argument 2, got function]"

Here is my meta...

<meta> 
<info name="IDD Stats" addon="race" /> 
<script src="server.lua" type="server" /> 
</meta> 

Here is my code...

addEvent ( "onMapStarting" ) 
function saveColours ( playerSource ) 
    local playerAccount = getPlayerAccount ( playerSource ) 
    local playerVehicle = getPlayerOccupiedVehicle ( playerSource ) 
    if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
        local color1, color2, color3, color4 = getVehicleColor ( playerVehicle ) 
        local r, g, b = getVehicleHeadLightColor ( playerVehicle ) 
        setAccountData ( playerAccount, "idd.ccolor1", colour1 ) 
        setAccountData ( playerAccount, "idd.ccolor2", colour2 ) 
        setAccountData ( playerAccount, "idd.ccolor3", colour3 ) 
        setAccountData ( playerAccount, "idd.ccolor4", colour4 ) 
        setAccountData ( playerAccount, "idd.cchcr", r) 
        setAccountData ( playerAccount, "idd.cchcg", g) 
        setAccountData ( playerAccount, "idd.cchcb", b) 
        outputChatBox ( "Your Chosen Colours have Been Saved!", source) 
    end 
end 
addCommandHandler("saveColours", saveColours) 
  
function setCarColours(_, playerAccount) 
    local playerVehicle = getPlayerOccupiedVehicle ( source ) 
    local color1 = getAccountData ( playerAccount, "idd.ccolor1") 
    local color2 = getAccountData ( playerAccount, "idd.ccolor2") 
    local color3 = getAccountData ( playerAccount, "idd.ccolor3") 
    local color4 = getAccountData ( playerAccount, "idd.ccolor4") 
    local r = getAccountData ( playerAccount, "idd.cchcr" ) 
    local g = getAccountData ( playerAccount, "idd.cchcg" ) 
    local b = getAccountData ( playerAccount, "idd.cchcb" ) 
    setVehicleColor ( playerVehicle, color1, color2, color3, color4 ) 
    getVehicleHeadLightColor ( playerVehicle, r,g,b) 
end 
addEventHandler ( "onMapStarting" ,setCarColours ) 

Eat My Dust - DM/Deathmatch

350x20_00C3FF_FFFFFF_000000_000000.png

Posted
addEvent ( "onMapStarting" ) 
function saveColours ( playerSource ) 
    local playerAccount = getPlayerAccount ( playerSource ) 
    local playerVehicle = getPlayerOccupiedVehicle ( playerSource ) 
    if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
        local color1, color2, color3, color4 = getVehicleColor ( playerVehicle ) 
        local r, g, b = getVehicleHeadLightColor ( playerVehicle ) 
        setAccountData ( playerAccount, "idd.ccolor1", colour1 ) 
        setAccountData ( playerAccount, "idd.ccolor2", colour2 ) 
        setAccountData ( playerAccount, "idd.ccolor3", colour3 ) 
        setAccountData ( playerAccount, "idd.ccolor4", colour4 ) 
        setAccountData ( playerAccount, "idd.cchcr", r) 
        setAccountData ( playerAccount, "idd.cchcg", g) 
        setAccountData ( playerAccount, "idd.cchcb", b) 
        outputChatBox ( "Your Chosen Colours have Been Saved!", source) 
    end 
end 
addCommandHandler("saveColours", saveColours) 
  
function setCarColours(_, playerAccount) 
    local playerVehicle = getPlayerOccupiedVehicle ( source ) 
    local color1 = getAccountData ( playerAccount, "idd.ccolor1") 
    local color2 = getAccountData ( playerAccount, "idd.ccolor2") 
    local color3 = getAccountData ( playerAccount, "idd.ccolor3") 
    local color4 = getAccountData ( playerAccount, "idd.ccolor4") 
    local r = getAccountData ( playerAccount, "idd.cchcr" ) 
    local g = getAccountData ( playerAccount, "idd.cchcg" ) 
    local b = getAccountData ( playerAccount, "idd.cchcb" ) 
    setVehicleColor ( playerVehicle, color1, color2, color3, color4 ) 
    getVehicleHeadLightColor ( playerVehicle, r,g,b) 
end 
addEventHandler ( "onMapStarting", getRootElement(),setCarColours ) -- For EVERY Event in server you need to have root here. 

Diet with russian vodka, lose 3 days in one week !

Posted
addEvent ( "onMapStarting" ) 
function saveColours ( playerSource ) 
    local playerAccount = getPlayerAccount ( playerSource ) 
    local playerVehicle = getPlayerOccupiedVehicle ( playerSource ) 
    if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
        local color1, color2, color3, color4 = getVehicleColor ( playerVehicle ) 
        local r, g, b = getVehicleHeadLightColor ( playerVehicle ) 
        setAccountData ( playerAccount, "idd.ccolor1", colour1 ) 
        setAccountData ( playerAccount, "idd.ccolor2", colour2 ) 
        setAccountData ( playerAccount, "idd.ccolor3", colour3 ) 
        setAccountData ( playerAccount, "idd.ccolor4", colour4 ) 
        setAccountData ( playerAccount, "idd.cchcr", r) 
        setAccountData ( playerAccount, "idd.cchcg", g) 
        setAccountData ( playerAccount, "idd.cchcb", b) 
        outputChatBox ( "Your Chosen Colours have Been Saved!", source) 
    end 
end 
addCommandHandler("saveColours", saveColours) 
  
function setCarColours(_, playerAccount) 
    local playerVehicle = getPlayerOccupiedVehicle ( source ) 
    local color1 = getAccountData ( playerAccount, "idd.ccolor1") 
    local color2 = getAccountData ( playerAccount, "idd.ccolor2") 
    local color3 = getAccountData ( playerAccount, "idd.ccolor3") 
    local color4 = getAccountData ( playerAccount, "idd.ccolor4") 
    local r = getAccountData ( playerAccount, "idd.cchcr" ) 
    local g = getAccountData ( playerAccount, "idd.cchcg" ) 
    local b = getAccountData ( playerAccount, "idd.cchcb" ) 
    setVehicleColor ( playerVehicle, color1, color2, color3, color4 ) 
    getVehicleHeadLightColor ( playerVehicle, r,g,b) 
end 
addEventHandler ( "onMapStarting", getRootElement(),setCarColours ) -- For EVERY Event in server you need to have root here. 

Thank you blazy, that worked, but i need this last bit of info, i get a warning saying that getPedOccupidVehicle on line 2 is not a valid arg, why??

here is the code\

  
addEvent ( "onMapStarting" )     
theVehicle = getPedOccupiedVehicle ( source ) 
function setLightColours ( source, commandName, r, g, b ) 
    local playerAccount = getPlayerAccount ( source ) 
    if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
        setAccountData ( playerAccount, "idd.cchcr", r) 
        setAccountData ( playerAccount, "idd.cchcg", g) 
        setAccountData ( playerAccount, "idd.cchcb", b) 
        setVehicleHeadLightColor ( theVehicle, r,g,b) 
        setVehicleOverrideLights ( theVehicle, 2 ) 
        outputChatBox ( "Your Chosen Light Colours have Been Saved!", source) 
    end 
end 
addCommandHandler("setLightColours", setLightColours) 
  
function setCarColours () 
    local playerAccount = getPlayerAccount ( source ) 
    if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
        local color1, color2, color3, color4 = getVehicleColor ( theVehicle ) 
        setAccountData ( playerAccount, "idd.ccolor1", colour1 ) 
        setAccountData ( playerAccount, "idd.ccolor2", colour2 ) 
        setAccountData ( playerAccount, "idd.ccolor3", colour3 ) 
        setAccountData ( playerAccount, "idd.ccolor4", colour4 ) 
        local crdone = outputChatBox ( "Your Current Car Colours have Been Saved!", source) 
    end 
end 
addCommandHandler("setCarColours", setCarColours) 
  
function setAllColours(_, playerAccount) 
    outputChatBox ("Broken!",source) 
    local color1 = getAccountData ( playerAccount, "idd.ccolor1") 
    local color2 = getAccountData ( playerAccount, "idd.ccolor2") 
    local color3 = getAccountData ( playerAccount, "idd.ccolor3") 
    local color4 = getAccountData ( playerAccount, "idd.ccolor4") 
    local r = getAccountData ( playerAccount, "idd.cchcr" ) 
    local g = getAccountData ( playerAccount, "idd.cchcg" ) 
    local b = getAccountData ( playerAccount, "idd.cchcb" ) 
    local cr = tonumber ( r ) 
    local cg = tonumber ( g ) 
    local cb = tonumber ( b ) 
    setVehicleColor ( theVehicle, color1, color2, color3, color4 ) 
    setVehicleHeadLightColor ( theVehicle, cr,cg,cb) 
end 
addCommandHandler ( "restoreColours", setAllColours) 
addEventHandler ( "onMapStarting", getRootElement(),setAllColours ) 
  

Eat My Dust - DM/Deathmatch

350x20_00C3FF_FFFFFF_000000_000000.png

Posted
addEvent ( "onMapStarting" ) 
function setLightColours ( source, commandName, r, g, b ) 
theVehicle = getPedOccupiedVehicle ( source ) 
if theVehicle then 
local playerAccount = getPlayerAccount ( source ) 
    if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
        setAccountData ( playerAccount, "idd.cchcr", r) 
        setAccountData ( playerAccount, "idd.cchcg", g) 
        setAccountData ( playerAccount, "idd.cchcb", b) 
        setVehicleHeadLightColor ( theVehicle, r,g,b) 
        setVehicleOverrideLights ( theVehicle, 2 ) 
        outputChatBox ( "Your Chosen Light Colours have Been Saved!", source) 
    else 
        outputChatBox ( "You are not logged in!", source) 
    end 
else 
      outputChatBox ( "You do not have a Vehicle!", source) 
end 
end 
addCommandHandler("setLightColours", setLightColours) 
  
function setCarColours () 
theVehicle = getPedOccupiedVehicle ( source ) 
if theVehicle then 
local playerAccount = getPlayerAccount ( source ) 
    if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
        local color1, color2, color3, color4 = getVehicleColor ( theVehicle ) 
        setAccountData ( playerAccount, "idd.ccolor1", colour1 ) 
        setAccountData ( playerAccount, "idd.ccolor2", colour2 ) 
        setAccountData ( playerAccount, "idd.ccolor3", colour3 ) 
        setAccountData ( playerAccount, "idd.ccolor4", colour4 ) 
        local crdone = outputChatBox ( "Your Current Car Colours have Been Saved!", source) 
    else 
        outputChatBox ( "You are not logged in!", source) 
    end 
else 
      outputChatBox ( "You do not have a Vehicle!", source) 
end 
end 
addCommandHandler("setCarColours", setCarColours) 
  
function setAllColours(_, playerAccount) 
theVehicle = getPedOccupiedVehicle ( source ) 
    if theVehicle then 
    local playerAccount = getPlayerAccount ( source ) 
        if ( playerAccount ) and not isGuestAccount ( playerAccount ) then 
        outputChatBox ("Broken!",source) 
        local color1 = getAccountData ( playerAccount, "idd.ccolor1") 
        local color2 = getAccountData ( playerAccount, "idd.ccolor2") 
        local color3 = getAccountData ( playerAccount, "idd.ccolor3") 
        local color4 = getAccountData ( playerAccount, "idd.ccolor4") 
        local r = getAccountData ( playerAccount, "idd.cchcr" ) 
        local g = getAccountData ( playerAccount, "idd.cchcg" ) 
        local b = getAccountData ( playerAccount, "idd.cchcb" ) 
        local cr = tonumber ( r ) 
        local cg = tonumber ( g ) 
        local cb = tonumber ( b ) 
        setVehicleColor ( theVehicle, color1, color2, color3, color4 ) 
        setVehicleHeadLightColor ( theVehicle, cr,cg,cb) 
        else 
        outputChatBox ( "You are not logged in!", source) 
        end 
    else 
        outputChatBox ( "You do not have a Vehicle!", source) 
    end 
end 
addCommandHandler ( "restoreColours", setAllColours) 
addEventHandler ( "onMapStarting", getRootElement(),setAllColours ) 

Destruction Derby

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