Hey, my payday script is not work. The script gives only error to debugscript and nothing is happening.
debugscript: ERROR: Payday\server.lua:14: bad argument #1 to 'gsub' (string expected, got boolean)
Thanks!
function giveMoney ()
players = getElementsByType ("player")
for k, pelaaja, auto in ipairs(players) do
onlineTime = getElementData(pelaaja, "online")
if onlineTime == false then
return false
else
h = gettok(onlineTime, 1, " ")
m = gettok(onlineTime, 2, " ")
m = string.gsub(m, "min", "")
h = string.gsub(h, "h", "")
h = tonumber(h)
m = tonumber(m)
if m < 1 then
return false
else
if h > 0 then
m = h*180+m
raha = m*1.667
raha = math.floor(raha)
players = getElementsByType ("player")
outputChatBox ("You been online for " .. onlineTime .. " and got " .. raha .. "$ for it!", pelaaja, 255, 255, 255, true)
givePlayerMoney (pelaaja, raha)
else
raha = m*1.667
raha = math.floor(raha)
players = getElementsByType ("player")
outputChatBox ("You been online for " .. m .. "min and got " .. raha .. "$ for it!", pelaaja, 255, 255, 255, true)
givePlayerMoney (pelaaja, raha)
end
end
end
end
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), timer)