SA-MP Forums Archive
Members - 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: Members (/showthread.php?tid=652097)



Members - EvgeniyHostel1992 - 02.04.2018

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


Re: Members - kovac - 02.04.2018

I made you an example. Hope it will help you

PHP код:
#define MAX_GANGS 1000
GetGangMembersCount(gangid)
{
    new 
count;
    foreach (new 
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 
0MAX_GANGSi++)
    {
        foreach (new 
Player)
        {
            if(
IsPlayerConnected(p) && PlayerInfo[p][Gang] == i)
            {
                
amount 1000*GetGangMembersCount(i)
                
GivePlayerMoney(pamount)
                
                
GetPlayerName(pnamesizeof(name));
                
format(stringsizeof(string), "DEBUG: Player: %s - Money given: %d - Online members: %d"nameamountGetGangMembersCount(i))
                
SendClientMessage(playerid, -1string);
            }
        }
    }
    return 
1;




Re: Members - EvgeniyHostel1992 - 03.04.2018

error 021: symbol already defined: "GetGangMembersCount"


Re: Members - kovac - 03.04.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