mjau Posted October 5, 2011 Share Posted October 5, 2011 (edited) 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 October 6, 2011 by Guest Link to comment
Aibo Posted October 5, 2011 Share Posted October 5, 2011 if you're setting from server and getting the data in client only once on script start there's a chance it is not properly synced yet. try moving your getElementData part inside stats() function. Link to comment
mjau Posted October 5, 2011 Author Share Posted October 5, 2011 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
mjau Posted October 5, 2011 Author Share Posted October 5, 2011 but armor still dont work Edit Doublepost srry Link to comment
Cadu12 Posted October 5, 2011 Share Posted October 5, 2011 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
Aibo Posted October 5, 2011 Share Posted October 5, 2011 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? Link to comment
mjau Posted October 5, 2011 Author Share Posted October 5, 2011 But if i use settimer and infinite repeats it will work then ? Link to comment
Aibo Posted October 5, 2011 Share Posted October 5, 2011 why do you want to sync things in element data that are already synced by MTA? too much spare bandwidth? Link to comment
mjau Posted October 5, 2011 Author Share Posted October 5, 2011 nah just a bit lazy guy anyway i will try to do the health and armor clientsided 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