Banning an offline player
#1

pawn Код:
CMD:banoff(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 2 || IsPlayerAdmin(playerid))
    {
        new name[100];
        new file[128];
        new targetid;
         GetPlayerName(targetid, name, sizeof(name));
        new name2[12] = name;//must be a constant expression, assumed zero
        new name3 = strval(name2);
        new reason[128];
        if(sscanf(params,"s[100]s[128]", name,reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "[USAGE]: /banoff [name] [reason]");
        format(file, sizeof(file),"Admin/Accounts/%s.ini", name);
        if(!fexist(file)) return SendClientMessage(playerid, 0xFF0000AA, "Player is not on the database");
        BanPlayer(name3,playerid,reason);
    }
    return 1;
}
Being a noob 'and all, I came up with this code myself. But I crossed on one error, it's commented in the pawn code so you may want to look up top
Reply
#2

Hmm, I am in my iPad, so you can post the error here now?
Reply
#3

Quote:
Originally Posted by MyNinja
Посмотреть сообщение
Hmm, I am in my iPad, so you can post the error here now?
Error code: Must be a constant expression, assumed zero
EDIT: This line - new name2[12] = name;
Reply
#4

Check out my Tutorial, it will give you an idea. I'd recommend you to use the new methods.

https://sampforum.blast.hk/showthread.php?tid=388612
Reply
#5

Or save the last connected IP from the Player in the scriptfiles from the Player, and rangeban then the Player.
Reply
#6

1. You need to make an array for names. name[MAX_PLAYER_NAME+1] (+1 is for null). Then use:
pawn Код:
strmid(name2, name, 0, strlen(name));
2. If you use SSCANF then use the "u" params for smaller code..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)