Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Basic Bids System
- * 13/3/2017 last update
- * Need includes:
- - foreach 3.0
- - formatnumber
- */
- #define public::%0(%1) forward%0(%1); public%0(%1)
- new lastUser[MAX_PLAYER_NAME],
- lastPrice = -1,
- bidsID = -1,
- bidsTimer = -1,
- bidsCountTimer = 120,
- bidsName[64],
- bidsPrice = -1,
- isActiveBid[MAX_PLAYERS] = -1;
- public OnPlayerConnect(playerid)
- {
- isActiveBid[playerid] = -1;
- return 1;
- }
- public:: Bids(bidName[], bidPrice, playerid) {
- new y,
- m,
- d,
- szString[255];
- new bzname = strlen(bidName);
- getdate(y, m, d);
- if(d == 13)
- {
- if(bzname < 1) strcat(bidsName, "Unknow", 64);
- if(bzname > 1) strcat(bidsName, bidName, 64);
- bidsPrice = bidPrice;
- bidsID ++;
- format(szString, sizeof(szString), "Bussines {90C3D4}%s {FFFFFF}a fost scos la vanzare la pretul de {90C3D4}$%s.", bidsName, FormatNumber(bidsPrice));
- foreach(new i : Player) {
- SendClientMessage(i, -1, "------------------------------------------------");
- SendClientMessage(i, -1, "O noua licitatie a inceput, mai jos avetii infomatiile necesare:");
- SendClientMessage(i, -1, "");
- SendClientMessage(i, -1, szString);
- SendClientMessage(i, -1, "Pentru a licita foloseste /bid <price>");
- SendClientMessage(i, -1, "Licitatiile se incheie automat dupa 2 minute !");
- SendClientMessage(i, -1, "------------------------------------------------");
- bidsTimer = SetTimerEx("EndActiveBids", 1000, true, "dd", bidsID, playerid);
- }
- }
- return 1;
- }
- public:: EndActiveBids(bidID, playerid) {
- if(bidsCountTimer > 0) bidsCountTimer --;
- if(bidsCountTimer == 60)
- {
- new szString[128];
- foreach(new i : Player) {
- SendClientMessage(i, -1, "------------------------------------------------");
- format(szString, sizeof(szString), "Licitatia cu ID(#%d) este activa, puteti licita", bidsID);
- SendClientMessage(i, -1, szString);
- format(szString, sizeof(szString), "Ultimul player care a licitat este %s cu suma de $%s.", lastUser, FormatNumber(lastPrice));
- SendClientMessage(i, -1, szString);
- SendClientMessage(i, -1, "Au mai ramas 1 minute pana licitatia se inchide.");
- SendClientMessage(i, -1, "------------------------------------------------");
- }
- }
- if(bidsCountTimer == 0) {
- new szString[128];
- if(!strcmp(lastUser, "No One")) {
- foreach(new i : Player) {
- SendClientMessage(i, -1, "------------------------------------------------");
- format(szString, sizeof(szString), "Licitatia cu ID #%d a fost anulata", bidsID);
- SendClientMessage(i, -1, szString);
- format(szString, sizeof(szString), "Nici un player nu a licitat pentru acest bussines !");
- SendClientMessage(i, -1, szString);
- SendClientMessage(i, -1, "------------------------------------------------");
- }
- } else {
- foreach(new i : Player) {
- SendClientMessage(i, -1, "------------------------------------------------");
- format(szString, sizeof(szString), "Licitatia cu ID #%d a fost finalizata", bidsID);
- SendClientMessage(i, -1, szString);
- format(szString, sizeof(szString), "Ultimul player care a licitat este {90C3D4}%s {FFFFFF}cu suma de {90C3D4}$%s.", lastUser, FormatNumber(lastPrice));
- SendClientMessage(i, -1, szString);
- SendClientMessage(i, -1, "------------------------------------------------");
- }
- }
- lastUser = "No One";
- bidsName = "No One";
- bidsID = -1;
- bidsCountTimer = -1;
- bidsPrice = -1;
- lastPrice = -1;
- KillTimer(bidsTimer);
- bidsTimer = -1;
- }
- return 1;
- }
- CMD:startbids(playerid, params[]) {
- new bidName[64], bidPrice;
- if(sscanf(params, "s[64]d", bidName, bidPrice)) return ErrorCMD(playerid);
- CallRemoteFunction("Bids", "si", bidName, bidPrice);
- return 1;
- }
- CMD:bid(playerid, params[]) {
- new suma, nume[MAX_PLAYER_NAME];
- GetPlayerName(playerid, nume, MAX_PLAYER_NAME);
- if(sscanf(params, "i", suma)) return SCM(playerid, -1, "Usage: /bid <Price>");
- if(bidsID < 0) return SCM(playerid, -1, "ERROR: Nu este o licitatie activa ");
- if(GetPlayerMoney(playerid) < bidsPrice) return SCM(playerid, -1, "ERROR: Nu detii destui bani pentru a licita.");
- if(suma > GetPlayerMoney(playerid)) return SCM(playerid, -1, "ERROR: Nu detii destui bani pentru a licita.");
- if(suma < bidsPrice) return SCM(playerid, -1, "ERROR: Nu detii destui bani pentru a licita.");
- if(suma < lastPrice[playerid]) return SCM(playerid, -1, "ERROR: Nu detii destui bani pentru a licita.");
- isActiveBid[playerid] = 1;
- lastPrice[playerid] = suma;
- lastUser[playerid] = nume;
- GivePlayerMoney(playerid, -suma);
- new szString[128];
- if(isActiveBid[playerid] == 1)
- {
- foreach(new i : Player) {
- format(szString, sizeof(szString), "{6649CC}%s a licitat pentru bussines %s suma de $%s", lastUser[playerid], bidsName, FormatNumber(lastPrice[playerid]));
- SendClientMessage(i, -1, szString);
- }
- }
- return 1;
- }
- CMD:togbid(playerid, params[]) {
- if(isActiveBid[playerid] <= 0) {
- isActiveBid[playerid] = 1;
- SCM(playerid, -1, "{6649CC} Acum esti spectator pe o licitatie activa !");
- } else {
- isActiveBid[playerid] = 0;
- SCM(playerid, -1, "{6649CC} Acum nu mai esti spectator pe o licitatie !");
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement