Advertisement
Guest User

Untitled

a guest
Aug 25th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.68 KB | None | 0 0
  1. #define INVALID_CAPTURE_ZONE_ID -1
  2. #define MAX_CAPTURE_ZONES 50
  3. #define MAX_RADIUS 10
  4. #define OBJECT_MODEL 3003 // (1946,1974 - тоже можно, но текстуры сами подбирайте)
  5. #define STEP 5
  6. #define INVALID_OWNER_ID -1
  7. #define OBJECT_FLAG 2993
  8. enum captureInfo
  9. {
  10.     captureradius,
  11.     Float:capturex,
  12.     Float:capturey,
  13.     Float:capturez,
  14.     captureColor,
  15.     captureID,
  16.     captureFlag,
  17.     captureOwner,
  18.     ObjectID[360/STEP]
  19. };
  20. new InfoCaptureZones[MAX_CAPTURE_ZONES][captureInfo];
  21. stock CreateCaptureZone(Float:x,Float:y,Float:z,radius,color,owner = INVALID_OWNER_ID,flag = 1)
  22. {
  23.     if(radius > MAX_RADIUS) radius = MAX_RADIUS;
  24.     for(new i; i < MAX_CAPTURE_ZONES; i++)
  25.     {
  26.         if(InfoCaptureZones[i][captureID] == 0)
  27.         {
  28.             InfoCaptureZones[i][captureradius] = radius;
  29.             InfoCaptureZones[i][capturex] = x;
  30.             InfoCaptureZones[i][capturey] = y;
  31.             InfoCaptureZones[i][capturez] = z;
  32.             InfoCaptureZones[i][captureColor] = color;
  33.             if(flag)
  34.             {
  35.                 InfoCaptureZones[i][captureFlag] = 1;
  36.                 InfoCaptureZones[i][ObjectID][0] = CreateObject(OBJECT_FLAG,x,y,z,0.0,0.0,0.0,300.0);
  37.                 SetObjectMaterial(InfoCaptureZones[i][ObjectID][0], 0, OBJECT_FLAG, "rcflagx", "GOflag",color);
  38.                 SetObjectMaterial(InfoCaptureZones[i][ObjectID][0], 1, OBJECT_FLAG, "rcflagx", "Alumox64",color);
  39.             }  
  40.             for(new f,d= flag; f< 360; f+= STEP)
  41.             {
  42.                 InfoCaptureZones[i][ObjectID][d] = CreateObject(OBJECT_MODEL,x+radius*-floatsin(f,degrees),y+radius*floatcos(f,degrees),z,0.0,0.0,0.0,300.0);
  43.                 SetObjectMaterial(InfoCaptureZones[i][ObjectID][d], 0, OBJECT_MODEL, "golfball", "kb_golf",color);
  44.                 d++;
  45.             }
  46.             InfoCaptureZones[i][captureOwner] = owner;
  47.             InfoCaptureZones[i][captureID] = 1;
  48.             return i;
  49.         }
  50.     }
  51.     return INVALID_CAPTURE_ZONE_ID;
  52. }
  53.  
  54. stock GetZoneOwnerID(zone_id)
  55. {
  56.     if(!InfoCaptureZones[zone_id][captureID])return INVALID_OWNER_ID;
  57.     return InfoCaptureZones[zone_id][captureOwner];
  58. }
  59. stock SetCaptureZoneOwner(zone_id,owner_id)
  60. {
  61.     if(InfoCaptureZones[zone_id][captureID])InfoCaptureZones[zone_id][captureOwner] = owner_id;
  62. }
  63. stock SetPlayerCaptureZonePos(playerid,zone_id)
  64. {
  65.     if(InfoCaptureZones[zone_id][captureID] == 1)
  66.     {
  67.         SetPlayerPos(playerid, InfoCaptureZones[zone_id][capturex], InfoCaptureZones[zone_id][capturey], InfoCaptureZones[zone_id][capturez]+0.5);
  68.     }
  69. }
  70. stock SetCaptureZoneColor(zone_id,color)
  71. {  
  72.     if(InfoCaptureZones[zone_id][captureFlag])
  73.     {
  74.         SetObjectMaterial(InfoCaptureZones[zone_id][ObjectID][0], 0, OBJECT_FLAG, "rcflagx", "GOflag",color);
  75.         SetObjectMaterial(InfoCaptureZones[zone_id][ObjectID][0], 1, OBJECT_FLAG, "rcflagx", "Alumox64",color);
  76.     }  
  77.     if(InfoCaptureZones[zone_id][captureID] == 1)
  78.     {
  79.         for(new d,i = InfoCaptureZones[zone_id][captureFlag]; d< InfoCaptureZones[zone_id][captureradius]*360; d+= STEP)
  80.         {
  81.             SetObjectMaterial(InfoCaptureZones[zone_id][ObjectID][i], 0, OBJECT_MODEL, "golfball", "kb_golf",color);
  82.             i++;
  83.         }
  84.     }  
  85. }
  86.  
  87. stock IsValidZoneID(zone_id)
  88. {
  89.     return InfoCaptureZones[zone_id][captureID];
  90. }
  91. stock GetPlayerCaptureZoneIn(playerid)
  92. {
  93.     for(new i; i < MAX_CAPTURE_ZONES; i++)
  94.     {
  95.         if(InfoCaptureZones[i][captureID] == 0)continue;
  96.         if(!IsPlayerInRangeOfPoint(playerid, InfoCaptureZones[i][captureradius], InfoCaptureZones[i][capturex], InfoCaptureZones[i][capturey], InfoCaptureZones[i][capturez]))continue;
  97.         return i;
  98.     }  
  99.     return INVALID_CAPTURE_ZONE_ID;
  100. }
  101. stock DeleteCaptureZone(zoneid)
  102. {
  103.     if(InfoCaptureZones[zoneid][captureID] == 0) return 0;
  104.     InfoCaptureZones[zoneid][captureID] = 0;
  105.     InfoCaptureZones[zoneid][captureFlag] = 0;
  106.     InfoCaptureZones[zoneid][captureOwner] = INVALID_OWNER_ID;
  107.     for(new i; i < 360; i+=STEP)
  108.     {
  109.         DestroyObject(InfoCaptureZones[zoneid][ObjectID][i]);
  110.     }
  111.     return 1;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement