SA-MP Forums Archive
How do I make a faction only chat - 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: How do I make a faction only chat (/showthread.php?tid=469631)



How do I make a faction only chat - lramos15 - 14.10.2013

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?


Re: How do I make a faction only chat - EiresJason - 14.10.2013

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!");



Re: How do I make a faction only chat - lramos15 - 14.10.2013

But that's looping through players still not the faction


Re: How do I make a faction only chat - EiresJason - 14.10.2013

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

I edited the last post. Try it now.


Re: How do I make a faction only chat - lramos15 - 14.10.2013

Invalid expression assumed zero


Re: How do I make a faction only chat - thomaswilliams - 14.10.2013

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!"); 



Re: How do I make a faction only chat - lramos15 - 14.10.2013

didn't work


Re: How do I make a faction only chat - lramos15 - 14.10.2013

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?!


Re: How do I make a faction only chat - EiresJason - 14.10.2013

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;
}



Re: How do I make a faction only chat - lramos15 - 14.10.2013

invalid expression assumed zero