Help please
#1

Hey all. I made a /report command.
But the message: Your report was send to the admins is sended to times to me. It's anoying.

pawn Код:
COMMAND:report(playerid,params[])
{
    new text[80];
    if(sscanf(params,"s[80]",text)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /report [text]");
    for(new admins;admins < MAX_PLAYERS; admins++)
    {
        if(PlayerInfo[admins][pAdminLevel] >=1)
        {
        GetPlayerName(playerid,Name,sizeof(Name));
        format(String,sizeof(String),"Report from %s[%d]: {FFFFFF}%s.",Name,GetPlayerIdFromName(Name),text,GetPlayerIdFromName(Name));
        SendClientMessage(admins,COLOR_ORANGE,String);
        format(String,sizeof(String),"Use /respond %d to help him/her.",GetPlayerIdFromName(Name));
        SendClientMessage(admins,COLOR_GREY,String);
        format(String,sizeof(String),"Report to the admins: {FFFFFF}%s",text);
        SendClientMessage(playerid,COLOR_ORANGE,String);
        SendClientMessage(playerid,COLOR_WHITE,"Your Report Message was sent to all available admins. They will respond shortly.");
        PlayerInfo[playerid][pReported] = 1;
   
        }
       
    }
    return 1;
}
Reply
#2

pawn Код:
SendAdminMessage(color, text[])
{
    foreach(Player, i)
    {
        if (Playerinfo[i][pAdminLevel] >= 1)
        {
            SendClientMessage(i, color, text);
        }
    }
    return 0;
}
Put that somewhere outside a callback, then change the messages that needs to be sended to an admin with
SendAdminMessage(color, string);
Reply
#3

C:\Users\Bart\Desktop\infinityrp\gamemodes\infinit yrp.pwn(97 : error 017: undefined symbol "foreach"
C:\Users\Bart\Desktop\infinityrp\gamemodes\infinit yrp.pwn(980) : error 017: undefined symbol "Playerinfo"
C:\Users\Bart\Desktop\infinityrp\gamemodes\infinit yrp.pwn(980) : error 017: undefined symbol "i"
C:\Users\Bart\Desktop\infinityrp\gamemodes\infinit yrp.pwn(980) : error 029: invalid expression, assumed zero
C:\Users\Bart\Desktop\infinityrp\gamemodes\infinit yrp.pwn(980) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#4

pawn Код:
COMMAND:report(playerid,params[])
{
    new text[80];
    if(sscanf(params,"s[80]",text)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /report [text]");
    for(new admins;admins < MAX_PLAYERS; admins++)
    {
        if(PlayerInfo[admins][pAdminLevel] >=1)
        {
        GetPlayerName(playerid,Name,sizeof(Name));
        format(String,sizeof(String),"Report from %s[%d]: {FFFFFF}%s.",Name,GetPlayerIdFromName(Name),text,GetPlayerIdFromName(Name));
        SendClientMessage(admins,COLOR_ORANGE,String);
        format(String,sizeof(String),"Use /respond %d to help him/her.",GetPlayerIdFromName(Name));
        SendClientMessage(admins,COLOR_GREY,String);
        PlayerInfo[playerid][pReported] = 1;
   
        }
       
    }
    format(String,sizeof(String),"Report to the admins: {FFFFFF}%s",text);
    SendClientMessage(playerid,COLOR_ORANGE,String);
    SendClientMessage(playerid,COLOR_WHITE,"Your Report Message was sent to all available admins. They will respond shortly.");
    return 1;
}
Reply
#5

https://sampforum.blast.hk/showthread.php?tid=92679
Foreach = loop that is faster & more efficient

Playerinfo = PlayerInfo, stupid typo
Reply
#6

Thanks both. I'm using Wesley's code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)