Jump to content

panel not loading stats


kikos500

Recommended Posts

16HKIDK.png

Client

addEventHandler("onClientResourceStart", resourceRoot, 
function ( )  
     triggerServerEvent ("onGetPlayerRaceStats", resourceRoot) 
end ) 
  
addEvent("onGotRaceStats", true ) 
addEventHandler("onGotRaceStats", root, 
function  (wins, dms ) 
guiSetText( GUIEditor.label[1], "Maps Played: "..tostring(dms)) 
guiSetText( GUIEditor.label[2], "Maps Won: "..tostring(wins)) 
end ) 

----Server

addEvent("onGetPlayerRaceStats", true ) 
addEventHandler("onGetPlayerRaceStats", root, 
function ( ) 
    for _ ,v in pairs ( getElementsByType("player") ) do  
         local wins = getElementData(source,"wins") 
         local dms = getElementData(source,"played") 
  
          triggerClientEvent (v, "onGotRaceStats", v, wins, dms) 
     end  
end ) 
  

idk what should i do but it works fine with /st as you can see in the picture :shock:

Link to comment

Server

addEvent("onGetPlayerRaceStats", true) 
addEventHandler("onGetPlayerRaceStats", root, 
function() 
    local wins = getElementData(client, "wins") 
    local dms = getElementData(client, "played") 
    triggerClientEvent(client, "onGotRaceStats", client, wins, dms) 
end) 

And be sure to set the data before the resource start.

Link to comment
Server
addEvent("onGetPlayerRaceStats", true) 
addEventHandler("onGetPlayerRaceStats", root, 
function() 
    local wins = getElementData(client, "wins") 
    local dms = getElementData(client, "played") 
    triggerClientEvent(client, "onGotRaceStats", client, wins, dms) 
end) 

And be sure to set the data before the resource start.

well it worked and it loaded the dms and wins and cash and ratio but the problem is that it doesn't update meaning now i have 13 dms and 5 wins i won next round > so /st 14dms and 6 wins but the panel still 13 dms and 5 wins any solutions :fadein:

Link to comment

because you are checking the player stats only onClientResourceStart just try to add a commandHandler.

Example

function functionName() 
    triggerServerEvent ("onGetPlayerRaceStats", localPlayer) 
end  
addCommandHandler("stats",functionName 

Try now and it will update the player stats everytime you use the stats command.

Link to comment
because you are checking the player stats only onClientResourceStart just try to add a commandHandler.

Example

function functionName() 
    triggerServerEvent ("onGetPlayerRaceStats", localPlayer) 
end  
addCommandHandler("stats",functionName 

Try now and it will update the player stats everytime you use the stats command.

well this example will need you to write a command everytime can i use a timer idk if its possible since i haven't used a one before

Link to comment
I just wonder why you need the trigger in the first place?

You can use getElementData client side as long as the sync argument of the data wasn't set to false.

well i tried to do that but it didn't work so i decided to use triggering any idea how to do that ?

never mind it worked

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