Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define INVALID_CAPTURE_ZONE_ID -1
- #define MAX_CAPTURE_ZONES 50
- #define MAX_RADIUS 10
- #define OBJECT_MODEL 3003 // (1946,1974 - тоже можно, но текстуры сами подбирайте)
- #define STEP 5
- #define INVALID_OWNER_ID -1
- #define OBJECT_FLAG 2993
- enum captureInfo
- {
- captureradius,
- Float:capturex,
- Float:capturey,
- Float:capturez,
- captureColor,
- captureID,
- captureFlag,
- captureOwner,
- ObjectID[360/STEP]
- };
- new InfoCaptureZones[MAX_CAPTURE_ZONES][captureInfo];
- stock CreateCaptureZone(Float:x,Float:y,Float:z,radius,color,owner = INVALID_OWNER_ID,flag = 1)
- {
- if(radius > MAX_RADIUS) radius = MAX_RADIUS;
- for(new i; i < MAX_CAPTURE_ZONES; i++)
- {
- if(InfoCaptureZones[i][captureID] == 0)
- {
- InfoCaptureZones[i][captureradius] = radius;
- InfoCaptureZones[i][capturex] = x;
- InfoCaptureZones[i][capturey] = y;
- InfoCaptureZones[i][capturez] = z;
- InfoCaptureZones[i][captureColor] = color;
- if(flag)
- {
- InfoCaptureZones[i][captureFlag] = 1;
- InfoCaptureZones[i][ObjectID][0] = CreateObject(OBJECT_FLAG,x,y,z,0.0,0.0,0.0,300.0);
- SetObjectMaterial(InfoCaptureZones[i][ObjectID][0], 0, OBJECT_FLAG, "rcflagx", "GOflag",color);
- SetObjectMaterial(InfoCaptureZones[i][ObjectID][0], 1, OBJECT_FLAG, "rcflagx", "Alumox64",color);
- }
- for(new f,d= flag; f< 360; f+= STEP)
- {
- 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);
- SetObjectMaterial(InfoCaptureZones[i][ObjectID][d], 0, OBJECT_MODEL, "golfball", "kb_golf",color);
- d++;
- }
- InfoCaptureZones[i][captureOwner] = owner;
- InfoCaptureZones[i][captureID] = 1;
- return i;
- }
- }
- return INVALID_CAPTURE_ZONE_ID;
- }
- stock GetZoneOwnerID(zone_id)
- {
- if(!InfoCaptureZones[zone_id][captureID])return INVALID_OWNER_ID;
- return InfoCaptureZones[zone_id][captureOwner];
- }
- stock SetCaptureZoneOwner(zone_id,owner_id)
- {
- if(InfoCaptureZones[zone_id][captureID])InfoCaptureZones[zone_id][captureOwner] = owner_id;
- }
- stock SetPlayerCaptureZonePos(playerid,zone_id)
- {
- if(InfoCaptureZones[zone_id][captureID] == 1)
- {
- SetPlayerPos(playerid, InfoCaptureZones[zone_id][capturex], InfoCaptureZones[zone_id][capturey], InfoCaptureZones[zone_id][capturez]+0.5);
- }
- }
- stock SetCaptureZoneColor(zone_id,color)
- {
- if(InfoCaptureZones[zone_id][captureFlag])
- {
- SetObjectMaterial(InfoCaptureZones[zone_id][ObjectID][0], 0, OBJECT_FLAG, "rcflagx", "GOflag",color);
- SetObjectMaterial(InfoCaptureZones[zone_id][ObjectID][0], 1, OBJECT_FLAG, "rcflagx", "Alumox64",color);
- }
- if(InfoCaptureZones[zone_id][captureID] == 1)
- {
- for(new d,i = InfoCaptureZones[zone_id][captureFlag]; d< InfoCaptureZones[zone_id][captureradius]*360; d+= STEP)
- {
- SetObjectMaterial(InfoCaptureZones[zone_id][ObjectID][i], 0, OBJECT_MODEL, "golfball", "kb_golf",color);
- i++;
- }
- }
- }
- stock IsValidZoneID(zone_id)
- {
- return InfoCaptureZones[zone_id][captureID];
- }
- stock GetPlayerCaptureZoneIn(playerid)
- {
- for(new i; i < MAX_CAPTURE_ZONES; i++)
- {
- if(InfoCaptureZones[i][captureID] == 0)continue;
- if(!IsPlayerInRangeOfPoint(playerid, InfoCaptureZones[i][captureradius], InfoCaptureZones[i][capturex], InfoCaptureZones[i][capturey], InfoCaptureZones[i][capturez]))continue;
- return i;
- }
- return INVALID_CAPTURE_ZONE_ID;
- }
- stock DeleteCaptureZone(zoneid)
- {
- if(InfoCaptureZones[zoneid][captureID] == 0) return 0;
- InfoCaptureZones[zoneid][captureID] = 0;
- InfoCaptureZones[zoneid][captureFlag] = 0;
- InfoCaptureZones[zoneid][captureOwner] = INVALID_OWNER_ID;
- for(new i; i < 360; i+=STEP)
- {
- DestroyObject(InfoCaptureZones[zoneid][ObjectID][i]);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement