Money Rain Help! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Money Rain Help! (
/showthread.php?tid=615471)
Money Rain Help! -
danish007 - 22.08.2016
How can i do that, if i use /moneyrain (amount) the amount will be divided in all players equally?
Re: Money Rain Help! - WhiteGhost - 22.08.2016
Wrong,delete.
Re: Money Rain Help! -
Shinja - 22.08.2016
PHP код:
CMD:moneyrain(playerid, params[])
{
new money, players;
if(sscanf(params, "i", money)) return SendClientMessage(playerid, -1, "USAGE: moneyrain amount");
for(new i, j=GetPlayerPoolSize(); i<=j; i++){if(IsPlayerConnected(i)) players++;} //Getting EXACT number of players online
new pmoney = money; pmoney /= players;
for(new i, j=GetPlayerPoolSize(); i<=j; i++)
{
if(IsPlayerConnected(i)) GivePlayerMoney(i, pmoney);
}
return 1;
}
Re: Money Rain Help! -
Stinged - 22.08.2016
PHP код:
new i, count, pool_size = GetPlayerPoolSize();
for (i = 0; i <= pool_size; i++)
{
if (IsPlayerConnected(i))
count++;
}
amount /= count;
for (i = 0; i <= pool_size; i++)
{
// No need to use IsPlayerConnected ONLY IF you're only using natives
// Because they do not get called if the player isn't online
GivePlayerMoney(i, amount);
}
It would be more efficient if you use foreach/y_iterate instead.
You replace that with this:
PHP код:
amount /= Iter_Count(Player);
foreach (new i : Player)
{
GivePlayerMoney(i, amount);
}
Re: Money Rain Help! -
danish007 - 23.08.2016
Thanks Stinged, +Rep