BigBoss1234 Posted April 11, 2023 Share Posted April 11, 2023 (edited) Job payout timer -- Group payout timer function sendTurfPayout ( ) local playerJobs = { } for i, Police Officer in pairs ( getElementsByType ( 'player' ) ) do local exports.NGJobs:getPlayerJobs ( 'Police Officer' ) if ( g and playerJobs [ g ] and playerJobs [ g ] > 0 ) then local c = playerJobs [ g ] * tonumber ( get ( "*PAYOUT_CASH" ) ) givePlayerMoney ( Police Officer, c ) exports.NGMessages:sendClientMessage ( "Police: Here is $ "( playerJobs [ g ] ).."playout" v, 0, 255, 0 ) end end end setTimer ( sendTurfPayout, (60*tonumber(get("*PAYOUT_TIME")))*1000, 0 ) Edited April 11, 2023 by Citizen code block Link to comment
Moderators Citizen Posted April 11, 2023 Moderators Share Posted April 11, 2023 Hello @BigBoss1234, Don't use the Tutorial section to ask scripting questions. Your topic has been moved to the Scripting section and approved so other members can now see it. Using the right section for your post next time will reduce the waiting time for an actual answer. PS: Also embed your lua code in a script block so it is easier to read. It's greatly appreciated in the community when OP does so (I edited your post for you) Best regards, Link to comment
FLUSHBICEPS Posted April 11, 2023 Share Posted April 11, 2023 (edited) 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 payoutTime = tonumber(get("*PAYOUT_TIME")) if payoutTime then setTimer(sendTurfPayout, 60 * payoutTime * 1000, 0) end Edited April 11, 2023 by FLUSHBICEPS 1 Link to comment
BigBoss1234 Posted April 12, 2023 Author Share Posted April 12, 2023 (edited) Not Warking function sendJobPayout() 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 payoutTime = tonumber(get("*PAYOUT_TIME")) if payoutTime then setTimer(sendTurfPayout, 60 * payoutTime * 1000, 0) end <meta> <info author="BigBoss" name="Police Playout" type='script' version="1.0" /> <script src="server.lua" type="server" /> <settings> <setting name="*PAYOUT_TIME" value="30" desc="Payout timer in minutes" /> <setting name="*PAYOUT_CASH" value="100000" desc="Money per group member per turf" /> </settings> </meta> Edited April 12, 2023 by BigBoss1234 Link to comment
P[ow]er Posted April 13, 2023 Share Posted April 13, 2023 16 hours ago, BigBoss1234 said: Not Warking function sendJobPayout() 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 payoutTime = tonumber(get("*PAYOUT_TIME")) if payoutTime then setTimer(sendTurfPayout, 60 * payoutTime * 1000, 0) end <meta> <info author="BigBoss" name="Police Playout" type='script' version="1.0" /> <script src="server.lua" type="server" /> <settings> <setting name="*PAYOUT_TIME" value="30" desc="Payout timer in minutes" /> <setting name="*PAYOUT_CASH" value="100000" desc="Money per group member per turf" /> </settings> </meta> 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 1 Link to comment
FLUSHBICEPS Posted April 13, 2023 Share Posted April 13, 2023 18 hours ago, BigBoss1234 said: Not Warking function sendJobPayout() 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 payoutTime = tonumber(get("*PAYOUT_TIME")) if payoutTime then setTimer(sendTurfPayout, 60 * payoutTime * 1000, 0) end <meta> <info author="BigBoss" name="Police Playout" type='script' version="1.0" /> <script src="server.lua" type="server" /> <settings> <setting name="*PAYOUT_TIME" value="30" desc="Payout timer in minutes" /> <setting name="*PAYOUT_CASH" value="100000" desc="Money per group member per turf" /> </settings> </meta> You are calling in setTimer “SendTurfPayout” function and the function is sendJobPayout 1 Link to comment
BigBoss1234 Posted April 14, 2023 Author Share Posted April 14, 2023 Bro, a playout does not happen from Resource, please make one for me A big help On 11/04/2023 at 20:21, FLUSHBICEPS said: local job = exports.NGJobs:getPlayerJob(player) getPlayerJob ro getPlayerJobs? Link to comment
FLUSHBICEPS Posted April 14, 2023 Share Posted April 14, 2023 getPlayerJobs then I guess 1 Link to comment
FLUSHBICEPS Posted April 14, 2023 Share Posted April 14, 2023 How your server stores job info? If it’s a team use getPlayerTeam 1 Link to comment
BigBoss1234 Posted April 16, 2023 Author Share Posted April 16, 2023 Spoiler http://blob:https://web.whatsapp.com/2a50cd3f-050f-4902-b005-7596351d7c6f Link to comment
BigBoss1234 Posted April 16, 2023 Author Share Posted April 16, 2023 local job = exports.NGJobs:getPlayerTeam(player) ?? 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