Jump to content

Showing kills in clientside


Bananovy

Recommended Posts

Hello there,

I made GUI for userpanel and I wanted to make a function where players can see their stats when they open it. As first I'm trying to make kills, but there's an error. This is how it looks now:

Clientside:

function callServerFunction(funcname, ...) 
    local arg = { ... } 
    if (arg[1]) then 
        for key, value in next, arg do 
            if (type(value) == "number") then arg[key] = tostring(value) end 
        end 
    end 
    triggerServerEvent("kills123", resourceRoot , funcname, unpack(arg)) 
end  
  
guiSetText ( killslabel, "Kills: "..callServerFunction("kills").."") 

Serverside:

function kills(v) 
for i, v in pairs ( getElementsByType ( "player" ) ) do  
local theAcc = getPlayerAccount(v) 
    if theAcc and not isGuestAccount(theAcc) then 
    return tostring(getAccountData ( theAcc, "Info.Kills" )) 
    else 
    return "0" 
end 
end 
end 
addEvent("kills123", true) 
addEventHandler("kills123", resourceRoot, kills) 

And error: Attempt to concatenate a nil value (line with guiSetText)

Link to comment
  • MTA Team

You should know that networking doesn't work like that, otherwise it would freeze your client until the server sends the result (= extremely bad).

And you might use setElementData and getElementData for your kill counter.

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