Jump to content
Prosíme všetkých užívateľov, ktorý sa chcú opätovne pripojiť na discord aby znovu spárovali svoje účty kliknutím na "Discord" v navigácií a pripojili sa na server Read more... ×
  • 0
Honles

pomoc Chcem System Banka

Dotaz

10 odpovědí na tuto otázku

Recommended Posts

  • 0
#include <a_samp>
#include <izcmd>
#include <dof2>

#define r "{FF0000}"
#define w "{FFFFFF}"
#define g "{00FF00}"

#define DIALOG_BANKA 500

#pragma unused DOF2_Exit

new Banka[MAX_PLAYERS];

CMD:banka(playerid){
	new String[150];
	format(String,sizeof(String),""w"Vložiť peniaze\nVybrať peniaze\nVložiť všetko ("g"%s$"w")\nVybrať všetko ("g"%s$"w")\n",Split(GetPlayerMoney(playerid)),Split(Banka[playerid]));
	ShowPlayerDialog(playerid,DIALOG_BANKA,DIALOG_STYLE_LIST,"Banka",String,"Vybrať","Zavrieť");
	return 1;
}

public OnPlayerConnect(playerid){
	Banka[playerid] = 0,Load(playerid);
 	return 1;
}
public OnPlayerDisconnect(playerid){
	Save(playerid);
	return 1;
}

public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[]){
	if(dialogid == DIALOG_BANKA){
	    if(response){
	        switch(listitem){
	            case 0: VlozitPeniaze(playerid);
				case 1: VybratPeniaze(playerid);
				case 2: VlozitVsetko(playerid);
				case 3: VybratVsetko(playerid);
			}
		}
		return 1;
	}else if(dialogid == DIALOG_BANKA+1){
	    if(response){
			new Ciastka = strval(inputtext),String[100];
 			format(String,sizeof(String),"Napíš čiastku ktorú chceš vložiť na svoj účet. U seba máš "g"%s"w".\n",Split(GetPlayerMoney(playerid)));
  			if(!strval(inputtext)) return ShowPlayerDialog(playerid,DIALOG_BANKA+1,DIALOG_STYLE_INPUT,"Banka - Vložiť peniaze",String,"Vložiť","Zavrieť");
			else if(Banka[playerid] > 2000000000) return SendClientMessage(playerid,0xFF0000FF,"[ ! ] "w"Nemôžeš mať v banke viac než "g"2.000.000.000$"w".");
			else if(Ciastka < 1 || GetPlayerMoney(playerid) < Ciastka) return SendClientMessage(playerid,0xFF0000FF,"[ ! ] "w"Zadal si neplatnú čiastku.");
			else if(Banka[playerid] < 1) Banka[playerid] = 0;
			Banka[playerid] = Ciastka + Banka[playerid];
			GivePlayerMoney(playerid, -Ciastka);
			format(String,sizeof(String),"Vložil si "g"%s$ "w"na svoj účet, v banke máš celkom "g"%s$"w".",Split(Ciastka),Split(Banka[playerid]));
			SendClientMessage(playerid,-1,String);
		}
		return 1;
	}else if(dialogid == DIALOG_BANKA+2){
	    if(response){
			new Ciastka = strval(inputtext),String[100];
 			format(String,sizeof(String),"Napíš čiastku ktorú chceš vybrať zo svojho účtu. V Banke máš "g"%s"w".\n",Split(Banka[playerid]));
  			if(!strval(inputtext)) return ShowPlayerDialog(playerid,DIALOG_BANKA+2,DIALOG_STYLE_INPUT,"Banka - Vybrať peniaze",String,"Vložiť","Zavrieť");
			else if(Banka[playerid] > 2000000000) return SendClientMessage(playerid,0xFF0000FF,"[ ! ] "w"Nemôžeš mať v banke viac než "g"2.000.000.000$"w".");
			else if(Ciastka < 1 || Banka[playerid] < Ciastka) return SendClientMessage(playerid,0xFF0000FF,"[ ! ] "w"Zadal si neplatnú čiastku.");
			else if(Banka[playerid] < 1) Banka[playerid] = 0;
			Banka[playerid] = Ciastka - Banka[playerid];
			GivePlayerMoney(playerid, Ciastka);
			format(String,sizeof(String),"Vybral si "g"%s$ "w"zo svojho účtu, v banke máš celkom "g"%s$"w".",Split(Ciastka),Split(Banka[playerid]));
			SendClientMessage(playerid,-1,String);
		}
		return 1;
	}
	return 1;
}

