new transferplayer;//this will store the playerid's wich has the inserted card number
if(dialogid==13)
{
if(response==0) return SendClientMessage(playerid,COLOR_RED,"Prijenos prekinut!");
if(response==1)
{
if(!strval(inputtext)) return SendClientMessage(playerid,COLOR_RED,"Krivi broj racuna!");//again,he can only insert a numeric value in order to avoid bugs/errors
else
{
new cardnum;
cardnum=strval(inputtext);
new OK=0;//this variable will tell us if there's any player with the inserted card number(1 YES,0 NO)
for(new i=0;i<MAX_PLAYERS;i++)//we start the loop
{
if(BankInfo[i][CardNumber]==cardnum)//we check the players cardnumber,if it's the same as the inserted one
{
transferplayer=i;//if yes,we store his ID,into the variable defined earlier
OK=1;//we make the OK variable 1(THERE IS SOMEONE with the inserted card)
break;//we stoop the loop
}
}
if(OK==0) SendClientMessage(playerid,COLOR_RED,"Korisnik nije konektiran ili je broj racuna krivi!");
else
{
ShowPlayerDialog(playerid,DIALOG_TRANSFERM, DIALOG_STYLE_INPUT, ""COL_SPLAVA"Cloud-Banka:"COL_BIJELA"Transfer", "Upisite sumu novca za "COL_SPLAVA"prebacivanje", "Prebaci", "Odustani");//we show the ACTUAL TRANSFER dialog
}
}
}
}
if(dialogid==14)
{
if(response==0) return SendClientMessage(playerid,COLOR_RED,"Transfer prekinut!");
if(response==1)
{
if(!strval(inputtext)) return SendClientMessage(playerid,COLOR_RED,"Kriva suma novca, pokusajte ponovo!");
else
{
new transmoney;
transmoney=strval(inputtext);//so we get the inserted ammount wich the player wishes to transfer
if(transmoney>BankInfo[playerid][DepositedMoney]) {SendClientMessage(playerid,COLOR_RED,"Nemas toliko novca na banci!");tShow[playerid]=0;}//the variable that stops the dialogs from overwriting is now 0,because it's like he exited the pickup ;)}//BUT,if his deposited ammount is smaller than the inserted ammount,then he won't be able to transfer money anymore
else
{
BankInfo[playerid][DepositedMoney]=BankInfo[playerid][DepositedMoney]-transmoney;//first we modify the actual player's deposited ammount
new INI:bFile=INI_Open(BankDB(playerid));//we open his file
INI_SetTag(bFile,"BankData");//we set the tag
INI_WriteInt(bFile,"DepositedMoney",BankInfo[playerid][DepositedMoney]);//we store the new deposited ammount
INI_Close(bFile);//we close the file
BankInfo[transferplayer][DepositedMoney]=BankInfo[transferplayer][DepositedMoney]+transmoney;//NOW we modify the deposited ammount OF the player that the money has been transfered TO
new INI:bFile2=INI_Open(BankDB(transferplayer));//we open HIS DataBase
INI_SetTag(bFile2,"BankData");//we set the tag
INI_WriteInt(bFile2,"DepositedMoney",BankInfo[transferplayer][DepositedMoney]);//we store the new ammount
INI_Close(bFile2);//and we close his file
new pName[24],pName2[24];//variables to store the player's name
GetPlayerName(transferplayer,pName2,sizeof(pName2));
GetPlayerName(playerid,pName,sizeof(pName));
new string[256],string2[256];//informative messages
format(string,sizeof(string),"Uspjesno prebaceno %d$ novca igracu %s!",transmoney,pName2);//we format the message wich will look like "Succesfully transfered 20$ to John"
SendClientMessage(playerid,COLOR_GREEN,string);//we inform the player
PlayerPlaySound(playerid,1057,0,0,0);
format(string2,sizeof(string2),"%s je uspjesno prebacio %d$ vama!",pName,transmoney);//again,informative messages
SendClientMessage(transferplayer,COLOR_GREEN,string2);
PlayerPlaySound(transferplayer,1057,0,0,0);//just a confirmation sound
tShow[playerid]=0;//again we make the variable that prevents dialogs from overwriting 0
}
}
}
}
YCMD:transfer(playerid, params[], help)
{
if(help)
{
SendClientMessage(playerid, 0xFF0000AA, "PRIMJER: /transfer");
}
else
{
if(PlayerInfo[playerid][pCardOwner]==0) return SendClientMessage(playerid,COLOR_RED,"Nemas bankovni racun,mozes ga otvoriti u banci za 500$!");
else if(IsPlayerInRangeOfPoint(playerid, 2.0, 1407.4142, 1319.5991, 1501.0840))
{
if(PlayerInfo[playerid][pCardOwner]==1)
{
if(tShow[playerid]==0)
{
tShow[playerid]=1;
ShowPlayerDialog(playerid,DIALOG_CARDCHECK,DIALOG_STYLE_INPUT,""COL_SPLAVA"Cloud-Banka:"COL_BIJELA"Transfer","Upisite kod kartice igraca:","OK","Cancel");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Moras biti u banci!");
}
}
}
return 1;
}
YCMD:racuninfo(playerid, params[], help)
{
if(help)
{
SendClientMessage(playerid, 0xFF0000AA, "PRIMJER: /racuninfo");
}
else
{
if(PlayerInfo[playerid][pCardOwner]==0) return SendClientMessage(playerid,COLOR_RED,"Nemas bankovni racun,mozes ga otvoriti u banci za 500$!");
else
{
new string[128];
format(string,sizeof(string),""COL_SIVA"Vlasnik Racuna:"COL_SPLAVA" %s"COL_SIVA"\nBroj Racuna: "COL_SPLAVA"%d"COL_SIVA"\nPolozeni Novac: "COL_ZELENA"%d",BankInfo[playerid][Owner],BankInfo[playerid][CardNumber],BankInfo[playerid][DepositedMoney]);//we format the string wich will contain the player's bank data
ShowPlayerDialog(playerid,DIALOG_CARDINFO,DIALOG_STYLE_MSGBOX,""COL_SPLAVA"Cloud-Banka:"COL_BIJELA"RacunInfo",string,"Uredu","Odustani");
}
}
return 1;
}
if(tShow[playerid]==0)
{
tShow[playerid]=1;
ShowPlayerDialog(playerid,DIALOG_CARDCHECK,DIALOG_STYLE_INPUT,""COL_SPLAVA"Cloud-Banka:"COL_BIJELA"Transfer","Upisite kod kartice igraca:","OK","Cancel");
}
|
pawn Код:
|