Jump to content

I need help here...


GTX

Recommended Posts

Hello, I have this:

function click () 
emptytext = "" 
    if source == grid_players then 
    local selectedPlayer = guiGridListGetItemText ( grid_players, guiGridListGetSelectedItem ( grid_players ), 1 ) 
    if not (selectedPlayer == emptytext) then 
    outputChatBox ( selectedPlayer )     -- output it to chat box 
    guiSetText(lbl_f_showstats, "Showing statistics of the player " ..tostring(selectedPlayer)) 
    triggerServerEvent("gStats", root, selectedPlayer) 
        end 
    end 
end 

And this:

function get(argument) 
local acc = getPlayerAccount(argument) 
if not isGuestAccount ( acc ) then 
  
local wins = getPlayerAccount(acc, "wins") or "NO" 
local deaths = getPlayerAccount(acc, "deaths") or " NO" 
local cash = getPlayerAccount(acc, "cash") or " NO$" 
local points = getPlayerAccount(acc, "points") or " NO" 
local ttset = getPlayerAccount(acc, "ttset") or " NO" 
  
  
--triggerServerEvent("rStats", root, wins, deaths, cash, points, ttset) 
  
outputChatBox("TRIGGERED: " .. wins .. deaths .. cash .. points .. ttset) 
  
else 
  
outputChatBox("GUEST") 
  
    end 
end 
addEvent("gStats", true) 
addEventHandler("gStats", root, get) 

Returns:

[14:55:43] WARNING: [gtx]\upanel\stats_s.lua:5: Bad argument @ 'getPlayerAccount' [Expected element at argument 1]

Thanks in advance!

Link to comment

Try

Client

function click ( ) 
    if source == grid_players then 
        local selectedPlayer = guiGridListGetItemText ( grid_players, guiGridListGetSelectedItem ( grid_players ), 1 ) 
        if selectedPlayer ~= '' then 
            outputChatBox ( tostring( selectedPlayer ) )     -- output it to chat box 
            guiSetText( lbl_f_showstats, "Showing statistics of the player " ..tostring( selectedPlayer ) ) 
             
            local from = getPlayerFromName( selectedPlayer ) 
            if isElement( from ) then 
                triggerServerEvent( "gStats", from ) 
            end 
        end 
    end 
end 

Server

addEvent( "gStats", true ) 
  
function Get( ) 
    local acc = getPlayerAccount( source ) 
    if acc then 
        if not isGuestAccount ( acc ) then 
            local wins = getAccountData( acc, "wins" ) or "NO" 
            local deaths = getAccountData( acc, "deaths" ) or " NO" 
            local cash = getAccountData( acc, "cash" ) or " NO$" 
            local points = getAccountData( acc, "points" ) or " NO" 
            local ttset = getAccountData( acc, "ttset" ) or " NO" 
            --triggerServerEvent("rStats", root, wins, deaths, cash, points, ttset) 
            outputChatBox( "TRIGGERED: " .. wins .. deaths .. cash .. points .. ttset ) 
        else 
            outputChatBox( "GUEST" ) 
        end 
    else 
        outputChatBox( "not get account" ) 
    end  
end 
  
addEventHandler( "gStats", root, Get ) 

Updated again.

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