CMD:wiretransfer(playerid, params[])
{
if(PlayerInfo[playerid][pLevel] < 3)
{
SendClientMessageEx(playerid, COLOR_GRAD1, " You must be at least level 3!");
return 1;
}
if(!IsPlayerInRangeOfPoint(playerid, 15.0, 2308.7346, -11.0134, 26.7422))
{
SendClientMessageEx(playerid, COLOR_GREY, "you are not in a bank");
return 1;
}
if(PlayerInfo[playerid][pCash] < 0 || PlayerInfo[playerid][pAccount] < 0)
{
SendClientMessageEx(playerid, COLOR_GRAD1, "Your cash on-hand or in the bank is currently at a negative value!");
return 1;
}
if(gettime()-GetPVarInt(playerid, "LastTransaction") < 10) return SendClientMessageEx(playerid, COLOR_GRAD2, "Wait 10s !");
if(PlayerInfo[playerid][pFreezeBank] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "The Bank Is Close now");
new string[128], giveplayerid, amount;
if(sscanf(params, "ud", giveplayerid, amount)) return SendClientMessageEx(playerid, COLOR_GREY, "SU DUNG: /wiretransfer [player] [amount]");
if (IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(gPlayerLogged{giveplayerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "* Player Could Be Offline!");
new playermoney = PlayerInfo[playerid][pAccount] ;
if (amount > 0 && playermoney >= amount)
{
GivePlayerCashEx(playerid, TYPE_BANK, -amount);
GivePlayerCashEx(giveplayerid, TYPE_BANK, amount);
/*PlayerInfo[playerid][pAccount] -= amount;
PlayerInfo[giveplayerid][pAccount] += amount;*/
format(string, sizeof(string), " You have send $%s for account %s's.", number_format(amount), GetPlayerNameEx(giveplayerid),giveplayerid);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
SendClientMessageEx(playerid, COLOR_GRAD1, string);
format(string, sizeof(string), " You have recive $%s into your account %s.", number_format(amount), GetPlayerNameEx(playerid), playerid);
SendClientMessageEx(giveplayerid, COLOR_GRAD1, string);
new ip[32], ipex[32];
GetPlayerIp(playerid, ip, sizeof(ip));
GetPlayerIp(giveplayerid, ipex, sizeof(ipex));
format(string, sizeof(string), "[BANK] %s (IP:%s) da chuyen $%s den %s (IP:%s).", GetPlayerNameEx(playerid), ip, number_format(amount), GetPlayerNameEx(giveplayerid), ipex);
if(amount >= 500000)
{
ABroadCast(COLOR_YELLOW,string,2);
}
Log("logs/pay.log", string);
PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
SetPVarInt(playerid, "LastTransaction", gettime());
/*OnPlayerStatsUpdate(playerid);
OnPlayerStatsUpdate(giveplayerid);*/
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD1, " Amount Error.");
}
}
}
else SendClientMessageEx(playerid, COLOR_GRAD1, "Player Could Be offline.");
return 1;
}
|
Information
Clearly you have no taken the time to check the tutorial section? There are plenty of tutorials that show you exactly how to do what you are asking. Create a Dialog |
#define DIALOG_WIRETRANSFER_PLAYER 1
#define DIALOG_WIRETRANSFER_AMOUNT 2
CMD:wiretransfer(playerid, params[])
{
if(PlayerInfo[playerid][pLevel] < 3)
{
SendClientMessageEx(playerid, COLOR_GRAD1, " You must be at least level 3!");
return 1;
}
if(!IsPlayerInRangeOfPoint(playerid, 15.0, 2308.7346, -11.0134, 26.7422))
{
SendClientMessageEx(playerid, COLOR_GREY, "you are not in a bank");
return 1;
}
if(PlayerInfo[playerid][pCash] < 0 || PlayerInfo[playerid][pAccount] < 0)
{
SendClientMessageEx(playerid, COLOR_GRAD1, "Your cash on-hand or in the bank is currently at a negative value!");
return 1;
}
if(gettime()-GetPVarInt(playerid, "LastTransaction") < 10) return SendClientMessageEx(playerid, COLOR_GRAD2, "Wait 10s !");
if(PlayerInfo[playerid][pFreezeBank] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "The Bank Is Close now");
ShowPlayerDialog(playerid, DIALOG_WIRETRANSFER_PLAYER, DIALOG_STYLE_INPUT, "Wire Transfer", "Please put the valid playerid", "Procced", "Cancel");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new string[150];
if(dialogid == DIALOG_WIRETRANSFER_PLAYER)
{
if(response) // If they clicked 'Yes' or pressed enter
{
new giveplayerid = strval(inputtext);
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_RED, "Error: Inactive userid!");
SetPVarInt(playerid, "PlayerSelected", giveplayerid);
ShowPlayerDialog(playerid, DIALOG_WIRETRANSFER_AMOUNT, DIALOG_STYLE_INPUT, "Wire Transfer", "Please put the amount of money", "Transfer", "Cancel");
}
}
if(dialogid == DIALOG_WIRETRANSFER_AMOUNT)
{
if(response) // If they clicked 'Yes' or pressed enter
{
new amount = strval(inputtext);
new giveplayerid = GetPVarInt(playerid, "PlayerSelected");
new playermoney = PlayerInfo[playerid][pAccount] ;
if (amount < 1 && playermoney < amount) return SendClientMessageEx(playerid, COLOR_GRAD1, " Amount Error.");
GivePlayerCashEx(playerid, TYPE_BANK, -amount);
GivePlayerCashEx(giveplayerid, TYPE_BANK, amount);
PlayerInfo[playerid][pAccount] -= amount;
PlayerInfo[giveplayerid][pAccount] += amount;
format(string, sizeof(string), " You have send $%s for account %s's.", number_format(amount), GetPlayerNameEx(giveplayerid),giveplayerid);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
SendClientMessageEx(playerid, COLOR_GRAD1, string);
format(string, sizeof(string), " You have recive $%s into your account %s.", number_format(amount), GetPlayerNameEx(playerid), playerid);
SendClientMessageEx(giveplayerid, COLOR_GRAD1, string);
new ip[32], ipex[32];
GetPlayerIp(playerid, ip, sizeof(ip));
GetPlayerIp(giveplayerid, ipex, sizeof(ipex));
format(string, sizeof(string), "[BANK] %s (IP:%s) da chuyen $%s den %s (IP:%s).", GetPlayerNameEx(playerid), ip, number_format(amount), GetPlayerNameEx(giveplayerid), ipex);
if(amount >= 500000)
{
ABroadCast(COLOR_YELLOW,string,2);
}
Log("logs/pay.log", string);
PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
SetPVarInt(playerid, "LastTransaction", gettime());
}
}
return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}