Problem with Random Fire
#1

I got problem in my fire script. The fire didn't go away when the fire health is 0. This is my code
Code:
#define MAX_FIRES					10			// max amout of fires able to exist at once
#define BURNING_RADIUS 				1.2     	// radius in which you start burning if you're too close to a fire
#define FIRE_RADIUS_FOOT			8.0		// radius in which you can extinguish the fire by foot
#define CAR_RADIUS					12.0			// radius in which you can extinguish the fire by firetruck/SWAT Van
#define Z_DIFFERENCE				2.5			// height which is used for technical accurancy of extinguishing. Please do not change
#define FIRE_OBJECT_SLOT			1			// the slot used with SetPlayerAttachedObject and RemovePlayerAttachedObject

forward CreateFire(slot, Float:x, Float:y, Float:z);
forward CreateSmoke(Float:x, Float:y, Float:z);
forward DestroyFire(id);
forward DestroySmoke(id);
forward RemoveSmokeFromFire(id);
forward BurnoutTimer(fireid);
new FireBurnout[MAX_FIRES];
forward PutOutFire(fireid, type);
new ExtinguishFire[MAX_FIRES];
new FireFinal[MAX_FIRES];
forward FireContained(fireid);
forward RandomLAFireTimer();
forward RandomCCFireTimer();
forward BurningTimer(playerid);
forward TogglePlayerBurning(playerid, burning);

enum FireInfo
{
	Fire_id,
	Fire_Exists,
	Float:Fire_X,
	Float:Fire_Y,
	Float:Fire_Z,
	Smoke[5],
	Fire_Taken,
	Fire_Zone[MAX_ZONE_NAME]
}

new Fire[MAX_FIRES][FireInfo];
new PlayerFireTimer[MAX_PLAYERS][3]; // Burn, StopBurn, Extinguish a fire
new Float:PlayerOnFireHP[MAX_PLAYERS];
new FireHealth[MAX_FIRES];

// LAFD Fire Locations
forward StartRandomFire(randomloc);
forward GetNextFire();
new Float:RandomFire_X;
new Float:RandomFire_Y;
new Float:RandomFire_Z;
new RandomFireLocation[256];
new ActiveFires;
new FireObjects[MAX_FIRES][4];
new Float:RandomFireSpawns[][3] = {
{1567.887,-1894.786,13.632}, // 1: Metropolitan ave building automatic firealarm Vestols house
{1447.816,-2289.690,13.622}, // 2: LAX Terminal Entrance Hindenburg N
{2283.268,-1702.766,17.772}, // 3: Gym Parking lot fire, Liverpool rd
{2307.164,-1642.985,14.652}, // 4: Ten Green Bottles Kennedy Vld and Grove
{862.530,-1252.124,14.892},// 5: Stage A Fire Liberty Ave and Rodeo Dr
{2782.219,-1814.517,11.745},// 6: Forum Arena Main Entrance off of 425
{2371.641,-2134.402,27.260},// 7: Oil tank fire accross from trucking depotw Atlantic Avenu
{2397.253,-1898.087,13.622},// 8: Clukinbell Atlantic Ave
{1413.382,-1699.106,13.612},// 9: LA Courthouse
{1337.640,-1090.549,26.729},// 10: Lawyers office stlarwrence blvd
{1173.541,-1307.865,14.071},// 11: Allsaints front entrance
{1940.535,-1172.337,20.668},// 12: Park Fire brush park north and green st
{1518.149,-1451.034,13.800},// 13: Residential Obey Hangout Central Ave and pasadena
{1351.162,-1756.498,13.497},// 14: Sandreas Blvd Near Courthouse 247 comercial alarm
{1940.8149,-1773.1541,19.5250}, // 15: Gas Station Fire, San Andreas Blvd. and Gates.
{2852.2368,-1357.7797,11.0625}, // 16: Building Fire, Santa Monica Blvd. and Bush St.
{1460.0709,-1009.9266,26.8438}, // 17: Building Fire, Sunset Blvd. near ELM, LA Bank.
{813.6826,-1456.7595,14.2284}, // 18: House Fire, Giggles and Hell Street.
{1034.7396,-813.1819,101.8516}, // 19: House Fire, Rich St. Near VGB Circle Dr.
{-2100.77,-2337.32,29.98}, // 20: J&J's Restaurant Angel Pine
{-2153.8689,-2461.4744,30.8516},// 21: Cluck N Bell, Angel Pine
{-2094.28,-2463.16,29.98}, // 22: Cluck N Bell, Angel Pine
{-2104.64,-2432.15,29.98}, // 23: Phat Liquors, Angel Pine
{2001.1978,1540.5249,13.2319}, // 24: LV Pirate Ship
{1892.1227,2408.5327,10.8254}, // 25: LV North Souvenir Shop
{2471.9177,2036.7567,10.4692}, // 26: Burger shot @ Gere St
{2864.4194,2429.9978,10.6796}, // 27: Stripmall East LV
{2543.7000,1022.3932,10.4663}, // 28: Thomas St Strip Club
{2698.1152,900.7314,10.0080}, // 29: Franklin / Thomas Construction Site
{2825.4768,970.1545,10.3974}, // 30: East LV Franklin St Truck Dock
{767.7085,1890.9637,4.7346}, // 31: Transition / Thorn St Ammunation West LV
{763.5473,2033.9827,6.3581} // 32: West LV Power Substation
};

new RandomFireLocationNames[][] = {
"Metropolitan Ave and Pine St.",//1//
"LAX Terminal, Front Entrance, Hindenburg North.",//2//
"Gym Roof, Liverpool Rd.",//3//
"Ten Greenbottles, Grove St.",//4//
"Stage A, Liberty Ave and Rodeo Dr.",//5//
"Forum Arena, Main Entrance, off of I425.",//6//
"Oil Refinery, Atlantic Ave, just south of Industrial Blvd.",//7// Explosive
"Cluckin' Bell, Atlantic Avenue.",//8//
"Front Entrance, LA County Courthouse.",//9//
"Lawyer Firm, St Lawrence Blvd.",//10// Explosive
"All Saints, Front Bay, Health St and St Mary.",//11
"City Park, Park North and Green St.",//12//
"Obey Residence, Central Ave and Pasadena Blvd.",//13//
"24/7 San Andrea Blvd Near the Courthouse.",//14//
"San Andreas Blvd. and Gates.",//15// Explosive
"Santa Monica Blvd. and Bush St.",//16//
"Sunset Blvd. near ELM, LA Bank.",//17//
"Giggles and Hell Street.",//18//
"Rich St. Near VGB Circle Dr.",//19//
"J&J's Restaurant, Angel Pine",//20//
"Cluck N Bell, Angel Pine",//21//
"Ammu-Nation, Angel Pine",//22//
"Liquor Store, Angel Pine",//23//
"Las Vegas Blvd / Belview St, at the pirate ship.",//24// Explosive
"Jones St. Souvenir shop.",//25//
"Gere St. Burger Shot.",//26//
"Mint St. East LV at the Strip Mall.",//27// Explosive
"Thomas St. at the Strip Club.",//28//
"Franklin / Thomas St, at the Construction site.",//29//
"Franklin St. East LV at the Truck Dock.",//30// Explosive
"Transition / Thorn St. West LV.",//31// Explosive
"County Rd. 207 / Transition St. West LV."//32//
};
Code:
// Fire Publics
public GetNextFire()
{
	for(new i=0; i<MAX_FIRES; i++)
	{
	    if(Fire[i][Fire_Exists] == 0) return i;
	}
	return MAX_FIRES-1;
}
	    
public CreateFire(slot, Float:x, Float:y, Float:z)
{
	Fire[slot][Fire_X] = x;
	Fire[slot][Fire_Y] = y;
	Fire[slot][Fire_Z] = z - Z_DIFFERENCE;
	CreateDynamicObject(18691, Fire[slot][Fire_X], Fire[slot][Fire_Y], Fire[slot][Fire_Z], 0.0, 0.0, 0.0);
}

public DestroyFire(id)
{
 	DestroyDynamicObject(FireObjects[id][0]);
 	DestroyDynamicObject(FireObjects[id][1]);
 	DestroyDynamicObject(FireObjects[id][2]);
 	DestroyDynamicObject(FireObjects[id][3]);
	Fire[id][Fire_Exists] = 0;
	Fire[id][Fire_X] = 0.0;
	Fire[id][Fire_Y] = 0.0;
	Fire[id][Fire_Z] = 0.0;
	Fire[id][Fire_Zone] = MAX_ZONE_NAME;
	FireHealth[id] = 0;
	ActiveFires --;
	RemoveSmokeFromFire(id);
}

public CreateSmoke(Float:x, Float:y, Float:z)
{
	return CreateDynamicObject(18726, x, y, z, 0.0, 0.0, 0.0);
}

public DestroySmoke(id)
{
 	DestroyDynamicObject(id);
}

// Destroys extinguishing-smoke
public RemoveSmokeFromFire(id)
{
    for(new i; i < 5; i++)
	{
		DestroyDynamicObject(Fire[id][Smoke][i]);
		Fire[id][Smoke][i] = -1;
	}
}

