Name is bugged with my /transfer command
#1

Fixed!
Reply
#2

You were obtaining the player's name before the player's id was found.
pawn Код:
CMD:transfer(playerid, params[])
{
    new target, amount;
    if(sscanf(params, "ui", target, amount)) return SendClientMessage(playerid, COLOR_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(target == playerid) return SendClientMessage(playerid, COLOR_RED, "[ ERROR: You can't transfer to yourself! ]");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_RED, "[ ERROR: Player is not connected! ]");
    if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2316.2041,-4.6539,26.7422)) return SendClientMessage(playerid, COLOR_RED, "[ ERROR: You are not inside a bank or on a counter checkpoint! ]");

    new string[256], name[MAX_PLAYER_NAME], TargetName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(target, TargetName, sizeof(name));
    format(file,sizeof(file),PlayerFile,name);

    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:file1=fopen("/Database/Logs/BankTransferLog.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 received $%d from %s to his/her bank account via bank and the new bank balance was $%d ]\r\n", day, month, year, hour, minute, second, TargetName, amount, name, pInfo[target][BankCash]);
    fwrite(file1, string);
    fclose(file1);
    return 1;
}
Reply
#3

Fixed!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)