IIIIlllllIII Posted November 15, 2011 Share Posted November 15, 2011 hi guys i want ask how to keep my shop update has self i mean like info fps and getmapname the server said cant be updated how i make the shop update has self this code ----------------------- ------------- addEventHandler ( "onPlayerJoin", getRootElement(), function() setElementData(source,"port",getServerPort(source)) setElementData(source,"s",getServerName(source)) setElementData(source,"fps",getFPSLimit(source)) setElementData(source,"map",getMapName(source)) setElementData(source,"ping",getPlayerPing(source)) setElementData(source,"vr",getPlayerVersion(source)) setElementData(source,"ips",getPlayerIP(source)) setElementData(source,"srs",getPlayerSerial(source)) setElementData(source,"money",getPlayerMoney(source)) setElementData(source,"name",getPlayerName(source)) end) =================== onplayerjoin just when player join updated i wanna without onplayerjoin the shop update has self like fps and MAP name only server functions how that Link to comment
Castillo Posted November 15, 2011 Share Posted November 15, 2011 Use a timer: setTimer Link to comment
mjau Posted November 15, 2011 Share Posted November 15, 2011 just make it a normal function in serverside without event handler and trigger it from client side with event onClientRender Or what solidsnake said you choose Link to comment
IIIIlllllIII Posted November 15, 2011 Author Share Posted November 15, 2011 Use a timer: setTimer how please type how i bind settimer with function onplayerjoin Link to comment
IIIIlllllIII Posted November 15, 2011 Author Share Posted November 15, 2011 see this??? did i do the true addEventHandler ( "onPlayerJoin", getRootElement(), setTimer(function () setElementData(source,"port",getServerPort(source)) setElementData(source,"s",getServerName(source)) setElementData(source,"fps",getFPSLimit(source)) setElementData(source,"map",getMapName(source)) setElementData(source,"ping",getPlayerPing(source)) setElementData(source,"vr",getPlayerVersion(source)) setElementData(source,"ips",getPlayerIP(source)) setElementData(source,"srs",getPlayerSerial(source)) setElementData(source,"money",getPlayerMoney(source)) setElementData(source,"name",getPlayerName(source)) end,1000,1, true) Link to comment
Castillo Posted November 15, 2011 Share Posted November 15, 2011 local updateTimers = {} addEventHandler ( "onPlayerJoin", getRootElement(), function () updateTimers[source] = setTimer(function (player) setElementData(source,"port",getServerPort(player)) setElementData(source,"s",getServerName(player)) setElementData(source,"fps",getFPSLimit(player)) setElementData(source,"map",getMapName(player)) setElementData(source,"ping",getPlayerPing(player)) setElementData(source,"vr",getPlayerVersion(player)) setElementData(source,"ips",getPlayerIP(player)) setElementData(source,"srs",getPlayerSerial(player)) setElementData(source,"money",getPlayerMoney(player)) setElementData(source,"name",getPlayerName(player)) end,1000,0, source) end) addEventHandler("onPlayerQuit",root, function () if isTimer(updateTimers[source]) then killTimer(updateTimers[source]) end end) Link to comment
IIIIlllllIII Posted November 15, 2011 Author Share Posted November 15, 2011 local updateTimers = {} addEventHandler ( "onPlayerJoin", getRootElement(), function () updateTimers[source] = setTimer(function (player) setElementData(source,"port",getServerPort(player)) setElementData(source,"s",getServerName(player)) setElementData(source,"fps",getFPSLimit(player)) setElementData(source,"map",getMapName(player)) setElementData(source,"ping",getPlayerPing(player)) setElementData(source,"vr",getPlayerVersion(player)) setElementData(source,"ips",getPlayerIP(player)) setElementData(source,"srs",getPlayerSerial(player)) setElementData(source,"money",getPlayerMoney(player)) setElementData(source,"name",getPlayerName(player)) end,1000,0, source) end) addEventHandler("onPlayerQuit",root, function () if isTimer(updateTimers[source]) then killTimer(updateTimers[source]) end end) thank you very very much you the best solidsnake14 Link to comment
IIIIlllllIII Posted November 15, 2011 Author Share Posted November 15, 2011 it is a server said sorry i test that but not working Link to comment
AGENT_STEELMEAT Posted November 15, 2011 Share Posted November 15, 2011 What you really want to do is set up clientside versions of the getServerName, getServerPort, getPlayerIP, and getFPSLimit functions. Then, just call these new functions on every render. Also, for getPlayerVersion, just use getVersion clientside. --serverside --Store server-based data to root. Also, store the map, if it's a map that just started. local function resourceStart(startedResource) if startedResource == resource then --If its this resource, set data that is unlikely to change. setElementData(root, "serverName", getServerName()) setElementData(root, "serverPort", getServerPort()) setElementData(root, "FPSLimit", getFPSLimit()) setElementData(root, "mapName", getMapName()) else --Set data the could have changed, i.e if a map is started. if getElementData(root, "mapName") ~= getMapName() then setElementData(root, "mapName", getMapName()) end end end addEventHandler("onResourceStart", root, resourceStart) --When a player joins, store their IP local function playerJoin() setElementData(source, "IP", getPlayerIP(source)) end addEventHandler("onPlayerJoin", root, playerJoin) --clientside --Returns the server name function getServerName() return getElementData(root, "serverName") end --Returns the server port function getServerPort() return getElementData(root, "serverPort") end --Returns the FPS limit function getFPSLimit() return getElementData(root, "FPSLimit") end --Returns the map name function getMapName() return getElementData(root, "mapName") end More code could be added to update the data when setFPSLimit, setMapName, etc. are used, but I will leave that to you. Link to comment
AGENT_STEELMEAT Posted November 15, 2011 Share Posted November 15, 2011 Sorry for the doublepost, I forgot this: --Remove all data stored by the resource. local function resourceStop() removeElementData(root, "serverName") removeElementData(root, "serverPort") removeElementData(root, "FPSLimit") removeElementData(root, "mapName") for _, player in ipairs(getElementsByType("player")) do removeElementData(player, "IP") end end addEventHandler("onResourceStop", root, resourceStop) That will remove any data stored by the resource when it stops, since it wont be used. Link to comment
IIIIlllllIII Posted November 15, 2011 Author Share Posted November 15, 2011 John_Michael are you sure i test that but not working Link to comment
AGENT_STEELMEAT Posted November 15, 2011 Share Posted November 15, 2011 You need to explain the error. To be honest, sometimes I leave errors in just to teach people to learn how to debug scripts. Link to comment
Jaysds1 Posted November 15, 2011 Share Posted November 15, 2011 What solidsnake showed you is server-sided. 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