Jump to content

Making stats/info system but a small problem


mjau

Recommended Posts

Hi i have decided to make a stats system and as far i have come it works but now there is a problem

The probmlem is that ive added some things to get like serial ip health ad others but it shows false in the gui

Edited by Guest
Link to comment

Another problem The healh and armor shows 0 wahtever i do

function bindTheKeys() 
bindKey ( "F2", "down", openGui )  
bindKey ( "F2", "up", closeGui )  
bindKey ( "F2", "down", stats )  
end 
addCommandHandler ( "bindme", bindTheKeys ) 
  
  
function stats() 
local ping = getElementData (getLocalPlayer(), "ping") 
local ip = getElementData (getLocalPlayer(), "ip") 
local serial = getElementData (getLocalPlayer(), "serial") 
local health = getElementData (getLocalPlayer(), "health") 
local armour = getElementData (getLocalPlayer(), "armour") 
  
  
guiSetText(GUIEditor_Label[4], "Serial: " ..tostring(serial).. "  " ,true, GUIEditor_Window[1]) 
guiSetText(GUIEditor_Label[3], "Ping: " ..tostring(ping).. "  " ,true, GUIEditor_Window[1]) 
guiSetText(GUIEditor_Label[5], "IP: " ..tostring(ip).. "  " ,true, GUIEditor_Window[1]) 
guiSetText(GUIEditor_Label[1], "Health: " ..tostring(health).. "  " ,true, GUIEditor_Window[1]) 
guiSetText(GUIEditor_Label[2], "Armour: " ..tostring(armour).. "  " ,true, GUIEditor_Window[1]) 
end 
  
  
function openGui() 
infoGui() 
end 
  
function closeGui() 
guiSetVisible ( GUIEditor_Window[1], false ) 
end 

Server side in 1th post

Link to comment

Try this server-side:

  
    addEventHandler("onPlayerSpawn",root, 
    function() 
    setElementData(source,"ping",getPlayerPing(source)) 
    setElementData(source,"health",getPlayerMoney(source)) 
    setElementData(source,"ip",getPlayerIP(source)) 
    setElementData(source,"serial",getPlayerSerial(source)) 
    setElementData(source,"armour",getPedArmor(source)) 
    end ) 
  

Link to comment

because your element data is not synced. you set it only once, on player join (i assume he has 0 armor at that time) and never update it.

also there's no real need for setting armor as element data, you can use getPedArmor() both in client and server to get the current armor value.

PS: just noticed, why getPlayerMoney() goes into health variable? :S

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