20.10.2012, 20:13
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()
Ignore the sscanf buffer overflow for now, that was just caused by trying to load the password line, which is a ton of characters.
PHP код:
CMD:getmoney(playerid, params[])
{
if(isnull(params)) {
return SendClientMessage(playerid, -1, "Correct Usage: /getmoney [PlayerFile]");
}
new filename[MAX_PLAYER_NAME+18];
format(filename, sizeof(filename), "/Users/%s.ini", params);
if(!fexist(filename)) {
return SendClientMessage(playerid, -1, "That account doesn't exist!");
}
new
File:file = fopen(filename, io_read),
string[128],
Name[20],
Value[20],
cash;
while(fread(file, string)) {
if(!sscanf(string, "p<=>s[20]s[20]", Name, Value)) {
if(!strcmp(Name, "Cash ")) {
cash = strval(Value);
break;
}
}
}
format(string, sizeof(string), "Money from %s's account is $%d", params, cash);
SendClientMessage(playerid, -1, string);
return true;
}