Advertisement
SSYT

[Basic System] Licitatii

Mar 13th, 2017
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.09 KB | None | 0 0
  1. /*
  2. * Basic Bids System
  3. * 13/3/2017 last update
  4. * Need includes:
  5.     - foreach 3.0
  6.     - formatnumber
  7. */
  8.  
  9. #define public::%0(%1) forward%0(%1); public%0(%1)
  10.  
  11. new lastUser[MAX_PLAYER_NAME],
  12.     lastPrice = -1,
  13.     bidsID = -1,
  14.     bidsTimer = -1,
  15.     bidsCountTimer = 120,
  16.     bidsName[64],
  17.     bidsPrice = -1,
  18.     isActiveBid[MAX_PLAYERS] = -1;
  19.  
  20. public OnPlayerConnect(playerid)
  21. {
  22.     isActiveBid[playerid] = -1;
  23.     return 1;
  24. }
  25.  
  26. public:: Bids(bidName[], bidPrice, playerid) {
  27.     new y,
  28.     m,
  29.     d,
  30.     szString[255];
  31.     new bzname = strlen(bidName);
  32.     getdate(y, m, d);
  33.     if(d == 13)
  34.     {
  35.         if(bzname < 1) strcat(bidsName, "Unknow", 64);
  36.         if(bzname > 1) strcat(bidsName, bidName, 64);
  37.         bidsPrice = bidPrice;
  38.         bidsID ++;
  39.         format(szString, sizeof(szString), "Bussines {90C3D4}%s {FFFFFF}a fost scos la vanzare la pretul de {90C3D4}$%s.", bidsName, FormatNumber(bidsPrice));
  40.         foreach(new i : Player) {
  41.             SendClientMessage(i, -1, "------------------------------------------------");
  42.             SendClientMessage(i, -1, "O noua licitatie a inceput, mai jos avetii infomatiile necesare:");
  43.             SendClientMessage(i, -1, "");
  44.             SendClientMessage(i, -1, szString);
  45.             SendClientMessage(i, -1, "Pentru a licita foloseste /bid <price>");
  46.             SendClientMessage(i, -1, "Licitatiile se incheie automat dupa 2 minute !");
  47.             SendClientMessage(i, -1, "------------------------------------------------");
  48.             bidsTimer = SetTimerEx("EndActiveBids", 1000, true, "dd", bidsID, playerid);
  49.         }
  50.     }
  51.     return 1;
  52. }
  53.  
  54. public:: EndActiveBids(bidID, playerid) {
  55.     if(bidsCountTimer > 0) bidsCountTimer --;
  56.     if(bidsCountTimer == 60)
  57.     {
  58.         new szString[128];
  59.         foreach(new i : Player) {
  60.             SendClientMessage(i, -1, "------------------------------------------------");
  61.             format(szString, sizeof(szString), "Licitatia cu ID(#%d) este activa, puteti licita", bidsID);
  62.             SendClientMessage(i, -1, szString);
  63.             format(szString, sizeof(szString), "Ultimul player care a licitat este %s cu suma de $%s.", lastUser, FormatNumber(lastPrice));
  64.             SendClientMessage(i, -1, szString);
  65.             SendClientMessage(i, -1, "Au mai ramas 1 minute pana licitatia se inchide.");
  66.             SendClientMessage(i, -1, "------------------------------------------------");
  67.         }
  68.     }
  69.  
  70.     if(bidsCountTimer == 0) {
  71.         new szString[128];
  72.         if(!strcmp(lastUser, "No One")) {
  73.             foreach(new i : Player) {
  74.                 SendClientMessage(i, -1, "------------------------------------------------");
  75.                 format(szString, sizeof(szString), "Licitatia cu ID #%d a fost anulata", bidsID);
  76.                 SendClientMessage(i, -1, szString);
  77.                 format(szString, sizeof(szString), "Nici un player nu a licitat pentru acest bussines !");
  78.                 SendClientMessage(i, -1, szString);
  79.                 SendClientMessage(i, -1, "------------------------------------------------");
  80.             }
  81.         } else {
  82.             foreach(new i : Player) {
  83.                 SendClientMessage(i, -1, "------------------------------------------------");
  84.                 format(szString, sizeof(szString), "Licitatia cu ID #%d a fost finalizata", bidsID);
  85.                 SendClientMessage(i, -1, szString);
  86.                 format(szString, sizeof(szString), "Ultimul player care a licitat este {90C3D4}%s {FFFFFF}cu suma de {90C3D4}$%s.", lastUser, FormatNumber(lastPrice));
  87.                 SendClientMessage(i, -1, szString);
  88.                 SendClientMessage(i, -1, "------------------------------------------------");
  89.             }
  90.         }
  91.  
  92.         lastUser = "No One";
  93.         bidsName = "No One";
  94.         bidsID = -1;
  95.         bidsCountTimer = -1;
  96.         bidsPrice = -1;
  97.         lastPrice = -1;
  98.         KillTimer(bidsTimer);
  99.         bidsTimer = -1;
  100.     }
  101.     return 1;
  102. }
  103.  
  104. CMD:startbids(playerid, params[]) {
  105.     new bidName[64], bidPrice;
  106.     if(sscanf(params, "s[64]d", bidName, bidPrice)) return ErrorCMD(playerid);
  107.     CallRemoteFunction("Bids", "si", bidName, bidPrice);
  108.     return 1;
  109. }
  110.  
  111. CMD:bid(playerid, params[]) {
  112.     new suma, nume[MAX_PLAYER_NAME];
  113.     GetPlayerName(playerid, nume, MAX_PLAYER_NAME);
  114.     if(sscanf(params, "i", suma)) return SCM(playerid, -1, "Usage: /bid <Price>");
  115.     if(bidsID < 0) return SCM(playerid, -1, "ERROR: Nu este o licitatie activa ");
  116.     if(GetPlayerMoney(playerid) < bidsPrice) return SCM(playerid, -1, "ERROR: Nu detii destui bani pentru a licita.");
  117.     if(suma > GetPlayerMoney(playerid)) return SCM(playerid, -1, "ERROR: Nu detii destui bani pentru a licita.");
  118.     if(suma < bidsPrice) return SCM(playerid, -1, "ERROR: Nu detii destui bani pentru a licita.");
  119.     if(suma < lastPrice[playerid]) return SCM(playerid, -1, "ERROR: Nu detii destui bani pentru a licita.");
  120.    
  121.     isActiveBid[playerid] = 1;
  122.  
  123.     lastPrice[playerid] = suma;
  124.     lastUser[playerid] = nume;
  125.     GivePlayerMoney(playerid, -suma);
  126.  
  127.     new szString[128];
  128.     if(isActiveBid[playerid] == 1)
  129.     {
  130.         foreach(new i : Player) {
  131.             format(szString, sizeof(szString), "{6649CC}%s a licitat pentru bussines %s suma de $%s", lastUser[playerid], bidsName, FormatNumber(lastPrice[playerid]));
  132.             SendClientMessage(i, -1, szString);
  133.         }
  134.     }
  135.     return 1;
  136. }
  137.  
  138. CMD:togbid(playerid, params[]) {
  139.     if(isActiveBid[playerid] <= 0) {
  140.         isActiveBid[playerid] = 1;
  141.         SCM(playerid, -1, "{6649CC} Acum esti spectator pe o licitatie activa !");
  142.     } else {
  143.         isActiveBid[playerid] = 0;
  144.         SCM(playerid, -1, "{6649CC} Acum nu mai esti spectator pe o licitatie !");
  145.     }
  146.     return 1;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement