Small error with my family chat command.
#1

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
Reply
#2

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

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.
Reply
#4

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;
}
Reply
#5

Thank you so much! fixed!

Do you know what I did wrong there?


, +1 rep btw.
Reply
#6

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.
Reply
#7

AHHHH! I see, thank you very much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)