Advertisement
Gireada

Sistem de rob

Sep 19th, 2016
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.92 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. #include <zcmd>
  4.  
  5. #define WEAPON_ROB WEAPON_SHOTGUN // arma rob
  6. #define TIME_ROB 60000 // 60
  7. #define TIMING_ROB 30 // cat dureaza rob-ul(secunde)
  8.  
  9. new TimeRob[MAX_PLAYERS], PradaRob[MAX_PLAYERS], Wanted[MAX_PLAYERS];
  10.  
  11. forward Rob(playerid);
  12. forward TimerRob();
  13.  
  14. new Float:LocatiiRob[][3] =
  15. {
  16.     {2310.9670,-8.1712,26.7422},//banca
  17.     {309.4031,-8.3204,26.7422}//bijuterie
  18. };
  19.  
  20. public OnFilterScriptInit()
  21. {
  22.     SetTimer("TimerRob", 1000, 1);
  23.     return 1;
  24. }
  25.  
  26. public TimerRob()
  27. {
  28.     for(new i = 0; i < MAX_PLAYERS; i++)
  29.     {
  30.         if(IsPlayerConnected(i))
  31.         {
  32.             if(TimeRob[i] > 0)
  33.                 TimeRob[i]--;
  34.         }
  35.     }
  36. }
  37.  
  38. public OnPlayerConnect(playerid)
  39. {
  40.     TimeRob[playerid] = 0;
  41.     PradaRob[playerid] = 0;
  42.     Wanted[playerid] = 0;
  43.     new file[MAX_PLAYER_NAME+13];
  44.     format(file, MAX_PLAYER_NAME, "Rob/%s.ini", pName(playerid));
  45.     if(!dini_Exists(file))
  46.     {
  47.         dini_Create(file);
  48.         dini_IntSet(file,"TimeRob",0);
  49.         dini_IntSet(file,"PradaRob",0);
  50.         dini_IntSet(file,"Wanted",0);
  51.     }
  52.     if(dini_Exists(file))
  53.     {
  54.         TimeRob[playerid] = dini_Int(file,"TimeRob");
  55.         PradaRob[playerid] = dini_Int(file,"PradaRob");
  56.         Wanted[playerid] = dini_Int(file,"Wanted");
  57.     }
  58.     return 1;
  59. }
  60.  
  61. stock pName(playerid)
  62. {
  63.     new name[MAX_PLAYER_NAME];
  64.     GetPlayerName(playerid,name,sizeof(name));
  65.     return name;
  66. }
  67.  
  68. CMD:rob(playerid,command[])
  69. {
  70.     new string[43];
  71.     if(TimeRob[playerid] > 0)
  72.     {
  73.         format(string, sizeof(string), "Deabia ai jefuit, trebuie sa astepti %d secunde", TimeConvert(TimeRob[playerid]));
  74.         return SendClientMessage(playerid, -1, string);
  75.        
  76.     }
  77.     if(GetPlayerLocation(playerid) == -1) return SendClientMessage(playerid, -1, "Nu te aflii la o locatie pentru Rob");
  78.     if(GetPlayerWeapon(playerid) != WEAPON_ROB) return SendClientMessage(playerid, -1, "Iti trebuie shotgun pentru a jefui. Du-te si cumpara unul.");
  79.     ApplyAnimation(playerid, "SHOP", "ROB_Loop_Threat", 4.0, 0, 0, 0, 0, 0); // Rob
  80.     TogglePlayerControllable(playerid,0);
  81.     GameTextForPlayer(playerid, "Jefuind...", TIMING_ROB*1000,  0);
  82.     format(string, sizeof(string), "%s este in cursul unui jaf",pName(playerid));
  83.     SendClientMessageToAll(-1, string);
  84.     SetTimerEx("Rob", TIMING_ROB*1000, 0, "i", playerid);
  85.     return 1;
  86. }
  87.  
  88. public Rob(playerid)
  89. {
  90.     new bani = randomEx(10000, 100000);
  91.     new reuseste = randomEx(1,3), string[64];
  92.     TogglePlayerControllable(playerid,1);
  93.     switch(reuseste)
  94.     {
  95.         case 1:
  96.         {
  97.             SendClientMessage(playerid, -1, "Casierul a lesinat si nu ai mai furat bijuteriile/");
  98.             TimeRob[playerid] = TIME_ROB*60;
  99.             SaveRob(playerid);
  100.             Wanted[playerid] = 4;
  101.             SetPlayerWantedLevel(playerid, 4);
  102.         }
  103.         case 2:
  104.         {
  105.             SendClientMessage(playerid, -1, "Nu sunt bani, in casa de marcat. Politia vine dupa tine");
  106.             TimeRob[playerid] = TIME_ROB*60;
  107.             SaveRob(playerid);
  108.             Wanted[playerid] = 4;
  109.             SetPlayerWantedLevel(playerid, 4);
  110.         }
  111.         case 3:
  112.         {
  113.             SetPlayerWantedLevel(playerid, 4);
  114.             Wanted[playerid] = 4;
  115.             SendClientMessage(playerid, -1, "Nu sunt bani in casa de marcat.");
  116.             TimeRob[playerid] = TIME_ROB*60;
  117.             PradaRob[playerid] = bani;
  118.             SaveRob(playerid);
  119.             format(string, sizeof(string), "Ai furat %d $. Fugi si du-i in siguranta", bani);
  120.             SendClientMessage(playerid, -1, string);
  121.             SetPlayerCheckpoint(playerid, 1422.6359,-1319.3135,13.1266,2.0);
  122.         }
  123.     }
  124. }  
  125.  
  126. public OnPlayerEnterCheckpoint(playerid)
  127. {
  128.     new string[256];
  129.     if(IsPlayerInRangeOfPoint(playerid, 5.0, 1422.6359,-1319.3135,13.1266))
  130.     {
  131.         if(PradaRob[playerid] > 0)
  132.         {
  133.             DisablePlayerCheckpoint(playerid);
  134.             format(string, sizeof(string), "Ai furat cu succes %d", PradaRob[playerid]);
  135.             SendClientMessage(playerid, -1, string);
  136.             GivePlayerMoney(playerid, PradaRob[playerid]);
  137.             PradaRob[playerid] = 0;
  138.         }  
  139.     }
  140.     return 1;
  141. }
  142.  
  143. stock GetPlayerLocation(playerid)
  144. {
  145.     new found = -1, l;
  146.     for(l = 0; l < sizeof(LocatiiRob); l++)
  147.     {
  148.         if(IsPlayerInRangeOfPoint(playerid, 5.0, LocatiiRob[l][0], LocatiiRob[l][1], LocatiiRob[l][2]))
  149.         {
  150.             found = l; break;
  151.         }
  152.     }
  153.     if(found == -1)
  154.         return -1;
  155.     else
  156.         return l;
  157. }
  158.  
  159. stock randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum;
  160.    
  161. stock TimeConvert(time)
  162. {
  163.     new minutes;
  164.     new seconds;
  165.     new string[128];
  166.     if(time > 59){
  167.         minutes = floatround(time/60);
  168.         seconds = floatround(time - minutes*60);
  169.         if(seconds>9)format(string,sizeof(string),"%d:%d",minutes,seconds);
  170.         else format(string,sizeof(string),"%d:0%d",minutes,seconds);
  171.     }
  172.     else{
  173.         seconds = floatround(time);
  174.         if(seconds>9)format(string,sizeof(string),"0:%d",seconds);
  175.         else format(string,sizeof(string),"0:0%d",seconds);
  176.     }
  177.     return string;
  178. }  
  179.  
  180. stock SaveRob(playerid)
  181. {
  182.     new file[MAX_PLAYER_NAME+13];
  183.     format(file, MAX_PLAYER_NAME, "Rob/%s.ini", pName(playerid));
  184.     dini_IntSet(file,"TimeRob",TimeRob[playerid]);
  185.     dini_IntSet(file,"PradaRob",PradaRob[playerid]);
  186.     dini_IntSet(file,"Wanted",Wanted[playerid]);
  187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement