Shared chat between 2 factions.
#4

Example (not tested in game)
pawn Код:
#define POLICE  1
#define MEDICS  2

CMD:faction(playerid,params[]) {
    new text[128];
    if(sscanf(params,"s[128]")) return SendClientMessage(playerid,COLOR_RED,"Usage: /faction [text]");
    SendFactionMessage(text, POLICE, MEDICS);
    return true;
}



stock SendFactionMessage(text[],faction1, faction2) {
    for(new i=0; i < MAX_PLAYERS ;i++) {
        if(IsPlayerConnected(i)) {
            if(gTeam[i] == faction1 || gTeam[i] == faction2) { //if they are part of faction 1 or part of faction 2
                SendClientMessage(i,COLOR_RED,text);
            }
        }
    }
}


Or if you want dynamic usage of this system

pawn Код:
#define POLICE      1
#define MEDICS      2
#define NO_FACTION  3

CMD:faction(playerid,params[]) {
    new text[128];
    if(sscanf(params,"s[128]")) return SendClientMessage(playerid,COLOR_RED,"Usage: /faction [text]");
    SendFactionMessage(text, getPlayerFaction(playerid));
    return true;
}


stock getPlayerFaction(playerid) return gTeam[playerid];


stock getConnectedFaction(faction) {
    switch(faction) {
        case POLICE: return MEDICS;
        case MEDICS: return POLICE;
        default: return NO_FACTION; //if they are not part of the faction above
    }
}



stock SendFactionMessage(text[], faction) {
    for(new i=0; i < MAX_PLAYERS ;i++) {
        if(IsPlayerConnected(i)) {
            if(gTeam[i] == faction1 || gTeam[i] == getConnectedFaction(faction)) { //if they are part of faction 1 or part of faction 1 is connected to
                SendClientMessage(i,COLOR_RED,text);
            }
        }
    }
}
Reply


Messages In This Thread
Shared chat between 2 factions. - by cs_waller - 15.11.2016, 18:18
Re: Shared chat between 2 factions. - by justinnater - 15.11.2016, 23:53
Re: Shared chat between 2 factions. - by Luis- - 15.11.2016, 23:54
Re: Shared chat between 2 factions. - by TwinkiDaBoss - 16.11.2016, 00:19

Forum Jump:


Users browsing this thread: 1 Guest(s)