Tokio Posted August 5, 2017 Share Posted August 5, 2017 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
Tokio Posted August 6, 2017 Author Share Posted August 6, 2017 9 hours ago, Zorgman said: Make arfolyam global How? Because i want change the 'arfolyam' every 500 ms Link to comment
Tokio Posted August 6, 2017 Author Share Posted August 6, 2017 3 minutes ago, Zorgman said: Delete 'local' i deleted, but same problem i got error Link to comment
Zorgman Posted August 6, 2017 Share Posted August 6, 2017 18 hours ago, 50cent said: local arfolyam 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]) Try now Link to comment
Tokio Posted August 6, 2017 Author Share Posted August 6, 2017 4 minutes ago, Zorgman said: Try now attempt to concatenate local arfolyam (a nil value) Link to comment
szekelymilan Posted August 7, 2017 Share Posted August 7, 2017 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
Zorgman Posted August 7, 2017 Share Posted August 7, 2017 Yeah. I think my code would have worked too after spitting errors for the first half second Link to comment
Tokio Posted August 7, 2017 Author Share Posted August 7, 2017 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' Link to comment
NeXuS™ Posted August 7, 2017 Share Posted August 7, 2017 (edited) 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 August 7, 2017 by NeXuS™ 1 Link to comment
Tokio Posted August 7, 2017 Author Share Posted August 7, 2017 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
NeXuS™ Posted August 7, 2017 Share Posted August 7, 2017 (edited) Using the onClientGUIClick event, some custom events, and takePlayerMoney function. Edited August 7, 2017 by NeXuS™ Link to comment
Tokio Posted August 7, 2017 Author Share Posted August 7, 2017 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
Tokio Posted August 7, 2017 Author Share Posted August 7, 2017 Just now, NeXuS™ said: Any errors? server:5: attempt to compare nil with number Link to comment
NeXuS™ Posted August 7, 2017 Share Posted August 7, 2017 "arfolyam" doesnt exist on serverside, you have to send it to the server-side through the triggerServerEvent. 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