How do I make a faction only chat
#1

So I have admin only chat but I want faction only chat and I don't even know how because I think it would involve two loops
Here is the callback I use for the admin only chat
PHP код:
public SendAdminMessage(color,string[])
{
    foreach(
Player,i)
    {
        if(
PlayerInfo[i] [pAdmin] >= && GetPVarInt(i"on_adminduty"))
        {
            
SendClientMessage(i,color,string);
        }
    }
    return 
1;

Heres what the Faction chat needs to have
PHP код:
public SendFactionMessage(color,string[])
{
    foreach(
Player,i)
    {
        if(
PlayerInfo[i] [Faction] == FactionInfo[x][factionid]))
        {
            
SendClientMessage(i,color,string);
        }
    }
    return 
1;

but to get the x variable I need another loop
PHP код:
for(new i=1;i<MAX_FACTION;i++) 
how do I merge those loops together to work in the fuction?
Reply
#2

You could just pass 'playerid' as a parameter for SendFactionMessage.
pawn Код:
forward SendFactionMessage(playerid,color,string[]) ;
public SendFactionMessage(playerid,color,string[])
{
    foreach(Player,i)
    {
        if(PlayerInfo[playerid][Faction] == PlayerInfo[i][Faction]))
        {
            SendClientMessage(i,color,string);
        }
    }
    return 1;
}  

//How to use:
SendFactionMessage(playerid,-1,"This is the faction chat!");
Reply
#3

But that's looping through players still not the faction
Reply
#4

Oops, sorry. I never even noticed the 'FactionInfo', hehe.

I edited the last post. Try it now.
Reply
#5

Invalid expression assumed zero
Reply
#6

Use this:

PHP код:
forward SendFactionMessage(playerid,color,string[]);
public 
SendFactionMessage(playerid,color,string[]);

    foreach(
Player,i
    { 
        if(
PlayerInfo[playerid][Faction] == PlayerInfo[i][Faction])) 
        { 
            
SendClientMessage(i,color,string); 
        } 
    } 
    return 
1
}  
//How to use:
SendFactionMessage(playerid,-1,"This is the faction chat!"); 
Reply
#7

didn't work
Reply
#8

I feel like your trying to set two things equal to each other but they are the same enum shouldnt it be PlayerInfo faction goes to to everyone who has the same PlayeInfo faction but how does that work?!
Reply
#9

pawn Код:
forward SendFactionMessage(playerid,color,string[]);
public SendFactionMessage(playerid,color,string[])
{
    foreach(Player,i)
    {
        if(PlayerInfo[playerid][Faction] == PlayerInfo[i][Faction])
        {
            SendClientMessage(i,color,string);
        }
    }
    return 1;
}
Reply
#10

invalid expression assumed zero
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)