SendFactionMessage Help.
#1

Hello, can someone please show me how to make a loop which sends the command to the enumerator value of the person executing the command? So, for example, Player A does /factionmessage and it only sends this message to people whose faction enumerator is == 1 (assuming Player A's is "1")

Thanks.
Reply
#2

pawn Код:
for( new i = 0; i < GetMaxPlayers(); i++ )
{
    if( yourpvar[ playerid ][ faction ] == 1 )
    {
        // do your stuff here
    }
}
Reply
#3

Код:
if(PlayerInfo[playerid][IsInFaction] == 1)
{
	for(new i; i < MAX_PLAYERS; i++)
	{
	    if(PlayerInfo[i][FactionID] == PlayerInfo[playerid][FactionID])
	    {
	        new string[128];
		    format(string, sizeof(string),"%s", YOUR_WRITTEN_MESSAGE_FROM_COMMAND);
		    SendClientMessage(i, -1, string);
	    }
	}
}
Something like this?
Reply
#4

PHP код:
if(strcmp(cmd,"/p",true)==0) if(Logged[playerid] == 1)
    {
        
GetPlayerName(playeridsendernamesizeof(sendername));
        new 
length strlen(cmdtext);
        while ((
idx length) && (cmdtext[idx] <= ' '))
        {
        
idx++;
        }
        new 
offset idx;
        new 
result[64];
        while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
        {
        
result[idx offset] = cmdtext[idx];
        
idx++;
        }
        
result[idx offset] = EOS;
        if(!
strlen(result))
        {
        
SendClientMessage(playeridCOLOR_WHITE"[ ! ] USAGE: /p (message)");
        return 
1;
        }
        if(
gTeam[playerid] == TEAM_POLICE)
        {
            
format(stringsizeof(string), "Police officer %s : %s"sendername,result);
            
SendClientMessageToTeam(TEAM_POLICE,TEAM_POLICE_COLOR,string);
            
SendClientMessageToTeam(TEAM_SG,TEAM_POLICE_COLOR,string);
            
SendClientMessageToTeam(TEAM_SWAT,TEAM_POLICE_COLOR,string);
            
SendClientMessageToTeam(TEAM_MAYOR,TEAM_POLICE_COLOR,string);
            
SendClientMessageToTeam(TEAM_PD,TEAM_POLICE_COLOR,string);
            
SendClientMessageToTeam(TEAM_ARMY,TEAM_POLICE_COLOR,string);
            
SendClientMessageToTeam(TEAM_ARMYG,TEAM_POLICE_COLOR,string);
            return 
1;
        }
        return 
1;
    } 
Reply
#5

Thank you for the responses.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)