Posts: 53
Threads: 21
Joined: Feb 2016
Reputation:
0
How to find out the number of online subordinates of one of the gangs and multiply this amount by the amount?
I want that at the salary of each gang from their treasury the amount which was spent for online of all gang
Posts: 180
Threads: 3
Joined: Mar 2018
I made you an example. Hope it will help you
PHP код:
#define MAX_GANGS 1000
GetGangMembersCount(gangid)
{
new count;
foreach (new i : Player) // or for(new i = 0; i < MAX_PLAYERS; i++) if you don't use foreach
{
if(IsPlayerConnected(i) && PlayerInfo[i][Gang] == gangid)
{
count++;
}
}
return count;
}
CMD:salary(playerid)
{
new string[128], name[MAX_PLAYER_NAME], amount;
for(new i = 0; i < MAX_GANGS; i++)
{
foreach (new p : Player)
{
if(IsPlayerConnected(p) && PlayerInfo[p][Gang] == i)
{
amount = 1000*GetGangMembersCount(i)
GivePlayerMoney(p, amount)
GetPlayerName(p, name, sizeof(name));
format(string, sizeof(string), "DEBUG: Player: %s - Money given: %d - Online members: %d", name, amount, GetGangMembersCount(i))
SendClientMessage(playerid, -1, string);
}
}
}
return 1;
}
Posts: 53
Threads: 21
Joined: Feb 2016
Reputation:
0
error 021: symbol already defined: "GetGangMembersCount"
Posts: 180
Threads: 3
Joined: Mar 2018
Quote:
Originally Posted by EvgeniyHostel1992
error 021: symbol already defined: "GetGangMembersCount"
|
So you already have function with same name somewhere in your script, just rename it