John Smith Posted June 15, 2014 Share Posted June 15, 2014 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
MIKI785 Posted June 15, 2014 Share Posted June 15, 2014 So i guess you're doing this client-sided... getResources is server-only function. You'll have to use triggerClientEvent to send the list of resources to the client. Link to comment
toxicsmoke11 Posted June 15, 2014 Share Posted June 15, 2014 (edited) sry for my embarassing mistake,i've made this serveside in another file,and this thing restarts every single resource and i dont know why. its the same code like in first post on this topic Edited June 15, 2014 by Guest Link to comment
MIKI785 Posted June 15, 2014 Share Posted June 15, 2014 I really don't understand what you're trying to do. Why would you restart all running resources? Link to comment
toxicsmoke11 Posted June 15, 2014 Share Posted June 15, 2014 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
MIKI785 Posted June 15, 2014 Share Posted June 15, 2014 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. Link to comment
toxicsmoke11 Posted June 15, 2014 Share Posted June 15, 2014 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
MIKI785 Posted June 15, 2014 Share Posted June 15, 2014 That's simply not possible. getPlayerName will always return current nick, it's impossible. Link to comment
toxicsmoke11 Posted June 15, 2014 Share Posted June 15, 2014 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
MIKI785 Posted June 15, 2014 Share Posted June 15, 2014 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
arezu Posted June 16, 2014 Share Posted June 16, 2014 You can also use https://wiki.multitheftauto.com/wiki/OnClientPlayerChangeNick if you intend to use gui* functions later. 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