Jump to content

[HELP] Why not working setTimer function?


Tokio

Recommended Posts

i have this code:

setTimer(function()
	local arfolyam = math.random(200,5130)
	outputChatBox("Jelenlegi árfolyam: "..arfolyam)
end, 500, 0)

        GUIEditor.window[1] = guiCreateWindow(0.35, 0.31, 0.31, 0.28, "Aranykereskedés", true)
        guiWindowSetSizable(GUIEditor.window[1], false)
        GUIEditor.label[1] = guiCreateLabel(0.02, 0.59, 0.95, 0.14, "Az arany jelenlegi árfolyama: "..arfolyam, true, GUIEditor.window[1])

but i get this error in debugscript 3:

attempt to concatenate global 'arfolyam' ( a nil value) 

 

what wrong? how to fix this?

Link to comment
18 hours ago, 50cent said:
  1. local arfolyam
  2. setTimer(function()
  3. arfolyam = math.random(200,5130)
  4. outputChatBox("Jelenlegi árfolyam: "..arfolyam)
  5. end, 500, 0)
  6.  
  7. GUIEditor.window[1] = guiCreateWindow(0.35, 0.31, 0.31, 0.28, "Aranykereskedés", true)
  8. guiWindowSetSizable(GUIEditor.window[1], false)
  9. GUIEditor.label[1] = guiCreateLabel(0.02, 0.59, 0.95, 0.14, "Az arany jelenlegi árfolyama: "..arfolyam, true, GUIEditor.window[1])

Try now

Link to comment
local arfolyam = math.random(200,5130)
setTimer(function()
arfolyam = math.random(200,5130)
outputChatBox("Jelenlegi árfolyam: "..arfolyam)
end, 500, 0)
 
GUIEditor.window[1] = guiCreateWindow(0.35, 0.31, 0.31, 0.28, "Aranykereskedés", true)
guiWindowSetSizable(GUIEditor.window[1], false)
GUIEditor.label[1] = guiCreateLabel(0.02, 0.59, 0.95, 0.14, "Az arany jelenlegi árfolyama: "..arfolyam, true, GUIEditor.window[1])

P.S.: I'm Hungarian too! ;)

Link to comment
58 minutes ago, MakroBox said:

local arfolyam = math.random(200,5130)
setTimer(function()
arfolyam = math.random(200,5130)
outputChatBox("Jelenlegi árfolyam: "..arfolyam)
end, 500, 0)
 
GUIEditor.window[1] = guiCreateWindow(0.35, 0.31, 0.31, 0.28, "Aranykereskedés", true)
guiWindowSetSizable(GUIEditor.window[1], false)
GUIEditor.label[1] = guiCreateLabel(0.02, 0.59, 0.95, 0.14, "Az arany jelenlegi árfolyama: "..arfolyam, true, GUIEditor.window[1])

P.S.: I'm Hungarian too! ;)

With this code, the label does not update the 'arfolyam' :S 

Link to comment
local arfolyam = math.random(200,5130)
setTimer(function()
arfolyam = math.random(200,5130)
	outputChatBox("Jelenlegi árfolyam: "..arfolyam)
	guiSetText(GUIEditor.label[1], "Az arany jelenlegi árfolyama: " .. arfolyam)
end, 500, 0)
 
GUIEditor.window[1] = guiCreateWindow(0.35, 0.31, 0.31, 0.28, "Aranykereskedés", true)
guiWindowSetSizable(GUIEditor.window[1], false)
GUIEditor.label[1] = guiCreateLabel(0.02, 0.59, 0.95, 0.14, "Az arany jelenlegi árfolyama: "..arfolyam, true, GUIEditor.window[1])

 

Edited by NeXuS™
  • Thanks 1
Link to comment
26 minutes ago, NeXuS™ said:

local arfolyam = math.random(200,5130)
setTimer(function()
arfolyam = math.random(200,5130)
	outputChatBox("Jelenlegi árfolyam: "..arfolyam)
	guiSetText(GUIEditor.label[1], "Az arany jelenlegi árfolyama: " .. arfolyam)
end, 500, 0)
 
GUIEditor.window[1] = guiCreateWindow(0.35, 0.31, 0.31, 0.28, "Aranykereskedés", true)
guiWindowSetSizable(GUIEditor.window[1], false)
GUIEditor.label[1] = guiCreateLabel(0.02, 0.59, 0.95, 0.14, "Az arany jelenlegi árfolyama: "..arfolyam, true, GUIEditor.window[1])

 

thanks:DD 

and how can i add when a player click on the button, then take the 'arfolyam' amount from player, in server side?

Link to comment
7 minutes ago, NeXuS™ said:

Using the onClientGUIClick event, some custom events, and takeMoney function.

this why not working?

client:

function arr() 
	triggerServerEvent ("ar", root, getLocalPlayer()) 
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[1], arr, false ) 

server:

addEvent( "ar", true ) 
addEventHandler( "ar", root, 
	function (thePlayer) 
	local arfolyam
	if getPlayerMoney(thePlayer) >= arfolyam then
	takePlayerMoney ( thePlayer, arfolyam )
else
	outputChatBox("Nincs elég pénzed a vásárláshoz.", thePlayer, 255, 0, 0, false)
	end
end
) 

 

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