Leveling prizes wont work =[

I’m working on a prize system for how long people play on the server and whenever they play for a certain amount of time they are rewarded. The money’s ent name is called “tehmoneylol” I need it to give the player the money I set for every 5 hours they play but when you play this long it doesn’t give you the money =. Also I’m talking about all the time they have spent altogether not just for playing that long straight.

function GivePrize()
money = GetNWInt("tehmoneylol")
if hours == 5 then
money = money + 5000

if hours == 10 then
money = money + 10000


if hours == 15 then
money = money + 15000

if hours == 20 then
money = money + 20000

if hours == 25 then
money = money + 25000

if hours == 30 then
money = money + 30000

if hours == 35 then
money = money + 35000

if hours == 40 then
money = money +40000

if hours == 45 then
money = money +45000

if hours == 50 then
money = money +50000

Your setting money to whatever the initial value of tehmoneylol is. You need to actually set their money now. Here let me show you what you should have done (Besides using lua tags for your code.):
[lua]function GivePrize()

--What I'm doing here, is testing that hours is a multiple of 5.
local _, dec = math.modf( hours/5 )

--If it is a multiple of 5, then we set tehmoneylol to the players hours times 1000, which will be 5000 @ 5 hours, 10000 @ 10 hours, and so on.
if( dec == 0 )then

	SetNWInt( "tehmoneylol", hours*1000 )

--Hope this helps :D ~Roiyaru.


Much better :slight_smile:


Oh by the way, I’m assuming that you were giving the money elsewhere, and just setting the integer there. Also, I assumed that hours was defined outside of the function.

Erm, the SetNWInt must be done on an entity object. It doesn’t exist in space. Should be like this:


I know, but he didn’t have one before, so I assumed he was doing something else with it…

What I was wanting was every 5 hours a player plays they get $5000 but that means 5 hours play time not 5 hours straight. So every 5 hours it adds on 5000 so 5 hours is $5000 10 hours is $10000 15 hours is $15000

Uhm… That’s not what that function does at all… :V Mine kind of does that… put the player variable in front of the SetNWInt and it will do that. I’m not coding an hour saving thing for you…

Just wanted to say, use Usermessages rather than a network variable It’s a waste of resources just to sync everyone with a number they never see(ie sending them a single players money).

So, every time you update their amount of money serverside, just send a usermessage to that player with the update, rather than using a network variable. :stuck_out_tongue: