Advertisement
Guest User

Untitled

a guest
May 28th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 22.49 KB | None | 0 0
  1. //----------------------------------------------------------------------------//
  2.  
  3. #include <a_samp>
  4. #define colore 0xFFFF22AA
  5. #define PlayerToPoint
  6. #pragma tabsize 0
  7.  
  8. //----------------------------------------------------------------------------//
  9.  
  10. new bottino = 300000; // Bottino della rapina, modificabile
  11. new temporapina = 180000; // Tempo della rapina in millisecondi, modificabile (default = 900000 millisecondi)
  12. new rapinaincorso = 0; // NON MODIFICARE
  13. new israpinatore[MAX_PLAYERS]; // NON MODIFICARE
  14. new rapinatimer[MAX_PLAYERS]; // NON MODIFICARE
  15. new polcount; // NON MODIFICARE
  16. new randmax = 50000; // Margine massimo per il bottino casuale, modificabile [IMPORTANTE: Randmax deve essere MAGGIORE di Randmin]
  17. new randmin = 20000; // Margine minimo per il bottino casuale, modificabile [IMPORTANTE: Randmin deve essere MINORE di Randmax]
  18. new bottinocasuale = 0; // Bottino casuale si/no, 1 per attivarlo, 0 per disattivarlo, modificabile
  19. new copsminimi = 2; // Numero minimo di poliziotti connessi nel server per poter rapinare la banca, modificabile
  20. new bloccorapina = 0; // NON MODIFICARE
  21.  
  22. forward IsPolice(playerid);
  23. forward IsInBank(playerid);
  24. forward IsArmed(playerid);
  25. forward RapinaTime(playerid);
  26. forward BankAreaCheck();
  27. forward CopsConnected();
  28. forward RapinaOn();
  29.  
  30. //----------------------------------------------------------------------------//
  31.  
  32. public IsInBank(playerid) {
  33.         new Float:px;
  34.         new Float:py;
  35.         new Float:pz;
  36.         GetPlayerPos(playerid, px, py, pz);
  37.         // Coordinate che delimitano il cubo in cui ? contenuto l'interior della banca
  38.         // Modificate a vostro rischio!
  39. if (PlayerToPoint(100.0, playerid,1490.2883,1305.6349,1093.2964)) return 1;// Devi modificare il numero 100.0 è la grandezza della banca, misuralo in base le dimensioni della stanza.
  40. else return 0;
  41. }
  42.  
  43. public IsPolice(playerid) {
  44.         new pskin = GetPlayerSkin(playerid);
  45.         // Skins dei poliziotti, cambiate, togliete o aggiungete SkinID se necessario
  46.         if ((pskin == 266) || (pskin == 265) || (pskin == 267) || (pskin == 71) || (pskin == 163) || (pskin == 246) || (pskin == 166) || (pskin == 165) || (pskin == 164) || (pskin == 280) || (pskin == 281) || (pskin == 282) || (pskin == 283) || (pskin == 284) || (pskin == 285) || (pskin == 286) || (pskin == 287) || (pskin == 288)) {
  47.                 return 1;
  48.         }
  49.         return 0;
  50. }
  51.  
  52. public IsArmed(playerid) {
  53.         new arma = GetPlayerWeapon(playerid);
  54.         if ((arma > 18) && (arma < 39)) {
  55.             return 1;
  56.         }
  57.         return 0;
  58. }
  59.  
  60. public CopsConnected() {
  61.     for (new i=0; i<MAX_PLAYERS; i++) {
  62.                 if (IsPlayerConnected(i)) {
  63.                         if (IsPolice(i) == 1) {
  64.                             polcount ++;
  65.                             return polcount;
  66.                         }
  67.                 }
  68.         }
  69.         return 0;
  70. }
  71.  
  72. public RapinaOn() {
  73.         bloccorapina = 0;
  74. }
  75.  
  76. public RapinaTime(playerid) {
  77.         new string[256];
  78.         new polstring[256];
  79.         new pname[MAX_PLAYER_NAME];
  80.         new randbottino = random(randmax-randmin) + randmin;
  81.         GetPlayerName(playerid, pname, sizeof(pname));
  82.         KillTimer(rapinatimer[playerid]);
  83.         israpinatore[playerid] = 0;
  84.         rapinaincorso = 0;
  85.         if (bottinocasuale == 0) {
  86.                 format(string, sizeof(string),"Un tizio ha rapinato con successo la banca, e porta a casa ben %d$ !", pname, bottino);
  87.                 GivePlayerMoney(playerid, bottino);
  88.         } else {
  89.                 format(string, sizeof(string),"Un tizio ha rapinato con successo la banca, e porta a casa ben %d$ !", pname, randbottino);
  90.                 GivePlayerMoney(playerid, randbottino);
  91.         }
  92.         SendClientMessageToAll(colore, string);
  93.         for (new i=0; i<MAX_PLAYERS; i++) {
  94.                 if (IsPlayerConnected(i)) {
  95.                         if (IsPolice(i) == 1) {
  96.                                 format(polstring, sizeof(polstring),"Hai fallito nell'impedire al rapinatore di fare la rapina!", pname);
  97.                                 SendClientMessage(i, colore, polstring);
  98.                         }
  99.                 }
  100.         }
  101.         return 1;
  102. }
  103.  
  104. public BankAreaCheck() {
  105.         for (new i=0; i<MAX_PLAYERS; i++) {
  106.                 if (IsPlayerConnected(i)) {
  107.                     if (israpinatore[i] == 1) {
  108.                                 if (IsInBank(i) == 1) {
  109.                                 } else {
  110.                                         new polstring[256];
  111.                                         new rapinatore[MAX_PLAYER_NAME];
  112.                                         GetPlayerName(i, rapinatore, sizeof(rapinatore));
  113.                                         israpinatore[i] = 0;
  114.                                 KillTimer(rapinatimer[i]);
  115.                                 rapinaincorso = 0;
  116.                                 SendClientMessage(i, colore, "Sei uscito dalla banca e hai fallito la rapina!");
  117.                                 for (new pi=0; pi<MAX_PLAYERS; pi++) {
  118.                                                 if (IsPlayerConnected(pi)) {
  119.                                                         if (IsPolice(pi) == 1) {
  120.                                                                 format(polstring, sizeof(polstring),"Il tizio uscito dalla banca e ha smesso di rapinare", rapinatore);
  121.                                                                 SendClientMessage(pi, colore, polstring);
  122.                                                         }
  123.                                                 }
  124.                                         }
  125.                                 }
  126.                     }
  127.                 }
  128.         }
  129.         return 1;
  130. }
  131.  
  132. //----------------------------------------------------------------------------//
  133.  
  134. public OnFilterScriptInit() {
  135.         print("\n--FS Rapina By Skiaffo Caricato.\n");
  136.         SetTimer("BankAreaCheck", 500, 1);
  137.         bloccorapina = 0;
  138.         rapinaincorso = 0;
  139.         return 1;
  140. }
  141.  
  142. //----------------------------------------------------------------------------//
  143.  
  144. public OnPlayerConnect(playerid) {
  145.         israpinatore[playerid] = 0; // NON MODIFICARE
  146.         return 1;
  147. }
  148.  
  149. //----------------------------------------------------------------------------//
  150.  
  151. public OnPlayerCommandText(playerid, cmdtext[]) {
  152.  
  153.         new cmd[256];
  154.         new idx;
  155.         cmd = strtok(cmdtext, idx);
  156.  
  157.         if (strcmp(cmd, "/rapina", true) == 0) {
  158.             if (IsPolice(playerid) == 0) {
  159.                 if (IsInBank(playerid) == 1) {
  160.                     if (bloccorapina == 0) {
  161.                         if (israpinatore[playerid] == 0) {
  162.                                 if (CopsConnected() >= copsminimi) {
  163.                                         if (IsArmed(playerid) == 1) {
  164.                                                 rapinatimer[playerid] = SetTimerEx("RapinaTime", temporapina, 0, "i", playerid);
  165.                                                 israpinatore[playerid] = 1;
  166.                                                 rapinaincorso = 1;
  167.                                                 bloccorapina = 1;
  168.                                                 new string[256];
  169.                                                 new polstring[256];
  170.                                                 new rapstring[256];
  171.                                                 new rapinatore[MAX_PLAYER_NAME];
  172.                                                 GetPlayerName(playerid, rapinatore, sizeof(rapinatore));
  173.                                                         for (new i=0; i<MAX_PLAYERS; i++) {
  174.                                                                         if (IsPlayerConnected(i)) {
  175.                                                                                 if (IsPolice(i) == 1) {
  176.                                                                                         format(polstring, sizeof(polstring),"Attenzione! qualcuno sta rapinando la banca!", rapinatore);
  177.                                                                                         SendClientMessage(i, colore, polstring);
  178.                                                                                 }
  179.                                                                         }
  180.                                                                 }
  181.                                                         SendClientMessage(playerid, colore, "Hai iniziato la rapina!");
  182.                                                         format(string, sizeof(string),"Resta per almeno %d minuti nella banca per rapinarla con successo!", temporapina/60000);
  183.                                                 SendClientMessage(playerid, colore, string);
  184.                                                         format(rapstring, sizeof(rapstring),"qualcuno ha iniziato a rapinare la banca!", rapinatore);
  185.                                                 SendClientMessageToAll(colore, rapstring);
  186.                                                         } else {
  187.                                                                 SendClientMessage(playerid, colore, "Devi avere un'arma da fuoco se vuoi rapinare una banca!");
  188.                                                         }
  189.                                                 } else {
  190.                                                         new minstring[256];
  191.                                                         format(minstring, sizeof(minstring),"Devono esserci minimo %d poliziotti connessi per poter rapinare la banca!", copsminimi);
  192.                                                         SendClientMessage(playerid, colore, minstring);
  193.                                                 }
  194.                                         } else {
  195.                                                 SendClientMessage(playerid, colore, "Stai gia' rapinando la banca!");
  196.                                         }
  197.                                 } else {
  198.                                         SendClientMessage(playerid, colore, "Al momento non e' possibile rapinare la banca!");
  199.                                 }
  200.                 } else {
  201.                         SendClientMessage(playerid, colore, "Non sei in banca!");
  202.                 }
  203.             } else {
  204.                 SendClientMessage(playerid, colore, "Sei un poliziotto, non puoi rapinare!");
  205.             }
  206.             return 1;
  207.         }
  208.  
  209.         if (strcmp(cmd, "/copsminimi", true) == 0) {
  210.                 if (IsPlayerAdmin(playerid) == 1) {
  211.                     if (rapinaincorso == 0) {
  212.                                 new tmpmincops;
  213.                                 new tmp[256];
  214.                                 new string[256];
  215.                                 tmp = strtok(cmdtext, idx);
  216.                                 if (!strlen(tmp)) {
  217.                                         format(string, sizeof(string), "Il numero minimo di poliziotti per fare una rapina e' di %d, scrivi /copsminimi [numero] per cambiarli", copsminimi);
  218.                                         SendClientMessage(playerid, colore, string);
  219.                                         return 1;
  220.                                 }
  221.                                 tmpmincops = strval(tmp);
  222.                                 copsminimi = tmpmincops;
  223.                                 format(string, sizeof(string), "Impostato %d come numero minimo di poliziotti per fare una rapina", copsminimi);
  224.                                 SendClientMessage(playerid, colore, string);
  225.                         } else {
  226.                                 SendClientMessage(playerid, colore, "C'e' una rapina in corso in questo momento, aspetta che finisca");
  227.                         }
  228.                 } else {
  229.                         SendClientMessage(playerid, colore, "Devi essere admin rcon per utilizzare questo comando");
  230.                 }
  231.                 return 1;
  232.         }
  233.  
  234.         if (strcmp(cmd, "/bottino", true) == 0) {
  235.                 if (IsPlayerAdmin(playerid) == 1) {
  236.                     if (rapinaincorso == 0) {
  237.                                 if (bottinocasuale == 0) {
  238.                                         new tmpbottino;
  239.                                         new tmp[256];
  240.                                         new string[256];
  241.                                         tmp = strtok(cmdtext, idx);
  242.                                         if (!strlen(tmp)) {
  243.                                                 format(string, sizeof(string), "Il bottino attuale e' di %d$, scrivi /bottino [soldi] per cambiarlo", bottino);
  244.                                                 SendClientMessage(playerid, colore, string);
  245.                                                 return 1;
  246.                                         }
  247.                                         tmpbottino = strval(tmp);
  248.                                         bottino = tmpbottino;
  249.                                         format(string, sizeof(string), "Bottino della rapina impostato a %d$", bottino);
  250.                                         SendClientMessage(playerid, colore, string);
  251.                                 } else {
  252.                                         SendClientMessage(playerid, colore, "E' attivo il bottino casuale. Per disattivarlo usare /bottinocasuale");
  253.                                 }
  254.                         } else {
  255.                                 SendClientMessage(playerid, colore, "C'e' una rapina in corso in questo momento, aspetta che finisca");
  256.                         }
  257.                 } else {
  258.                         SendClientMessage(playerid, colore, "Devi essere admin rcon per utilizzare questo comando");
  259.                 }
  260.                 return 1;
  261.         }
  262.  
  263.         if (strcmp(cmd, "/temporapina", true) == 0) {
  264.                 if (IsPlayerAdmin(playerid) == 1) {
  265.                         if (rapinaincorso == 0) {
  266.                                 new tmprapina;
  267.                                 new tmp[256];
  268.                                 new string[256];
  269.                                 tmp = strtok(cmdtext, idx);
  270.                                 if (!strlen(tmp)) {
  271.                                         format(string, sizeof(string), "Il tempo di rapina attuale e' di %d minuti, scrivi /temporapina [minuti] per cambiarlo", temporapina/60000);
  272.                                         SendClientMessage(playerid, colore, string);
  273.                                         return 1;
  274.                                 }
  275.                                 tmprapina = strval(tmp) * 60000;
  276.                                 temporapina = tmprapina;
  277.                                 format(string, sizeof(string), "Tempo della rapina impostato a %d minuti", temporapina/60000);
  278.                                 SendClientMessage(playerid, colore, string);
  279.                         } else {
  280.                                 SendClientMessage(playerid, colore, "C'? una rapina in corso in questo momento, aspetta che finisca");
  281.                         }
  282.                 } else {
  283.                         SendClientMessage(playerid, colore, "Devi essere admin rcon per utilizzare questo comando");
  284.                 }
  285.                 return 1;
  286.         }
  287.  
  288.         if (strcmp(cmd, "/randmax", true) == 0) {
  289.                 if (IsPlayerAdmin(playerid) == 1) {
  290.                         if (rapinaincorso == 0) {
  291.                                 new tmprand;
  292.                                 new tmp[256];
  293.                                 new string[256];
  294.                                 tmp = strtok(cmdtext, idx);
  295.                                 if (!strlen(tmp)) {
  296.                                         format(string, sizeof(string), "L'attuale valore massimo per il bottino random e' %d$", randmax);
  297.                                         SendClientMessage(playerid, colore, string);
  298.                                         return 1;
  299.                                 }
  300.                                 tmprand = strval(tmp);
  301.                                 if (tmprand > randmin) {
  302.                                         randmax = tmprand;
  303.                                         format(string, sizeof(string), "Valore massimo per il bottino random impostato a %d", randmax);
  304.                                         SendClientMessage(playerid, colore, string);
  305.                                 } else {
  306.                                         SendClientMessage(playerid, colore, "randmax deve essere maggiore di randmin");
  307.                                 }
  308.                         } else {
  309.                                 SendClientMessage(playerid, colore, "C'e' una rapina in corso in questo momento, aspetta che finisca");
  310.                         }
  311.                 } else {
  312.                         SendClientMessage(playerid, colore, "Devi essere admin rcon per utilizzare questo comando");
  313.                 }
  314.                 return 1;
  315.         }
  316.  
  317.         if (strcmp(cmd, "/randmin", true) == 0) {
  318.                 if (IsPlayerAdmin(playerid) == 1) {
  319.                         if (rapinaincorso == 0) {
  320.                                 new tmprand;
  321.                                 new tmp[256];
  322.                                 new string[256];
  323.                                 tmp = strtok(cmdtext, idx);
  324.                                 if (!strlen(tmp)) {
  325.                                         format(string, sizeof(string), "L'attuale valore minimo per il bottino random e' %d$", randmin);
  326.                                         SendClientMessage(playerid, colore, string);
  327.                                         return 1;
  328.                                 }
  329.                                 tmprand = strval(tmp);
  330.                                 if (tmprand < randmax) {
  331.                                         randmin = tmprand;
  332.                                         format(string, sizeof(string), "Valore minimo per il bottino random impostato a %d", randmin);
  333.                                         SendClientMessage(playerid, colore, string);
  334.                                 } else {
  335.                                         SendClientMessage(playerid, colore, "randmin deve essere minore di randmax");
  336.                                 }
  337.                         } else {
  338.                                 SendClientMessage(playerid, colore, "C'e' una rapina in corso in questo momento, aspetta che finisca");
  339.                         }
  340.                 } else {
  341.                         SendClientMessage(playerid, colore, "Devi essere admin rcon per utilizzare questo comando");
  342.                 }
  343.                 return 1;
  344.         }
  345.  
  346.         if (strcmp(cmd, "/bottinocasuale", true) == 0) {
  347.                 if (IsPlayerAdmin(playerid) == 1) {
  348.                         if (rapinaincorso == 0) {
  349.                             if (bottinocasuale == 0) {
  350.                                         SendClientMessage(playerid, colore, "Bottino casuale attivato");
  351.                                         bottinocasuale = 1;
  352.                                 } else {
  353.                                         SendClientMessage(playerid, colore, "Bottino casuale disattivato");
  354.                                         bottinocasuale = 0;
  355.                                 }
  356.                         } else {
  357.                                 SendClientMessage(playerid, colore, "C'e' una rapina in corso in questo momento, aspetta che finisca");
  358.                         }
  359.                 } else {
  360.                         SendClientMessage(playerid, colore, "Devi essere admin rcon per utilizzare questo comando");
  361.                 }
  362.                 return 1;
  363.         }
  364.  
  365.         // Debug
  366.  
  367.         /*
  368.  
  369.         if (strcmp(cmd, "/randbottino", true) == 0) {
  370.             new string[128];
  371.                 new randbottino = random(randmax-randmin) + randmin;
  372.                 format(string, sizeof(string), "Bottino casuale: %d$", randbottino);
  373.                 SendClientMessage(playerid, colore, string);
  374.                 return 1;
  375.         }
  376.  
  377.         if (strcmp(cmd, "/polcount", true) == 0) {
  378.                 new string[256];
  379.                 format(string, sizeof(string), "Numero poliziotti: %d", CopsConnected());
  380.                 SendClientMessage(playerid, colore, string);
  381.                 return 1;
  382.         }
  383.  
  384.         if (strcmp(cmd, "/isinbank", true) == 0) {
  385.                 if (IsInBank(playerid) == 1) {
  386.                         SendClientMessage(playerid, colore, "si");
  387.                 } else {
  388.                         SendClientMessage(playerid, colore, "no");
  389.                 }
  390.                 return 1;
  391.         }
  392.  
  393.         if (strcmp(cmd, "/ispolice", true) == 0) {
  394.                 if (IsPolice(playerid) == 1) {
  395.                         SendClientMessage(playerid, colore, "si");
  396.                 } else {
  397.                         SendClientMessage(playerid, colore, "no");
  398.                 }
  399.                 return 1;
  400.         }
  401.  
  402.         */
  403.  
  404.         return 0;
  405. }
  406.  
  407. //----------------------------------------------------------------------------//
  408.  
  409. public OnPlayerDeath(playerid, killerid, reason) {
  410.         if (israpinatore[playerid] == 1) {
  411.             if (killerid == INVALID_PLAYER_ID) {
  412.                 SendClientMessage(playerid, colore, "Ti sei ucciso durante una rapina e hai fallito!");
  413.             } else {
  414.                         if (IsPolice(killerid) == 1) {
  415.                         SendClientMessage(playerid, colore, "Sei stato ucciso da un poliziotto mentre facevi una rapina!");
  416.                         } else
  417.                         if (israpinatore[killerid] == 1) {
  418.                                 SendClientMessage(playerid, colore, "Sei stato ucciso da un'altro rapinatore!");
  419.                         } else {
  420.                                 SendClientMessage(playerid, colore, "Sei stato ucciso mentre facevi una rapina!");
  421.                         }
  422.             }
  423.         israpinatore[playerid] = 0;
  424.         KillTimer(rapinatimer[playerid]);
  425.         rapinaincorso = 0;
  426.         }
  427.         return 1;
  428. }
  429.  
  430. //----------------------------------------------------------------------------//
  431.  
  432. strtok(const string[], &index)
  433. {
  434.         new length = strlen(string);
  435.         while ((index < length) && (string[index] <= ' '))
  436.         {
  437.                 index++;
  438.         }
  439.  
  440.         new offset = index;
  441.         new result[20];
  442.         while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  443.         {
  444.                 result[index - offset] = string[index];
  445.                 index++;
  446.         }
  447.         result[index - offset] = EOS;
  448.         return result;
  449. }
  450.  
  451. //----------------------------------------------------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement