function sendTurfPayout()
local playerJobs = {}
-- getting all police
for i, player in ipairs(getElementsByType('player')) do
local job = exports.NGJobs:getPlayerJob(player)
if (job == 'Police Officer') then
if (playerJobs[player] == nil) then
playerJobs[player] = 0
end
playerJobs[player] = playerJobs[player] + 1
end
end
-- pay the players
for player, count in pairs(playerJobs) do
local cash = count * tonumber(get("*PAYOUT_CASH"))
givePlayerMoney(player, cash)
exports.NGMessages:sendClientMessage("Police: Here is $" .. tostring(cash) .. " payout.", player, 0, 255, 0)
end
end
-- set the timer
local payoutTimeStr = get("*PAYOUT_TIME")
if payoutTimeStr ~= false and type(payoutTimeStr) == "string" then
local payoutTimeInt= tonumber(payoutTimeStr)
if type(payoutTimeInt) == "number" and payoutTimeInt > 0 then
setTimer(sendTurfPayout,payoutInt*60*1000,0)
else
outputDebugString("Warning! Invalid *PAYOUT_TIME set in meta file",2);
end
else
outputDebugString("warning No *PAYOUT_TIME parameter foundin meta file",2);
end
try this please