stock VlozitPeniaze(playerid){
	new String[200];
 	format(String,sizeof(String),"Napíš čiastku ktorú chceš vložiť na svoj účet. U seba máš "g"%s"w".\n",Split(GetPlayerMoney(playerid)));
  	ShowPlayerDialog(playerid,DIALOG_BANKA+1,DIALOG_STYLE_INPUT,"Banka - Vložiť peniaze",String,"Vložiť","Zavrieť");
}
stock VybratPeniaze(playerid){
	new String[200];
 	format(String,sizeof(String),"Napíš čiastku ktorú chceš vybrať zo svojho účtu. V banke máš "g"%s"w".\n",Split(Banka[playerid]));
  	ShowPlayerDialog(playerid,DIALOG_BANKA+2,DIALOG_STYLE_INPUT,"Banka - Vybrať peniaze",String,"Vybrať","Zavrieť");
}
stock VlozitVsetko(playerid){
	new Ciastka = GetPlayerMoney(playerid),String[100];
	if(Banka[playerid] < 1) Banka[playerid] = 0;
	else if(Ciastka < 1 || Banka[playerid] < Ciastka) return SendClientMessage(playerid,0xFF0000FF,"[ ! ] "w"Zadal si neplatnú čiastku.");
	Banka[playerid] = Ciastka + Banka[playerid];
	GivePlayerMoney(playerid, -Ciastka);
	format(String,sizeof(String),"[ ! ] "w"Vložil si "g"%s$ "w"na svoj účet, v banke máš celkom "g"%s$"w".",Split(Ciastka),Split(Banka[playerid]));
	SendClientMessage(playerid,0xFF0000FF,String);
	return 1;
}
stock VybratVsetko(playerid){
	new Ciastka = Banka[playerid],String[100];
	if(Banka[playerid] < 1) Banka[playerid] = 0;
	else if(Ciastka < 1 || Banka[playerid] < Ciastka) return SendClientMessage(playerid,0xFF0000FF,"[ ! ] "w"Zadal si neplatnú čiastku.");
	Banka[playerid] = Banka[playerid] -Ciastka;
	GivePlayerMoney(playerid,Ciastka);
	format(String,sizeof(String),"[ ! ] "w"Vybral si "g"%s$ "w"zo svojho účtu, v banke máš celkom "g"%s$"w".",Split(Ciastka),Split(Banka[playerid]));
	SendClientMessage(playerid,0xFF0000FF,String);
	return 1;
}
stock Split(Number, Type = 0){
	new String[16],Split_[2];
	if(Type == 0) Split_[0] = '.';
	else if(Type == 1) Split_[0] = ' ';
	else if(Type == 2) Split_[0] = ',';
	format(String,sizeof(String),"%d",Number);
	if(Number >= 1000) strins(String,Split_,strlen(String)-3, sizeof(String));
	if(Number >= 1000000) strins(String,Split_,strlen(String)-7, sizeof(String));
	if(Number >= 1000000000) strins(String,Split_,strlen(String)-11, sizeof(String));
	return String;
}
stock Save(playerid){
	Banka[playerid] = DOF2_GetInt(USER_FILES(playerid),"Banka");
  	DOF2_SaveFile();
}
stock Load(playerid){
  	if(fexist(USER_FILES(playerid))) DOF2_CreateFile(USER_FILES(playerid));
	DOF2_SetInt(USER_FILES(playerid),"Banka",Banka[playerid]);
}
stock Meno(playerid){
	new pName[MAX_PLAYER_NAME+1];
	GetPlayerName(playerid,pName,sizeof(pName));
	return pName;
}
stock USER_FILES(playerid){
	new pFile[32];
	format(pFile,sizeof(pFile),"Ucty/%s.ini",Meno(playerid));
	return pFile;
}
Edited by Affan

Sdílet tento příspěvek


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×