/report cmd sometimes buged
#1

hi,

i use this /report cmd in my server but sometimes its buged and i returns smth. like:
PlayerName has reported PlayerName has reported PlayerName has reported BadPlayerName Reason PlayerName has reported.
Shit like this

Would be nice if someone could show me where there could be the error in this code

regards...

pawn Код:
dcmd_report(playerid, params[])
{
    new name[30], aName[MAX_PLAYER_NAME], str[128], reason, iD;
    GetPlayerName(playerid,name,30);
    if (sscanf(params, "dz", iD, reason)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /report [ID] [Reason]");
    if (iD == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "Invalid PlayerID!");
    if (playerid == iD) return SendClientMessage(playerid, 0xFF0000FF, "You can't report yourself!");
    GetPlayerName(iD, aName, sizeof(aName));
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            if(Spieler[i][AdminLevel] > 0)
            {
                format(str, sizeof(str), "%s(%d) has reported %s(%d) for: %s", name, playerid, aName, iD, reason);
                SendClientMessage(i, 0xFF66FFAA, str);
            }
        }
    }
    return 1;
}
Reply
#2

the first name should be [MAX_PLAYER_NAME], right?
Reply
#3

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
the first name should be [MAX_PLAYER_NAME], right?
It doesn't matter I think, but its best to use MAX_PLAYER_NAME
Reply
#4

so the issue wouldnt be solved if i just add the [MAX_PLAYER_NAME] right?
Any other suggestions?
Would be really very happy
Reply
#5

no one knows where the error might be?
Reply
#6

Becouse you are formatting the text into the loop (for)
Reply
#7

so how would i fix it?
Im kinda sleepy now

thx for ur answer btw
Reply
#8

try
pawn Код:
dcmd_report(playerid, params[])
{
    new name[30], aName[MAX_PLAYER_NAME], str[128], reason, iD;
    GetPlayerName(playerid,name,30);
    if (sscanf(params, "dz", iD, reason)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /report [ID] [Reason]");
    if (iD == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "Invalid PlayerID!");
    if (playerid == iD) return SendClientMessage(playerid, 0xFF0000FF, "You can't report yourself!");
    GetPlayerName(iD, aName, sizeof(aName));
    format(str, sizeof(str), "%s(%d) has reported %s(%d) for: %s", name, playerid, aName, iD, reason);
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            if(Spieler[i][AdminLevel] > 0)
            {
                SendClientMessage(i, 0xFF66FFAA, str);
            }
        }
    }
    return 1;
}
Reply
#9

thx alot for ur fast answer !
Ill try it out soon but now im gonna get some sleep

thx alot !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)