Basically, you need to load the user's current cash which can be achieved by using INI_ParseFile. You will then need to save this value to a new variable, which we will define at the top of the script. Feel free to change the name of the variable.
pawn Code:
new AdminCashRefund[MAX_PLAYERS] = {0, ...}; //At the top of your script
Then, when you want to refund cash, check if the player exists first...
pawn Code:
format(string, sizeof(string), "/JCNR/Users/%s.ini", HouseInfo[h][HouseOwner]); //Format the path
if(!fexist(string)) return SendClientMessage(playerid, -1, "Player does not exist."); //If the user doesn't exist...
Then get ready to load the cash to a variable assigned to the admin/playerid doing the refund.
pawn Code:
INI_ParseFile(string, "RefundUser_%s", .bExtra = true, .extra = playerid);
It will call the following function:
pawn Code:
forward RefundUser_UserData(playerid, name[], value[]);
public RefundUser_UserData(playerid, name[], value[])
{
INI_Int("Cash", AdminCashRefund[playerid]);
return 1;
}
The current value of 'Cash' will be saved to the variable 'AdminCashRefund[playerid]', where 'playerid' is the ID of the admin doing the refund.
Then you can process the refund...
pawn Code:
new INI:File = INI_Open(string);
INI_SetTag(File, "UserData");
INI_WriteInt(File, "Cash", AdminCashRefund[playerid] + Refund);
INI_Close(File);
So your final code would look like...
pawn Code:
new AdminCashRefund[MAX_PLAYERS] = {0, ...};
CMD:refund(playerid, params[])
{
//Stuff should be here...
format(string, sizeof(string), "/JCNR/Users/%s.ini", HouseInfo[h][HouseOwner]);
if(!fexist(string)) return SendClientMessage(playerid, -1, "Player does not exist.");
INI_ParseFile(string, "RefundUser_%s", .bExtra = true, .extra = playerid);
new INI:File = INI_Open(string);
INI_SetTag(File, "UserData");
INI_WriteInt(File, "Cash", AdminCashRefund[playerid] + Refund);
INI_Close(File);
return 1;
}
forward RefundUser_UserData(playerid, name[], value[]);
public RefundUser_UserData(playerid, name[], value[])
{
INI_Int("Cash", AdminCashRefund[playerid]);
return 1;
}
I've put it in a command called 'refund' just for exemplary purposes.