#1

Hello guys, the cmd always returns a message "Player is not found in the database." even when the player does exist.


PHP код:
UserPath(playerid)
{
    new 
string[75], pName[MAX_PLAYER_NAME];
    
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    
format(string, sizeof string, "/Users/%s.txt", pName);
    return 
string;
} 
PHP код:
CMD:unban(playerid, params[])
{
    if(
PlayerInfo[playerid][AdminLevel] < 1) return 0;
    if(
PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Error: You are not authorized to use this command.");
    new 
string[75], user[128];
    if(
sscanf(params, "s[128]", user)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /unban [playername]");
    
format(string, sizeof string, "/Users/%s.txt", user);
    if(
fexist(user))
    {
        new 
INI:File = INI_Open(user);
        
printf("Userfile opened");
        
INI_SetTag(File, "PlayerData");
        
INI_WriteInt(File, "Banned", 0);
        
printf("User unbanned");
        
INI_Close(File);
        
printf("File closed");
        
format(string, sizeof string, "You have succesfully unbanned the player.");
        
SendClientMessage(playerid, COLOR_YELLOW, string);
    }
    else
    {
        
SendClientMessage(playerid, COLOR_RED, "Error: The user is not found in the database!");
    }
    return 
1;
} 
Reply
#2

Replace
PHP код:
if(fexist(user)) 
With:
PHP код:
if(fexist(string)) 
Reply
#3

Thanks,
How do I add that, when the variable Banned == 0, it returns a message "player is not banned".
Reply


Forum Jump:


Users browsing this thread: