Unban cmd
#1

I've problem with my /unban command :/

Well /ban adds "pSuspended = 1" to Player.ini file.

and I don't know what's wrong with my /unban cmd. It should change pSuspended to "0" but it doesn't. It even shows for me message "Player Is Not Banned"

/ban cmd :
pawn Код:
//-------------------------[Ban]------------------------------------------------
if(strcmp(cmd, "/ban", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_PURPLE, "USAGE: /ban [playerid] [reason]");
return 1;
}
new playa = strval(tmp);
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= &#39; '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_PURPLE, "USAGE: /ban [playerid] [reason]");
return 1;
}
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 6 && PlayerInfo[playerid][pRealAdmin] == 1)
{
SendClientMessage(playa, COLOR_YELLOW, "You were banned from the server");
SendClientMessage(playa, COLOR_GREEN, "===========================================================================");
format(string, sizeof(string), "Admin: %s Banned you",sendername);
SendClientMessage(playa, COLOR_RED, string);
format(string, sizeof(string), "Reason: %s", result);
SendClientMessage(playa, COLOR_RED, string);
SendClientMessage(playa, COLOR_GREEN, "===========================================================================");
SendClientMessage(playa, COLOR_YELLOW, "To appeal this ban, screenshot the information and visit http://www.tomsrp.mysmf.com[url=http://]");
format(string, sizeof(string), "Admin: %s Banned %s, Reason: %s",sendername, giveplayer, result);
printf("%s",string);
format(string, sizeof(string), "Admin: %s Banned %s, Reason: %s",sendername, giveplayer, result);
PlayerInfo[playerid][pSuspended] = 1;
SendClientMessageToAll(COLOR_RED, string);
Ban(playa);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
}
return 1;
}
/Unban command.

pawn Код:
//-------------------------[Unban]----------------------------------------------
if (strcmp(cmd, "/unban", true)==0)
{
if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 6 && PlayerInfo[playerid][pRealAdmin] == 1)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_PURPLE, "USAGE: /unban [playername]");
return 1;
}
if(!LoadPlayer(playerid,tmp))
{
return 1;
}
if(PlayerInfo[playerid][pSuspended] == 0)
{
SendClientMessage(playerid, COLOR_RED, "That player is not banned!");
return 1;
}
else
{
if(PlayerInfo[playerid][pSuspended] == 1)
{
PlayerInfo[playerid][pSuspended] = 0;
SavePlayer(playerid,tmp);
SendClientMessage(playerid, COLOR_DBLUE, "Player Un banned");
}
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
}
return 1;
}

if (strcmp(cmd, "/unbanip", true)==0)
{
if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 8 && PlayerInfo[playerid][pRealAdmin] == 1)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_PURPLE, "USAGE: /unban [IP]");
return 1;
}
format(string, sizeof(string), "unbanip %s", tmp);
SendRconCommand(string);
SendRconCommand("reloadbans");
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
}
return 1;
}
Help
Reply
#2

Because your checking if the player whos typing /unban is suspended
Reply
#3

So how to fix it?
Reply
#4

Its a guess but:

pawn Код:
if(PlayerInfo[tmp][pSuspended] == 0)
Reply
#5

Could you give me whole unban cmd with that?
Reply
#6

pawn Код:
//-------------------------[Unban]----------------------------------------------
if (strcmp(cmd, "/unban", true)==0)
{
if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 6 && PlayerInfo[playerid][pRealAdmin] == 1)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_PURPLE, "USAGE: /unban [playername]");
return 1;
}
if(!LoadPlayer(playerid,tmp))
{
return 1;
}
if(PlayerInfo[tmp][pSuspended] == 0)
{
SendClientMessage(playerid, COLOR_RED, "That player is not banned!");
return 1;
}
else
{
if(PlayerInfo[tmp][pSuspended] == 1)
{
PlayerInfo[tmp][pSuspended] = 0;
SavePlayer(playerid,tmp);
SendClientMessage(playerid, COLOR_DBLUE, "Player Un banned");
}
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
}
return 1;
}

if (strcmp(cmd, "/unbanip", true)==0)
{
if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 8 && PlayerInfo[playerid][pRealAdmin] == 1)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_PURPLE, "USAGE: /unban [IP]");
return 1;
}
format(string, sizeof(string), "unbanip %s", tmp);
SendRconCommand(string);
SendRconCommand("reloadbans");
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
}
return 1;
}
Reply
#7

Код:
XXX(9437) : error 033: array must be indexed (variable "tmp")
XXX(9444) : error 033: array must be indexed (variable "tmp")
XXX(9446) : error 033: array must be indexed (variable "tmp")
Any ideas?
Reply
#8

You obviously have to edit the players file, and not intern values .. How would you do that if he's not even connected?
Use common sense ..

Since you didn't give proper details, I suppose you use dini - an example;
pawn Код:
if (strcmp(cmd, "/unban", true)==0)
{
    if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 6 && PlayerInfo[playerid][pRealAdmin] == 1)
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp) || strlen(tmp) > MAX_PLAYER_NAME) return SendClientMessage(playerid, COLOR_PURPLE, "USAGE: /unban [playername]");
        // if(!LoadPlayer(playerid,tmp)) return 1; // Huh?
        new filename[ 80 ];
        format(filename, sizeof(filename), "%s.ini", tmp);
        if(!fexist(filename)) return SendClientMessage(playerid, COLOR_RED, "Player not found!");
        dini_IntSet(filename, "pSuspended", 0);
        return SendClientMessage(playerid, COLOR_RED, "Player has been unsuspended!");
    }
    else return SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
}
Reply
#9

Код:
XXX (9433): error 017: undefined symbol "dini_IntSet"
pawn Код:
dini_IntSet(filename, "pSuspended", 0); // 9433
:/
Nevermind, forgot to
pawn Код:
#include <dini>

Will let you know if it doesnt work :P
Reply
#10

Now it changes password :/
I just can't log in with password that I used in /register !
Reply
#11

You have to edit the code he sent you to get it working...
Reply
#12

Okay Thanks for help guys, I've fixed it
pawn Код:
new filename[ 80 ];
format(filename, sizeof(filename), "%s.ini", tmp);
if(!fexist(filename)) return SendClientMessage(playerid, COLOR_RED, "Player not found!");
PlayerInfo[playerid][pSuspended] = 0;
EDIT: Fuck it, now it doesn't change [pSuspended] to 0 again
Reply
#13

I've replaced this cmd with the one from GF
pawn Код:
//-------------------------[Unban TehWeirdShit ZOMG]----------------------------------------------------

if (strcmp(cmd, "/unban", true)==0)
{ new string[256];
  if((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >=6)
  {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
{
    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unban [PlayerName]");
      return 1;
}
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(giveplayer));
printf(string);
format(string,sizeof(string),"scriptfiles\%s.ini",tmp);
fremove(string);
SendClientMessage(playerid, COLOR_GREEN, "Player unbanned");
SendRconCommand(string);
PlayerInfo[playerid][pSuspended] = 0;
SendRconCommand("reloadbans");
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
}
return 1;
}
if (strcmp(cmd, "/unbanip", true)==0)
{
if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 8 && PlayerInfo[playerid][pRealAdmin] == 1)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_PURPLE, "USAGE: /unban [IP]");
return 1;
}
format(string, sizeof(string), "unbanip %s", tmp);
SendRconCommand(string);
SendRconCommand("reloadbans");
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
}
return 1;
}
It isn't changing pSuspended "0" either :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)