Reset Data
#1

What is the problem here. Why the command or the DoesAccountExist reset the data?
PHP код:
doesAccountExist(account_name[]) {
    new
        
sz_accStr[MAX_PLAYER_NAME 12];
    
format(sz_accStrsizeof(sz_accStr), "users/%s.db"account_name);
    if(
fexist(sz_accStr)) {
        new
            
Filef_Handle fopen(sz_accStrio_read);
        if(
flength(f_Handle) > 0) {
            
fclose(f_Handle);
            return 
1;
        }
        
fclose(f_Handle);
    }
    return 
0;

I have check it many time but cnaot find the soluation
PHP код:
CMD:unban(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= || PlayerInfo[playerid][pBanAppealer] >= 1)
    {
        new 
string[128];
        if(
isnull(params)) return SendClientMessageEx(playeridCOLOR_WHITE"USAGE: /unban [playername]");
        if(
doesAccountExist(params))
        {
            
OnPlayerOfflineLogin(params);
            if( 
PlayerInfo[MAX_PLAYERS][pPermaBanned] == )
            {
                
SendClientMessageExplayeridCOLOR_WHITE"Permanently banned accounts can only be unbanned via FTP." );
            }
            else
            {
                if( 
PlayerInfo[MAX_PLAYERS][pBanned] >= 0)
                {
                    
PlayerInfo[MAX_PLAYERS][pBanned] = 0;
                    
PlayerInfo[MAX_PLAYERS][pWarns] = 0;
                    
PlayerInfo[MAX_PLAYERS][pDisabled] = 0;
                    
RemoveBan(PlayerInfo[MAX_PLAYERS][pIP]);
                    print(
"OnPlayerOfflineLogin: Saving variables to file");
                    
OnPlayerOfflineSave(params);
                    print(
"OnPlayerOfflineLogin: Variables saved properly");
                    
format(string128"AdmCmd: %s (IP:%s) was unbanned by %s."paramsPlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid));
                    
ABroadCast(COLOR_LIGHTRED,string,2);
                    new 
yearmonth,day;
                    
getdate(yearmonthday);
                    
format(stringsizeof(string), "AdmCmd: %s (IP:%s) was unbanned by %s. (%d-%d-%d)"paramsPlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid),month,day,year);
                    
////Log("logs/ban.log", string);
                    
print(string);
                }
                else
                {
                    
SendClientMessageExplayeridCOLOR_WHITE"Not a banned account!" );
                }
            }
        }
        else
        {
            
SendClientMessageExplayeridCOLOR_WHITE"That account doesn't exist." );
        }
    }
    else
    {
        
SendClientMessageEx(playeridCOLOR_GRAD1"You are not authorized to use that command!");
    }
    return 
1;

Reply
#2

I don't see the point of opening the file and reading it. I think you can simply return 1 if the file exists or return 0 if not,

something like this should work;

PHP код:
doesAccountExist(account_name[])
{
    new
        
sz_accStr[MAX_PLAYER_NAME 12];

    
format(sz_accStrsizeof(sz_accStr), "users/%s.db"account_name);
    if(
fexist(sz_accStr))
    {
        return 
1//File exist
    
}
    else return 
0// No file found

Reply
#3

doesAccountExist(account_name[]) {

new
sz_accStr[MAX_PLAYER_NAME + 12];

format(sz_accStr, sizeof(sz_accStr), "users/%s.db", account_name);
if(fexist(sz_accStr)) {

new
File: f_Handle = fopen(sz_accStr, io_read);

if(flength(f_Handle) > 0) {
fclose(f_Handle);
return 1;
}
fclose(f_Handle);
}
return 0;
}
Reply
#4

Bump I need help ASAP, need to update the script
Reply
#5

You don't have to read it in case if you're writing data properly inside the file or unless player files are generated without registering. Simply use the function fexist to know if a player file exist or not.

Here's your answer already:
Quote:
Originally Posted by Sjn
Посмотреть сообщение
PHP код:
doesAccountExist(account_name[])
{
    new
        
sz_accStr[MAX_PLAYER_NAME 12];
    
format(sz_accStrsizeof(sz_accStr), "users/%s.db"account_name);
    if(
fexist(sz_accStr))
    {
        return 
1//File exist
    
}
    else return 
0// No file found

Reply
#6

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
You don't have to read it in case if you're writing data properly inside the file or unless player files are generated without registering. Simply use the function fexist to know if a player file exist or not.

Here's your answer already:
I have put Fexist. You can check on first
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)