Clan chat
#1

I need help with my clan chat. Everyone who's not in a clan can see it, while it should show only for clan members.

PlayerInfo[i][pClan] = cid;
if(PlayerInfo[i][pClan] == cid)
Should detect if the player is in a clan and send the message to his clan members. (I'm not that good with foreach, so sorry if I'm making a major failure :$.

pawn Код:
stock SendClanMessage(color, string[])
{
    foreach(Player, i)
    {
        new cid;
        PlayerInfo[i][pClan] = cid;
        if(PlayerInfo[i][pClan] == cid)
        {
            SendClientMessage(i, color, string);
        }
    }
    return 1;
}
pawn Код:
CMD:c(playerid,params[])
{
    new string[128];
    if(PlayerInfo[playerid][pClan] < 1) return SendClientMessage(playerid, COLOR_REDD, "[ERROR] You are not in a clan!");
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_LGREEN, "Usage: /c [text]");
    format(string, sizeof(string), "[CLAN] %s: {FFFFFF}%s", PLAYERNAME(playerid), params);
    SendClanMessage(COLOR_AMERICA, string);
    return 1;
}
Reply
#2

Try that
pawn Код:
stock SendClanMessage(text[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)

    {
        new cid;
        PlayerInfo[i][pClan] = cid;
        if(PlayerInfo[i][pClan] == cid)
        {
            SendClientMessage(i, color, string);
        }
    }
}
sorry about that edited
Reply
#3

Quote:
Originally Posted by SilentSoul
Посмотреть сообщение
Try that
pawn Код:
stock SendMessageToAdmins(text[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)

    {
        new cid;
        PlayerInfo[i][pClan] = cid;
        if(PlayerInfo[i][pClan] == cid)
        {
            SendClientMessage(i, color, string);
        }
    }
}
Isn't that the same thing? Also it's clan chat, not admin chat xDDD
Reply
#4

Try....

PHP код:
stock SendClanMessage(colorstring[])
{
    foreach(
Playeri)
    {
        if(
PlayerInfo[i][pClan] == 1)// And if player is not in clan hes pClan be '0'.
        
{
            
SendClientMessage(icolorstring);
        }
    }
    return 
1;

Reply
#5

Quote:
Originally Posted by HardRock
Посмотреть сообщение
Try....

PHP код:
stock SendClanMessage(colorstring[])
{
    foreach(
Playeri)
    {
        if(
PlayerInfo[i][pClan] == 1)// And if player is not in clan hes pClan be '0'.
        
{
            
SendClientMessage(icolorstring);
        }
    }
    return 
1;

There are 15 clans in total, this will only have clan id 1 have a clan chat.
Reply
#6

PHP код:
stock SendClanMessage(colorstring[]) 

    foreach(
Playeri
    { 
        if(
PlayerInfo[i][pClan] >= 1)
        { 
            
SendClientMessage(icolorstring); 
        } 
    } 
    return 
1

or

PHP код:
stock SendClanMessage(colorclanidstring[]) 

    foreach(
Playeri
    { 
        if(
PlayerInfo[i][pClan] == clanid)
        { 
            
SendClientMessage(icolorstring); 
        } 
    } 
    return 
1

Reply
#7

Quote:
Originally Posted by HardRock
Посмотреть сообщение
PHP код:
stock SendClanMessage(colorstring[]) 

    foreach(
Playeri
    { 
        if(
PlayerInfo[i][pClan] >= 1)
        { 
            
SendClientMessage(icolorstring); 
        } 
    } 
    return 
1

or

PHP код:
stock SendClanMessage(colorclanidstring[]) 

    foreach(
Playeri
    { 
        if(
PlayerInfo[i][pClan] == clanid)
        { 
            
SendClientMessage(icolorstring); 
        } 
    } 
    return 
1

Above one wont work, as it will send a clan message to all clans, and not to only clan members, not sure about the second one because i can't test it atm. I think it won't work.
Reply
#8

Do you change SendClanMessage(color, string[]) to SendClanMessage(color, clanid, string[]) in your script?

//Edit:

Try this....

PHP код:
stock SendClanMessage(colorstring[])  
{  
    foreach(
Playeri)  
    {  
        if(
PlayerInfo[i][pClan] == PlayerInfo[playerid][pClan]) 
        {  
            
SendClientMessage(icolorstring);  
        }  
    }  
    return 
1;  

Reply
#9

Quote:
Originally Posted by HardRock
Посмотреть сообщение
Do you change SendClanMessage(color, string[]) to SendClanMessage(color, clanid, string[]) in your script?

//Edit:

Try this....

PHP код:
stock SendClanMessage(colorstring[])  
{  
    foreach(
Playeri)  
    {  
        if(
PlayerInfo[i][pClan] == PlayerInfo[playerid][pClan]) 
        {  
            
SendClientMessage(icolorstring);  
        }  
    }  
    return 
1;  

Won't even let me compile.
// edit
Say's empty statement to : SendClanMessage(COLOR_AMERICA, string);
Reply
#10

Do you have the foreach include? Or just replace it with this - for(new i = 0; i < MAX_PLAYERS; i++)
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)