SA-MP Forums Archive
Clan 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: Clan chat (/showthread.php?tid=470594)



Clan chat - ThaCrypte - 19.10.2013

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



Re: Clan chat - SilentSoul - 19.10.2013

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


Re: Clan chat - ThaCrypte - 19.10.2013

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


Re: Clan chat - HardRock - 19.10.2013

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;




Re: Clan chat - ThaCrypte - 19.10.2013

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.


Re: Clan chat - HardRock - 19.10.2013

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




Re: Clan chat - ThaCrypte - 19.10.2013

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.


Re: Clan chat - HardRock - 19.10.2013

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;  




Re: Clan chat - ThaCrypte - 19.10.2013

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


Re: Clan chat - TonyII - 19.10.2013

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