Jump to content

how to keep resource update has self


IIIIlllllIII

Recommended Posts

Posted

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 :?:

Posted

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

Posted

see this??? did i do the true 8)

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)

Posted
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) 

Posted
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 :D

you the best solidsnake14

Posted

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.

Posted

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.

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