When a player types /transfer to Show Dialog,Type player's ID, than, Type How much money to transfer all in dialog, ho will help me +REP !
Код:
if(strcmp(cmd, "/transfer", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pLevel] < 3)
{
SendClientMessage(playerid, COLOR_GRAD1, "Morate biti level 3!");
return 1;
}
if(PlayerInfo[playerid][pLocal] != 103)
{
SendClientMessage(playerid, COLOR_GREY, "Niste u banci!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "Koristi: /transfer [ID Igraca] [kolicina]");
return 1;
}
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "Koristi: /transfer [ID Igraca] [kolicina]");
return 1;
}
moneys = strval(tmp);
if (IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerNameEx(playerid, sendername, sizeof(sendername));
playermoney = PlayerInfo[playerid][pAccount] ;
if (moneys > 0 && playermoney >= moneys)
{
PlayerInfo[playerid][pAccount] -= moneys;
PlayerInfo[giveplayerid][pAccount] += moneys;
format(string, sizeof(string), "Prebacili ste $%d na %s-ev racun", moneys, giveplayer,giveplayerid);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
SendClientMessage(playerid, COLOR_GRAD1, string);
format(string, sizeof(string), "Primili ste $%d na vas racun od %s-a", moneys, sendername, playerid);
SendClientMessage(giveplayerid, COLOR_GRAD1, string);
format(string, sizeof(string), "Igracot %s prefrli $%d na %s (/transfer)", sendername, moneys, giveplayer);
if(moneys >= 10000)
{
ABroadCast(COLOR_YELLOW,string,1);
}
printf("%s", string);
PayLog(string);
PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Nepravilan iznos!");
}
}
}
else
{
format(string, sizeof(string), "%d nije aktivan igrac.", giveplayerid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
return 1;
}
pawn Код:
//---Constants
#define DIALOG_RECEIVER 1996
#define DIALOG_SEND 6969
new ReceiverFixed[MAX_PLAYERS] = INVALID_PLAYER_ID;
//---Command
if(strcmp(cmd, "/transfer", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessage(playerid, COLOR_GRAD1, "Morate biti level 3!");
if(PlayerInfo[playerid][pLocal] != 103) return SendClientMessage(playerid, COLOR_GREY, "Niste u banci!");
ShowPlayerDialog(playerid,DIALOG_RECEIVER,DIALOG_STYLE_INPUT,"Receiver ID","Type the ID of the receiver below:","Next","Exit");
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_RECEIVER)
{
if(response)
{
if(isNumeric(inputtext))
{
if(inputtext != INVALID_PLAYER_ID)
{
ReceiverFixed[playerid] = strval(inputtext);
ShowPlayerDialog(playerid,DIALOG_SEND,DIALOG_STYLE_INPUT,"How much","How much money do you want send?","Send","Back");
} else {
SendClientMessage(playerid, COLOR_GRAD1, "Nepravilan iznos!");
ShowPlayerDialog(playerid,DIALOG_RECEIVER,DIALOG_STYLE_INPUT,"Receiver ID","Type the ID of the receiver below:","Next","Exit");
}
} else {
SendClientMessage(playerid,-1,"Letters aren't allowed, just numbers!");
ShowPlayerDialog(playerid,DIALOG_RECEIVER,DIALOG_STYLE_INPUT,"Receiver ID","Type the ID of the receiver below:","Next","Exit");
}
} else { ReceiverFixed[playerid] = INVALID_PLAYER_ID; }
return 1;
}
if(dialogid == DIALOG_SEND)
{
if(response)
{
if(isNumeric(inputtext))
{
GetPlayerName(ReceiverFixed[playerid], giveplayer, sizeof(giveplayer));
GetPlayerNameEx(playerid, sendername, sizeof(sendername));
playermoney = PlayerInfo[playerid][pAccount] ;
if (inputtext > 0 && playermoney >= inputtext)
{
PlayerInfo[playerid][pAccount] -= strval(inputtext);
PlayerInfo[ReceiverFixed[playerid]][pAccount] += strval(inputtext);
format(string, sizeof(string), "Prebacili ste $%d na %s-ev racun", inputtext, giveplayer,ReceiverFixed[playerid]);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
SendClientMessage(playerid, COLOR_GRAD1, string);
format(string, sizeof(string), "Primili ste $%d na vas racun od %s-a", inputtext, sendername, playerid);
SendClientMessage(ReceiverFixed[playerid], COLOR_GRAD1, string);
format(string, sizeof(string), "Igracot %s prefrli $%d na %s (/transfer)", sendername, inputtext, giveplayer);
if(inputtext >= 10000)
{
ABroadCast(COLOR_YELLOW,string,1);
}
printf("%s", string);
PayLog(string);
PlayerPlaySound(ReceiverFixed[playerid], 1052, 0.0, 0.0, 0.0);
ReceiverFixed[playerid] = INVALID_PLAYER_ID;
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Nepravilan iznos!");
ShowPlayerDialog(playerid,DIALOG_SEND,DIALOG_STYLE_INPUT,"How much","How much money do you want send?","Send","Back");
}
}
} else {
ReceiverFixed[playerid] = INVALID_PLAYER_ID;
ShowPlayerDialog(playerid,DIALOG_RECEIVER,DIALOG_STYLE_INPUT,"Receiver ID","Type the ID of the receiver below:","Next","Exit");
}
return 1;
}
return 0;
}
//---isNumeric function.
isNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}