public FireContained(fireid)
{
	new string[128];
	DestroyDynamicObject(FireObjects[fireid][0]);
	DestroyDynamicObject(FireObjects[fireid][1]);
	DestroyDynamicObject(FireObjects[fireid][2]);
	DestroyDynamicObject(FireObjects[fireid][3]);
	Fire[fireid][Fire_Exists] = 0;
	format(string, sizeof(string), "FIRE COMM DISPATCH: The fire located at %s has been successfully contained.", Fire[fireid][Fire_Zone]);
	SendDispatchMessage(string);
	Fire[fireid][Fire_X] = 0.0;
	Fire[fireid][Fire_Y] = 0.0;
	Fire[fireid][Fire_Z] = 0.0;
	Fire[fireid][Fire_Zone] = MAX_ZONE_NAME;
	FireHealth[fireid] = 0;
	ActiveFires --;
	RemoveSmokeFromFire(fireid);
	return 1;
}
Code:
public RandomLAFireTimer()
{
	if(ActiveFires < MAX_FIRES)
	{
		if(CheckLAFireMembers() < 1)
		{
		    SetTimer("RandomLAFireTimer", 950000, false);
		}
		if(5> CheckLAFireMembers() > 1)
		{
			 new randloc = random(23);
			StartRandomFire(randloc);
			SetTimer("RandomLAFireTimer", 950000, false);
		}
		if(9> CheckLAFireMembers() > 4)
		{
			 new randloc = random(23);
			StartRandomFire(randloc);
			SetTimer("RandomLAFireTimer", 900000, false);
		}
		if(CheckLAFireMembers() > 8)
		{
			 new randloc = random(23);
			StartRandomFire(randloc);
			SetTimer("RandomLAFireTimer", 700000, false);
		}
	}
}
public StartRandomFire(randomloc)
{
	new string[512], zone[MAX_ZONE_NAME];
	new RAND = randomloc;
    RandomFire_X = RandomFireSpawns[RAND][0];
    RandomFire_Y = RandomFireSpawns[RAND][1];
    RandomFire_Z = RandomFireSpawns[RAND][2];
	new fireslot = GetNextFire();
    format(RandomFireLocation, 256, "%s", RandomFireLocationNames[RAND]);
    FireBurnout[fireslot] = SetTimerEx("BurnoutTimer",300000,0, "i", fireslot);
	Fire[fireslot][Fire_Exists] = 1;
	Fire[fireslot][Fire_id] = fireslot;
	ActiveFires ++;
	Fire[fireslot][Fire_X] = RandomFireSpawns[RAND][0];
	Fire[fireslot][Fire_Y] = RandomFireSpawns[RAND][1];
	Fire[fireslot][Fire_Z] = RandomFireSpawns[RAND][2];
 	FireObjects[fireslot][0] = CreateFire(fireslot, RandomFire_X, RandomFire_Y, RandomFire_Z);
	FireObjects[fireslot][1] = CreateFire(fireslot, RandomFire_X+random(3),RandomFire_Y+random(3),RandomFire_Z+random(2));
	FireObjects[fireslot][2] = CreateFire(fireslot, RandomFire_X-random(3),RandomFire_Y-random(3),RandomFire_Z-random(2));
 	FireObjects[fireslot][3] = CreateFire(fireslot, RandomFire_X+random(3),RandomFire_Y-random(3),RandomFire_Z+random(1));
	Get3DZone(RandomFire_X, RandomFire_Y, RandomFire_Z, zone, sizeof(zone));
	Fire[fireslot][Fire_Zone] = zone;
	FireHealth[fireslot] = 100;
	format(string, sizeof(string), "Fire Health: \n %d /100", FireHealth[fireslot]);
	FireHealthText[fireslot] = CreateDynamic3DTextLabel(string, COLOR_WHITE, RandomFire_X, RandomFire_Y, RandomFire_Z, 20);

    foreach(Player, i)
	{
        if(IsPlayerInCircle(i,RandomFire_X,RandomFire_Y,70))
		{
	        format(string, sizeof(string), "(INFO) A fire has erupted in the vicinity.");
	        SendClientMessage(i,COLOR_YELLOW,string);
        }
        if((PlayerInfo[i][pMember] == 4 && RAND < 24))
  		{
			new szMessage[256];
  		    new Float:x2,Float:y2,Float:z2;
	        GetPlayerPos(i,x2,y2,z2);
	        PlayAudioStreamForPlayer(i, "http://fg-rp.com/sounds/beep.mp3");
			
			format(szMessage, sizeof(szMessage), "* %s's pager just activated, you hear the sound.", GetPlayerNameEx(i));
    		ProxDetector(25.0, i, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    		if((IsPlayerInCircle(i, 1761.3842,-1783.0110, 15)) || (IsPlayerInCircle(i, 1760.6700,2082.7996, 15)))
	  		{
	  			PlayAudioStreamForPlayer(i, "http://fg-rp.com/sounds/beep.mp3");
	  		}
		}
        if((PlayerInfo[i][pMember] == 17 && RAND > 23))
  		{
			new szMessage[256];
  		    new Float:x2,Float:y2,Float:z2;
	        GetPlayerPos(i,x2,y2,z2);
	        PlayAudioStreamForPlayer(i, "http://fg-rp.com/sounds/beep.mp3");

			format(szMessage, sizeof(szMessage), "* %s's pager just activated, you hear the sound.", GetPlayerNameEx(i));
    		ProxDetector(25.0, i, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    		if((IsPlayerInCircle(i, 1761.3842,-1783.0110, 15)) || (IsPlayerInCircle(i, 1760.6700,2082.7996, 15)))
	  		{
	  			PlayAudioStreamForPlayer(i, "http://fg-rp.com/sounds/beep.mp3");
	  		}
		}
	}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)