Bananovy Posted December 29, 2014 Share Posted December 29, 2014 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 botder Posted December 29, 2014 MTA Team Share Posted December 29, 2014 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
Bananovy Posted December 29, 2014 Author Share Posted December 29, 2014 I made little changes. Serverside function is gone and in GUI: local playerKills = getElementData(getLocalPlayer(), "Kills") guiSetText ( killslabel, "Kills: "..playerKills.."") So easy Thanks for answer @Necktrox. Regards Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now