Jump to content

attemp to call global 'getResources'


Recommended Posts

topicname + (a nil value)

function newTimer() 
local allResources = getResources() -- this line 
for index, text in ipairs(allResources) do 
if getResourceState(text) == "running" then 
setTimer(function() 
restartResource(text) 
end,10000,100000) 
end 
end 
end 
newTimer() 

i wanna set a timer for a loooong time because idk how to set it to unlimited time to restart a resource which would update dxDrawText but it gives me error

attemp to call global 'getResources' (a nil value)

please help

Link to comment

in client side script i have a line which draws dx text of player's nick on bottom of their screen in middle,but i dont know how to update that dxdrawtext text when a player changes his nick so i've tried to use restartResource so that it would update in other way but that thing restarts EVERY resource instead of resource named "text"

Link to comment
You don't need to restart anything..

Just when you draw the text the first argument in dxDrawText is the string to be drawn, use getPlayerName(localPlayer) there.. just change localPlayer if it's different player.

i am already using that but it doesn't update when a player changes nick

Link to comment

i got this but its not updating

local screenWidth, screenHeight = guiGetScreenSize ( ) 
local playerName = getPlayerName(localPlayer) 
function createText ( ) 
dxDrawText ( playerName, 970, screenHeight - 27, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 2, "arial" ) 
end 
  
function HandleTheRendering ( ) 
    addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) 

maybe something is wrong in my code evenn though it makes the text

Link to comment

Of course it's not working if you define the nick once...

local screenWidth, screenHeight = guiGetScreenSize ( ) 
function createText ( ) 
dxDrawText ( getPlayerName(localPlayer), 970, screenHeight - 27, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 2, "arial" ) 
end 
  
function HandleTheRendering ( ) 
    addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) 

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