timer.Create() repeat set to 0 and no repeat.

Hello, I have some code here I am making (My first script in Lua) and I created a timer.Create() and i have set the repeat to 0 (infinite)
and it does work but ONLY when there is no money taken. I am not sure why but once it takes money from someones wallet in DarkRP it stops running completely.

NOTE: Do not mind the 10 it is just to test it :stuck_out_tongue: it is something to change once i get this working.

CODE: http://pastebin.com/LyyVtGS5

Thanks for any help.

don’t sign posts
show error in console

Ok sorry for signing xD, also there are no erros. Rcon or Client.

[editline]14th March 2015[/editline]

Wait just got one!

00:07:43 Lua Error: [ERROR] lua/autorun/server/sv_cfgeconomy.lua:49: attempt to perform arithmetic on global ‘eco’ (a nil value) 1. unknown -

i have to disagree about the no errors part - unless you aren’t showing us your full code.

either define eco (is eco supposed to be a global? local? variable in the file? possibly a number?)
or remove the eco statements

Sorry Lines are off, for got a couple lines of comments at the top, the line is eco = eco+tax

[editline]14th March 2015[/editline]

eco is a number, this is to keep track of the removed taxes, and it is global.

[editline]14th March 2015[/editline]

How would i define eco?

Sorry im a bit new to this, my friend whom is teaching me is offline for a few days. :stuck_out_tongue:

ok, make a statement at the top of the file:

eco = eco or 0;

this will either initialize the variable or keep the existing global variable’s value

so this will not set it to 0 if eco has a value?

yes, it will keep the existing value if it already exists (if the file has already been loaded)

:smiley: WORKS!!!,
One last thing before I mark this as Solved.
This is in my autorun/server folder and it does not “autorun” is there a way i make it do so in the code? or is this just because it was not working before?

you will have to restart the server when you initially put the file in autorun for it to run - if you are on a linux or mac server then you will not have it re-run when you change it.

OH! ok, this is a Windows Server, so once the server restarts this will run as it should?


Alright! Thanks for the help MeepDarknessM

Be sure to mark this thread as solved in the top left corner of this page.

Already on it. :slight_smile: