Mario222 Posted October 7, 2021 Share Posted October 7, 2021 (edited) I have this resource that gives money to players based on their rank that I configure and adapt for only 20 players (maximum limit that I put on my server), it is a DD server but also a race and some from FunDD. So, the resource doesn't work, I have maps of both types and I need it to work in terms of rank but with the number of people left as I configure it, but that the winner, when no one is left alive, can take their money but I can't achieve how do it, I'm sorry if I bother but I'm still new to this Lua. -- # Server Side ! local Ranks = { {1,400}, {2,200}, {3,100}, {4,80}, {5,50}, {6,30}, {7,20}, {8,20}, {9,20}, {10,10} {11,10} {12,10} {13,10} {14,10} {15,10} {16,5} {17,5} {18,5} {19,5} {20,5} } addEventHandler("onPlayerWasted",root, function ( ) for _,v in ipairs ( Ranks ) do if ( exports["race"]:getPlayerRank( source ) == v[1] ) then givePlayerMoney ( source,v[2] ) end end end ) Edited October 7, 2021 by Mario222 error Link to comment
Moderators Vinyard Posted October 7, 2021 Moderators Share Posted October 7, 2021 Hi, your thread has been moved to the scripting section as it's a better suited place to get help for your problem. 1 Link to comment
_SAXI_ Posted October 8, 2021 Share Posted October 8, 2021 You had a problem in the table. Here's the fix: local Ranks = { {1,400}, {2,200}, {3,100}, {4,80}, {5,50}, {6,30}, {7,20}, {8,20}, {9,20}, {10,10}, {11,10}, {12,10}, {13,10}, {14,10}, {15,10}, {16,5}, {17,5}, {18,5}, {19,5}, {20,5} } 1 Link to comment
Mario222 Posted October 8, 2021 Author Share Posted October 8, 2021 2 hours ago, _SAXI_ said: You had a problem in the table. Here's the fix: local Ranks = { {1,400}, {2,200}, {3,100}, {4,80}, {5,50}, {6,30}, {7,20}, {8,20}, {9,20}, {10,10}, {11,10}, {12,10}, {13,10}, {14,10}, {15,10}, {16,5}, {17,5}, {18,5}, {19,5}, {20,5} } Yes i didn't saw that i fixed the problem. How to make it give money to the player regardless of whether it is a DD map or a race I can use the function of getAlivePlayers getDeadPlayers ??? Link to comment
_SAXI_ Posted October 10, 2021 Share Posted October 10, 2021 You can use an array to solve that. local Ranks = { {1,400}, {2,200}, {3,100}, {4,80}, {5,50}, {6,30}, {7,20}, {8,20}, {9,20}, {10,10}, {11,10}, {12,10}, {13,10}, {14,10}, {15,10}, {16,5}, {17,5}, {18,5}, {19,5}, {20,5} } local payToPlayer={}; addEventHandler('onPlayerWasted',root,function() for _,v in ipairs(Ranks) do if(exports["race"]:getPlayerRank(source) == v[1] )then payToPlayer[source] = v[2]; end end end) addEventHandler('onPlayerSpawn',root,function() if(payToPlayer[source])then givePlayerMoney(source,payToPlayer[source]); payToPlayer[source] = nil; -- reset the array end end) Link to comment
Mkl Posted October 10, 2021 Share Posted October 10, 2021 (edited) Hello, Here the documentation that can help you https://wiki.multitheftauto.com/wiki/Resource:Race. To distinguish Race from DD you can use info table from onMapStarting race event. Here an example how we could use it : local mapmode = nil addEventHandler("onMapStarting", root, function(info) mapmode = info.modename end ) function giveRacePrice(rank) if (mapmode == 'Sprint') then -- if mode is race for _,v in ipairs(Ranks) do if(rank == v[1] )then payToPlayer[source] = v[2]; end end end end addEventHandler("onPlayerFinish", root, giveRacePrice) -- event from Race function giveDDPrice(rank) if (mapmode == 'Destruction derby') then -- if mode is DD for _,v in ipairs(Ranks) do local rank = (#getAlivePlayers() + 1) -- or exports["race"]:getPlayerRank(source) ? if(rank == v[1] )then payToPlayer[source] = v[2]; end end end end addEventHandler("onPlayerWasted", root, giveDDPrice) Edited October 10, 2021 by Mkl 1 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