/unban command help
#1

This is my /unban command:
PHP код:
dcmd_unban(playeridparams[])
{
    new 
pName[128], string[128];
    if(
PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playeridCOLOR_WHITE,"Server: Unrecognized command, type /commands to see the commands available for you.");
    if(
PlayerInfo[playerid][pAdmin]<4) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This command is unavailable for your admin rank.");
    if(
admduty[playerid]==0) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: You must be on duty to use this command.");
    if(
sscanf(params"s"pName)) return SendClientMessage(playeridCOLOR_ADMINBLUE"Correct usage: /unban [username]");
     
format(pNamesizeof(pName), "/Users/%s.ini"pName);
    if(!
fexist(string)) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This user does not exists.");
    
SetPVarString(playerid"UnbanName"pName);
    
SetPVarInt(playerid"BanCheck"0);
    
INI_ParseFile(string"LoadBan_%s", .bExtra true, .extra playerid);
    if(
GetPVarInt(playerid"BanCheck")==0) return SendClientMessage(playeridCOLOR_ADMINBLUE"ERROR: This user is not banned.");
    new 
INI:File INI_Open(string);
    
INI_SetTag(File"data");
    
INI_WriteInt(File"Banned"0);
    
INI_Close(File);
    
format(stringsizeof(string), "User %s has been unbanned."pName);
    
SendClientMessage(playeridCOLOR_ADMINBLUEstring);
    return 
1;
}
forward LoadBan_data(playeridname[], value[]);
public 
LoadBan_data(playeridname[], value[])
{
    new var = 
0;
    
INI_Int("Banned", var);
    
SetPVarInt(playerid"BanCheck", var);
    return 
1;

But, when I use this command, it gives me the error 'User does not exist'.
How to fix this? Please help me.
Reply
#2

pawn Код:
dcmd_unban(playerid, params[])
{
    new pName[128], string[128];

    GetPlayerName(playerid, pName, sizeof(pName));//you didn't added this

    if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_WHITE,"Server: Unrecognized command, type /commands to see the commands available for you.");
    if(PlayerInfo[playerid][pAdmin]<4) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This command is unavailable for your admin rank.");
    if(admduty[playerid]==0) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: You must be on duty to use this command.");
    if(sscanf(params, "s", pName)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /unban [username]");
    format(pName, sizeof(pName), "/Users/%s.ini", pName);
    if(!fexist(string)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This user does not exists.");
    SetPVarString(playerid, "UnbanName", pName);
    SetPVarInt(playerid, "BanCheck", 0);
    INI_ParseFile(string, "LoadBan_%s", .bExtra = true, .extra = playerid);
    if(GetPVarInt(playerid, "BanCheck")==0) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This user is not banned.");
    new INI:File = INI_Open(string);
    INI_SetTag(File, "data");
    INI_WriteInt(File, "Banned", 0);
    INI_Close(File);
    format(string, sizeof(string), "User %s has been unbanned.", pName);
    SendClientMessage(playerid, COLOR_ADMINBLUE, string);
    return 1;
}
EDIT: Ohh i missed out that!
Reply
#3

Quote:
Originally Posted by ginger
Посмотреть сообщение
pawn Код:
dcmd_unban(playerid, params[])
{
    new pName[128], string[128];

    GetPlayerName(playerid, pName, sizeof(pName));//you didn't added this

    if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_WHITE,"Server: Unrecognized command, type /commands to see the commands available for you.");
    if(PlayerInfo[playerid][pAdmin]<4) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This command is unavailable for your admin rank.");
    if(admduty[playerid]==0) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: You must be on duty to use this command.");
    if(sscanf(params, "s", pName)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /unban [username]");
    format(pName, sizeof(pName), "/Users/%s.ini", pName);
    if(!fexist(string)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This user does not exists.");
    SetPVarString(playerid, "UnbanName", pName);
    SetPVarInt(playerid, "BanCheck", 0);
    INI_ParseFile(string, "LoadBan_%s", .bExtra = true, .extra = playerid);
    if(GetPVarInt(playerid, "BanCheck")==0) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This user is not banned.");
    new INI:File = INI_Open(string);
    INI_SetTag(File, "data");
    INI_WriteInt(File, "Banned", 0);
    INI_Close(File);
    format(string, sizeof(string), "User %s has been unbanned.", pName);
    SendClientMessage(playerid, COLOR_ADMINBLUE, string);
    return 1;
}
I don't want to get the name of the player. See, correct usage is /unban [username]
Reply
#4

pawn Код:
dcmd_unban(playerid, params[])
{
    new pName[128], string[128];
    if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_WHITE,"Server: Unrecognized command, type /commands to see the commands available for you.");
    if(PlayerInfo[playerid][pAdmin]<4) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This command is unavailable for your admin rank.");
    if(admduty[playerid]==0) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: You must be on duty to use this command.");
    if(sscanf(params, "s", pName)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /unban [username]");

    format(string, sizeof(string), "/Users/%s.ini", pName);//use string instead of pName to store the whole value!

    if(!fexist(string)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This user does not exists.");
    SetPVarString(playerid, "UnbanName", pName);
    SetPVarInt(playerid, "BanCheck", 0);
    INI_ParseFile(string, "LoadBan_%s", .bExtra = true, .extra = playerid);
    if(GetPVarInt(playerid, "BanCheck")==0) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This user is not banned.");
    new INI:File = INI_Open(string);
    INI_SetTag(File, "data");
    INI_WriteInt(File, "Banned", 0);
    INI_Close(File);
    format(string, sizeof(string), "User %s has been unbanned.", pName);
    SendClientMessage(playerid, COLOR_ADMINBLUE, string);
    return 1;
}
Maybe this!
Reply
#5

I found out the problem it's in this line:
PHP код:
format(pNamesizeof(pName), "/Users/%s.ini"pName); 
Changed the first and second 'pName' to string and its working fine now. Anyway, thanks for trying to help.

EDIT:
Quote:
Originally Posted by ginger
Посмотреть сообщение
pawn Код:
dcmd_unban(playerid, params[])
{
    new pName[128], string[128];
    if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_WHITE,"Server: Unrecognized command, type /commands to see the commands available for you.");
    if(PlayerInfo[playerid][pAdmin]<4) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This command is unavailable for your admin rank.");
    if(admduty[playerid]==0) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: You must be on duty to use this command.");
    if(sscanf(params, "s", pName)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /unban [username]");

    format(string, sizeof(string), "/Users/%s.ini", pName);//use string instead of pName to store the whole value!

    if(!fexist(string)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This user does not exists.");
    SetPVarString(playerid, "UnbanName", pName);
    SetPVarInt(playerid, "BanCheck", 0);
    INI_ParseFile(string, "LoadBan_%s", .bExtra = true, .extra = playerid);
    if(GetPVarInt(playerid, "BanCheck")==0) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This user is not banned.");
    new INI:File = INI_Open(string);
    INI_SetTag(File, "data");
    INI_WriteInt(File, "Banned", 0);
    INI_Close(File);
    format(string, sizeof(string), "User %s has been unbanned.", pName);
    SendClientMessage(playerid, COLOR_ADMINBLUE, string);
    return 1;
}
Maybe this!
We two posted at the same time, I fixed it myself. Thanks for trying to help me.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)