13.03.2015, 17:00
(
Последний раз редактировалось Sc0pion; 14.03.2015 в 20:21.
)
Fixed!
CMD:transfer(playerid, params[])
{
new target, amount;
new name[MAX_PLAYER_NAME], TargetName[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); GetPlayerName(target, TargetName, sizeof(name)); format(file,sizeof(file),PlayerFile,name);
if(sscanf(params, "ui", target, amount)) return SendClientMessage(playerid, LIGHTBLUE, "[ ERROR: /transfer (name/id) (amount) ]");
if(amount <= 0) return SendClientMessage(playerid,COLOR_RED,"[ ERROR: You have to transfer atleast $1! ]");
if(amount > pInfo[playerid][BankCash]) return SendClientMessage(playerid,COLOR_RED,"[ ERROR: You dont have that much cash in the bank! ]");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_RED, "[ ERROR: Player is not online! ]");
if(target == playerid) return SendClientMessage(playerid, COLOR_RED, "[ ERROR: You can't transfer to yourself! ]");
if(IsInBank[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "[ ERROR: You are not inside a bank! ]");
new string[128];
pInfo[playerid][BankCash] -= amount;
pInfo[target][BankCash] += amount;
format(string,sizeof(string),"[ BANK: You have successfully transfered $%d to %s's bank account. ]",amount,TargetName);
SendClientMessage(playerid,COLOR_BANK,string);
dini_IntSet(file,"BankCash",pInfo[playerid][BankCash]);
format(string,sizeof(string),"[ BANK: And your new balance is: $%d ]",pInfo[playerid][BankCash]);
SendClientMessage(playerid,COLOR_BANK,string);
format(string,sizeof(string),"[ BANK: %s has deposited $%d into your bank account. ]",name,amount);
SendClientMessage(target,COLOR_BANK,string);
format(string,sizeof(string),"[ BANK: And your new bank balance is: $%d ]",pInfo[target][BankCash]);
SendClientMessage(target,COLOR_BANK,string);
new File:filee=fopen("/Database/Logs/BankLog.log", io_append), hour, minute, second, year, month, day;
gettime(hour, minute, second);
getdate(year, month, day);
format(string, sizeof(string), "[%d/%d/%d | %d:%d:%d] [ %s to %s: %s ] [ %s has received $%d from %s through bank and his/her new bank balance is $%d ]\r\n", day, month, year, hour, minute, second, TargetName, amount, name, pInfo[target][BankCash]);
fwrite(filee, string);
fclose(filee);
return 1;