Advertisement
Guest User

GangZone System

a guest
Nov 8th, 2011
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.36 KB | None | 0 0
  1. /*------------------------------[v0.1]------------------------------
  2.   --------------------[ GangZoneSystem by Dr_Pawn ]-------------------
  3.   ------------------------------[v0.1]------------------------------*/
  4.  
  5. /*------------------------------------------------------------ INCLIDE/DEFINES*/
  6.  
  7. #include                    a_samp
  8.  
  9. #define                     iMAX_GZ                                         (99)
  10. #define                     iINVALID_GANGZONE_ID                            (-1)
  11.  
  12. /*-------------------------------------------------------------------- FORWARD*/
  13.  
  14. forward FimDominarGangZone(GangZoneID, Cor);
  15. forward iGz_FimDominarGangZone(GangZoneID, Cor);
  16.  
  17. /*------------------------------------------------------------------------ NEW*/
  18.  
  19. new UltimaGangZone = -1;
  20.  
  21. enum iGz_Info
  22. {
  23.     //GangZoneID
  24.     iGz_,
  25.     //GangZoneConfiguration
  26.     Float:iGz_Pos[4],
  27.     iGz_Cor,
  28.     iGz_Dono,
  29.     //GangZoneDomination
  30.     bool:iGz_Dominando,
  31.     iGz_DominandoCor
  32. };
  33. new iGz[iMAX_GZ][iGz_Info];
  34.  
  35. /*-------------------------------------------------------------------- INCLUDE*/
  36.  
  37. stock NovaGangZone(Float:PosXMin, Float:PosYMin, Float:PosXMax, Float:PosYMax, Cor, Dono = -1)
  38. {
  39.     if(UltimaGangZone == (iMAX_GZ - 1)) print("iGz: Nao foi Possivel Criar outra GangZone. Motivo: Limite Atingido.");
  40.     UltimaGangZone++;
  41.  
  42.     iGz[UltimaGangZone][iGz_] = GangZoneCreate(PosXMin, PosYMin, PosXMax, PosYMax);
  43.     iGz[UltimaGangZone][iGz_Cor] = Cor;
  44.     iGz[UltimaGangZone][iGz_Dono] = Dono;
  45.  
  46.     //Checar e Corrigir
  47.     if(PosXMax < PosXMin)
  48.     {
  49.         new Float:Trocar = PosXMax;
  50.         PosXMax = PosXMin;
  51.         PosXMin = Trocar;
  52.     }
  53.    
  54.     if(PosYMax < PosYMin)
  55.     {
  56.         new Float:Trocar = PosYMax;
  57.         PosYMax = PosYMin;
  58.         PosYMin = Trocar;
  59.     }
  60.    
  61.     iGz[UltimaGangZone][iGz_Pos][0] = PosXMin;
  62.     iGz[UltimaGangZone][iGz_Pos][1] = PosYMin;
  63.     iGz[UltimaGangZone][iGz_Pos][2] = PosXMax;
  64.     iGz[UltimaGangZone][iGz_Pos][3] = PosYMax;
  65.  
  66.     iGz[UltimaGangZone][iGz_Dominando] = false;
  67.     iGz[UltimaGangZone][iGz_DominandoCor] = 0xFFFFFFAA;
  68.  
  69.     GangZoneShowForAll(iGz[UltimaGangZone][iGz_], Cor);
  70.  
  71.     return UltimaGangZone;
  72. }
  73.  
  74. stock JogadorNaGangZone(playerid)
  75. {
  76.     if(!IsPlayerConnected(playerid) || UltimaGangZone == iINVALID_GANGZONE_ID) return iINVALID_GANGZONE_ID;
  77.  
  78.     new Float:PosX,
  79.         Float:PosY,
  80.         Float:PosZ;
  81.  
  82.     GetPlayerPos(playerid, PosX, PosY, PosZ);
  83.  
  84.     for(new gz = 0; gz <= UltimaGangZone; gz++)
  85.         if(PosX > iGz[gz][iGz_Pos][0] && PosY > iGz[gz][iGz_Pos][1] && PosX < iGz[gz][iGz_Pos][2] && PosY < iGz[gz][iGz_Pos][3])
  86.             return gz;
  87.  
  88.     return iINVALID_GANGZONE_ID;
  89. }
  90.  
  91. stock DominarGangZone(GangZoneID, Cor, Tempo)
  92. {
  93.     if(GangZoneID > UltimaGangZone || iGz[GangZoneID][iGz_Dominando] == true) return 0;
  94.  
  95.     iGz[GangZoneID][iGz_Dominando] = true;
  96.     iGz[GangZoneID][iGz_DominandoCor] = Cor;
  97.  
  98.     GangZoneFlashForAll(iGz[GangZoneID][iGz_], Cor);
  99.  
  100.     SetTimerEx("iGz_FimDominarGangZone", Tempo, false, "ii", GangZoneID, Cor);
  101.  
  102.     return 1;
  103. }
  104.  
  105. stock TrocarCorGangZone(GangZoneID, Cor)
  106. {
  107.     if(GangZoneID > UltimaGangZone || iGz[GangZoneID][iGz_Dominando] == true) return 0;
  108.  
  109.     GangZoneShowForAll(iGz[GangZoneID][iGz_], Cor);
  110.     iGz[GangZoneID][iGz_Cor] = Cor;
  111.  
  112.     return 1;
  113. }
  114.  
  115. stock TrocarDonoGangZone(GangZoneID, Dono)
  116. {
  117.     if(GangZoneID > UltimaGangZone) return 0;
  118.  
  119.     iGz[iGz[GangZoneID][iGz_]][iGz_Dono] = Dono;
  120.  
  121.     return 1;
  122. }
  123.  
  124. stock DonoDaGangZone(GangZoneID)
  125. {
  126.     if(GangZoneID > UltimaGangZone) return -1;
  127.  
  128.     return iGz[iGz[GangZoneID][iGz_]][iGz_Dono];
  129. }
  130.  
  131. stock DominandoGangZone(GangZoneID)
  132. {
  133.     if(GangZoneID > UltimaGangZone) return false;
  134.    
  135.     return iGz[GangZoneID][iGz_Dominando];
  136. }
  137.  
  138. public iGz_FimDominarGangZone(GangZoneID, Cor)
  139. {
  140.     iGz[GangZoneID][iGz_Dominando] = false;
  141.     GangZoneStopFlashForAll(iGz[GangZoneID][iGz_]);
  142.     FimDominarGangZone(GangZoneID, Cor);
  143.     return 1;
  144. }
  145.  
  146. iGz_OnPlayerConnect(playerid)
  147. {
  148.     if(UltimaGangZone == -1) return 1;
  149.  
  150.     for(new gz = 0; gz <= UltimaGangZone; gz++)
  151.     {
  152.         GangZoneShowForPlayer(playerid, iGz[gz][iGz_], iGz[gz][iGz_Cor]);
  153.         if(iGz[gz][iGz_Dominando])
  154.             GangZoneFlashForPlayer(playerid, iGz[gz][iGz_], iGz[gz][iGz_DominandoCor]);
  155.     }
  156.     return 1;
  157. }
  158.  
  159. /*-------------------------------------------------------------------- NATIVES*/
  160.  
  161. /*native NovaGangZone(Float:PosXMin, Float:PosYMin, Float:PosXMax, Float:PosYMax, Cor, Dono = -1);
  162. native JogadorNaGangZone(playerid);
  163. native DominarGangZone(GangZoneID, Cor, Tempo);
  164. native TrocarCorGangZone(GangZoneID, Cor);
  165. native TrocarDonoGangZone(GangZoneID, Dono);
  166. native DonoDaGangZone(GangZoneID);
  167. native DominandoGangZone(GangZoneID);*/
  168.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement