How To Read Something From an Offline User's Account in YINI?
#7

Tested and works for me, you had to account for those extra spaces that y_ini inputs when writing files. Also, instead of using sscanf for one parameter, you can just use isnull()
PHP код:
CMD:getmoney(playeridparams[])
{
   
    if(
isnull(params)) {
        return 
SendClientMessage(playerid, -1"Correct Usage: /getmoney [PlayerFile]");
    }
    
    new 
filename[MAX_PLAYER_NAME+18];
    
format(filenamesizeof(filename), "/Users/%s.ini"params);
    
    if(!
fexist(filename)) {
        return 
SendClientMessage(playerid, -1"That account doesn't exist!");
    }
        
    new 
        
File:file fopen(filenameio_read),
        
string[128],
        
Name[20],
        
Value[20],
        
cash;
        
    while(
fread(filestring)) {
        if(!
sscanf(string"p<=>s[20]s[20]"NameValue)) {
            if(!
strcmp(Name"Cash ")) {
                
cash strval(Value);
                break;
            }
        }
    }
    
format(stringsizeof(string), "Money from %s's account is $%d"paramscash);
    
SendClientMessage(playerid, -1string);
    return 
true;

Ignore the sscanf buffer overflow for now, that was just caused by trying to load the password line, which is a ton of characters.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)