Author Topic: Help with a reward system  (Read 1707 times)

0 Members and 2 Guests are viewing this topic.

Offline Digital Spit

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 1
Help with a reward system
« on: June 13, 2014, 08:54:18 PM »
I was messing around with ways to reward players for staying in game and helping us reach our goal of reaching our player cap.

How can I get this to run automatically? I originally had it in a timer to run every 4 minutes, but I was receiving lua errors (though it would run fine)

My question is how can I get this to run without locking it into a timer?

Code: [Select]
local Players = player.GetAll()
for i = 1, table.Count(Players) do
local ply = Players[i]
if table.Count(Players) <= 5 then
ply:addMoney( 150 )
ply:ChatPrint( "[TPG] " .. i .. "/40 players connected - initializing cash give-away.")
elseif table.Count(Players) >= 20 then
ply:addMoney( 200 )
ply:ChatPrint( "[TPG] " .. i .. "/40 players connected - initializing cash give-away.")
elseif table.Count(Players) >=30 then
ply:addMoney( 250 )
ply:ChatPrint( "[TPG] " .. i .. "/40 players connected - initializing & upgrading cash give-away.")
elseif table.Count(Players) == 40 then
ply:addMoney(300)
ply:ChatPrint( "[TPG] " .. i .."/40 players connected - initializing & upgrading cash give-away.")
end
end

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Help with a reward system
« Reply #1 on: June 14, 2014, 12:43:15 AM »
Use hooks.
Playerjoin or connect or spawn.
I forget exactly which.
Timer would still be best for making sure players stayed long enough after joining though.
Really should figure out why you were getting the error.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Digital Spit

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 1
Re: Help with a reward system
« Reply #2 on: June 15, 2014, 09:22:55 PM »
Use hooks.
Playerjoin or connect or spawn.
I forget exactly which.
Timer would still be best for making sure players stayed long enough after joining though.
Really should figure out why you were getting the error.

Will do JamminR, thanks for the help!