Juukoo Posted September 4, 2015 Share Posted September 4, 2015 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) Link to comment
JR10 Posted September 4, 2015 Share Posted September 4, 2015 The obvious explanation here is that onlineTime is not separated by that separation character. Link to comment
Markeloff Posted September 4, 2015 Share Posted September 4, 2015 You have to use the same function name at the third arg if the event is related to that function. function giveMoney () addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), timer) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now