SA-MP Forums Archive
Small error with my family chat command. - 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: Small error with my family chat command. (/showthread.php?tid=400051)



Small error with my family chat command. - Oscii - 16.12.2012

Hello Everyone,I'm working on a test script and i've been trying to get this command to work and It never works

When I type it it just returns nothing at all, simply nothing, no message or anything.

pawn Код:
CMD:f(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pFam]) return SendClientMessage(playerid, COLOR_GREY, "You are not in a family.");
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/f)amilychat [text]");
    format(string, sizeof(string), "(( ** [OOC] (%d) %s %s: %s ))", PlayerInfo[playerid][pFamRank], RPFaRN(playerid), RPN(playerid), params);
    SendPlayerFamMessage(playerid, COLOR_CYAN, string);
    return 1;
}
Regards
Oscii


Re: Small error with my family chat command. - maramizo - 16.12.2012

Need to see the stock:
pawn Код:
SendPlayerFamMessage(player, color, string[]);



Re: Small error with my family chat command. - Oscii - 16.12.2012

pawn Код:
stock SendPlayerFamMessage(playerid, color, string[])
{
    foreach(Player, i)
    {
        if(IsPlayerLoggedIn(i) && PlayerInfo[i][pFam] == 1 && PlayerInfo[playerid][pFam])
        {
            SendClientMessage(i, color, string);
        }
    }
    return 1;
}
Here you are.


Re: Small error with my family chat command. - maramizo - 16.12.2012

Quote:
Originally Posted by Oscii
Посмотреть сообщение
pawn Код:
stock SendPlayerFamMessage(playerid, color, string[])
{
    foreach(Player, i)
    {
        if(IsPlayerLoggedIn(i) && PlayerInfo[i][pFam] == 1 && PlayerInfo[playerid][pFam])
        {
            SendClientMessage(i, color, string);
        }
    }
    return 1;
}
Here you are.
Change it to:
pawn Код:
stock SendPlayerFamMessage(playerid, color, string[])
{
    foreach(Player, i)
    {
        if(IsPlayerLoggedIn(i) && PlayerInfo[i][pFam] == PlayerInfo[playerid][pFam])
        {
            SendClientMessage(i, color, string);
        }
    }
    return 1;
}



Re: Small error with my family chat command. - Oscii - 16.12.2012

Thank you so much! fixed!

Do you know what I did wrong there?


, +1 rep btw.


Re: Small error with my family chat command. - maramizo - 16.12.2012

Quote:
Originally Posted by Oscii
Посмотреть сообщение
Thank you so much! fixed!

Do you know what I did wrong there?


, +1 rep btw.
pawn Код:
PlayerInfo[i][pFam] == 1
Was in your original code, which does:
Starts checking every single player, and checks if their family equals ID ONE, then sends them the message.

The thing is, you want to check if that player's family equals the chat sender's family, so I did:
pawn Код:
PlayerInfo[i][pFam] == PlayerInfo[playerid][pFam]
To check if theirs equals the sender's, then send the message to them.
I hope you understood.


Re: Small error with my family chat command. - Oscii - 16.12.2012

AHHHH! I see, thank you very much!