Banning an offline player - 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: Banning an offline player (
/showthread.php?tid=409881)
Banning an offline player -
Neil. - 23.01.2013
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
Re: Banning an offline player -
MyNinja - 23.01.2013
Hmm, I am in my iPad, so you can post the error here now?
Re: Banning an offline player -
Neil. - 23.01.2013
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;
Re: Banning an offline player -
gtakillerIV - 23.01.2013
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
AW: Banning an offline player -
Blackazur - 23.01.2013
Or save the last connected IP from the Player in the scriptfiles from the Player, and rangeban then the Player.
Re: Banning an offline player -
B-Matt - 23.01.2013
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..