Add fire to House Entrance!
#1

Hello, Does anyone know how to add randomly fire to houses? And when fire is up to send message to firemans?
I find a code , but i didn't know if it's right!
Код:
forward AddFiresHouse(houseid);
public AddFiresHouse(houseid)
{
	for(new i = 1;i< 1000; i++)
    {
    	if(FireObjHouse[i] == 0)
     	{
			new ID = i;
			new Float:x1, Float:y1, Float:z1;
			x1 = HouseData[houseid][hEntrancex];
			y1 = HouseData[houseid][hEntrancey];
			z1 = HouseData[houseid][hEntrancez];
			FireObjHouse[ID] = CreateObject(18688, x1, y1, z1, 0, 0, 0.0);
			i = 10001;
			FireHouse[1][houseid] = FireObjHouse[ID];
			TotalFires++;
			FiresHouse[houseid]++;
			FireHealthHouse[1][houseid] = 15;
			for(new j = 1;j< 1000; j++)
		    {
		    	if(FireObjHouse[j] == 0)
		     	{
   				 	ID = j;
					new Float:x2, Float:y2, Float:z2;
					x2 = HouseData[houseid][hEntrancex];
					y2 = HouseData[houseid][hEntrancey];
					z2 = HouseData[houseid][hEntrancez];
					FireObjHouse[ID] = CreateObject(18688, x2, y2, z2, 0, 0, 0.0);
					j = 10001;
					FireHouse[2][houseid] = FireObjHouse[ID];
					TotalFires++;
					FiresHouse[houseid]++;
					FireHealthHouse[2][houseid] = 28;
					for(new k = 1;k< 1000; k++)
				    {
				    	if(FireObjHouse[k] == 0)
				     	{
							ID = k;
							new Float:x3, Float:y3, Float:z3;
							x3 = HouseData[houseid][hEntrancex];
							y3 = HouseData[houseid][hEntrancey];
							z3 = HouseData[houseid][hEntrancez];
							FireObjHouse[ID] = CreateObject(18688, x3, y3, z3, 0, 0, 0.0);
							k = 10001;
							FireHouse[3][houseid] = FireObjHouse[ID];
							TotalFires++;
							FiresHouse[houseid]++;
							FireHealthHouse[3][houseid] = 46;
							for(new l = 1;l< 1000; l++)
						    {
						    	if(FireObjHouse[l] == 0)
						     	{
									ID = l;
									new Float:x4, Float:y4, Float:z4;
									x4 = HouseData[houseid][hEntrancex];
									y4 = HouseData[houseid][hEntrancey];
									z4 = HouseData[houseid][hEntrancez];
									FireObjHouse[ID] = CreateObject(18688, x4, y4, z4, 0, 0, 0.0);
									l = 10001;
									FireHouse[4][houseid] = FireObjHouse[ID];
									TotalFires++;
									FiresHouse[houseid]++;
									FireHealthHouse[4][houseid] = 65;
									for(new h = 1;h< 1000; h++)
								    {
								    	if(FireObjHouse[h] == 0)
								     	{
											ID = h;
											new Float:x5, Float:y5, Float:z5;
											x5 = HouseData[houseid][hEntrancex];
											y5 = HouseData[houseid][hEntrancey];
											z5 = HouseData[houseid][hEntrancez];
											FireObjHouse[ID] = CreateObject(18688, x5, y5, z5, 0, 0, 0.0);
											h = 10001;
											FireHouse[5][houseid] = FireObjHouse[ID];
											TotalFires++;
											FiresHouse[houseid]++;
											FireHealthHouse[5][houseid] = 88;
										}
									}
								}
							}
						}
					}
				}
			}

		}
	}
	return 1;
}
Who can help me?
Reply
#2

test it first.
Reply
#3

Quote:
Originally Posted by YouHack
Посмотреть сообщение
test it first.
Not Work
Reply
#4

What's happening , what type of bug you're facing !!?
Reply
#5

Edit:
I have another public
Код:
public Production()
{
	medicev += 5;
	if(medicev == 20)
	{
        medicev = 0;
		new string[256];
		foreach(Player,i)
		{
			if(IsPlayerConnected(i))
			{
			    if(PlayerInfo[i][pMember] == 14)
			    {
           	    	if(CP[i] == 43 || CP[i] == 0 && Line1busck[i] == 0 && Line2busck[i] == 0 && MechanicCallTime[i] == 0 && MedicCallTime[i] == 0 && TaxiCallTime[i] == 0 && woodl[i] == 0 && petrolt[i] == 0 && petrolt2[i] == 0  && pizzaj[i] == 0 && IsCollectingRubbish[i] == 0
					&& PlayerInfo[i][pChicken] == 0 && balem[i] == 0 && playerrace[i] == 0 && explosion[i] == 0 && playerraces[i] == 0 && taxim[i] == 0 && towcarm[i] == 0
					&& nrmission[i] == 0)
					{
					    new rand = random(sizeof(gRandomExplosion));
					    expx[i] = gRandomExplosion[rand][0];
						expy[i] = gRandomExplosion[rand][1];
						expz[i] = gRandomExplosion[rand][2];
					    format(string,sizeof(string),"EN: ** A fire broke out, go to the red point and stop it for reject mission Type /cancel pmission.");
						SCM(i,COLOR_LIGHTRED,string);
					    format(string,sizeof(string),"RO: ** A pornit un incendiu, mergi la punctul rosu de pe harta si opreste-l, pentru a respinge misiunea Type /cancel pmission.");
						SCM(i,COLOR_LIGHTRED,string);
						explosion[i] = 1;
						SetPlayerCheckpoint(i,gRandomExplosion[rand][0],gRandomExplosion[rand][1],gRandomExplosion[rand][2],4.0);
					}
			    }
But not any Explosion shows up
Reply
#6

Try Using ptask as a timer for every 10 min or 20 min what ever you want and use CreateObject on hEntranceX,Y,Z.
Or may be a Separate Timer using SetTimerEx() with a Call back to add Fire. For a Improved code, Set Repeat to False and Once the Fire Object is Destroyed by Fire Fighters, you re-start that Random Fire timer.
Reply
#7

Quote:
Originally Posted by GTLS
Посмотреть сообщение
Try Using ptask as a timer for every 10 min or 20 min what ever you want and use CreateObject on hEntranceX,Y,Z.
Or may be a Separate Timer using SetTimerEx() with a Call back to add Fire. For a Improved code, Set Repeat to False and Once the Fire Object is Destroyed by Fire Fighters, you re-start that Random Fire timer.
Can you do that public with timer for me please?
Reply
#8

Quote:
Originally Posted by MrTea
Посмотреть сообщение
Can you do that public with timer for me please?
I wont script entirely for you but i can give you a small example to make you understand how it works.


PHP код:
OnGameModeInit()
{
      
Add SetTimer("RandFireTimer",600000,false); //600 Seconds. means 10 Min. Change 600000 to what ever you want.(seconds X 1000).  
}
//First We Forward the Public Timer.
forward RandFireTimer();
//Then Public.
public RandFireTimer()
{
   
     new 
random(0MAX_HOUSES+1);
     
FireObject CreateObject(18691HouseInfo[a][hEntranceX],HouseInfo[a][hEntranceY],HouseInfo[a][hEntranceZ],0,0,0,10); //the Object ID for Fire is 18691. There are other Fire Objects too. Set the Rotation according to your needs. Also remember to declare FireObject Globally above this.
     
    
foreach(Playeri)
    {
            if(
IsAParamedic(i)) // Your Variable for if he is a Fire Fighter or not.
            
{
                  
SendClientMessage(iCOLOR"---Fire Dispatch ---");
                 
format(stringsizeof(string), "Fire Was Seen at %s`s House.",HouseInfo[a][hOwner]); 
                 
SendClientMessage(i,COLOR2string);
                  
SendClientMessage(i,COLOR3"Please Fire Fighters Respond to the call.");   //Or what ever your  Messages are.                  
                   
SetPlayerCheckPoint(iHouseInfo[a][hEntranceX],HouseInfo[a][hEntranceY],HouseInfo[a][hEntranceZ],5); //This is like a optional thing to trigger Fire Fighter thing.
            
}
   }
     

You Have to make a Command which sets something in a variable to check if he responded to the call.i will use RespondedToFire[playerid]. you have to Declare the variable Globally. like, new RespondedToFire[MAX_PLAYERS];

PHP код:
//Now we trigger that FireFighter is there. and for that we use, OnPlayerEnterCheckpoint.
public OnPlayerEnterCheckpoint(playerid)
{
    if(
RespondedToFire[playerid] == 1)
    {
             
SendClientMessage(playeridCOLOR"You are at the Random Fire Location. Take Out your Extingusher.");
             
IsAtFire[playerid] = 1//Global Variable.
    
}

Now we detect if he is Extingushing the fire. for that we will use OnPlayerKeyStateChange.

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys == KEY_FIRE) && RespondedToFire[playerid] == && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && IsAtFire[playerid] == 1//You can also check here if he has a Extingusher or not.
   
{
             
                
FireTimer[playerid] = SetTimerEx("PuttingOutFire",180000false"i",playerid); // its just a timer.
    
}
    }

Now we create Timer Public.
PHP код:
forward PuttingOutFire(playerid);
public 
PuttingOutFire(playerid)
{
          
DestroyObject(FireObject);
         
SendClientMessage(playerid,COLOR"You have Extingushed the Fire.");
        
DisablePlayerCheckpoint(playerid);
        
RespondedToFire[playerid] = 0;
           
SetTimer("RandFireTimer",600000,false);

What ever i created is a Example, you will have to make changes according to your needs. i posted this from my phone, so didnt had time to check if it works or not. if you get any error, ask us here.

Hope that helped.
Reply
#9

There has to be filterscript that involves fire out there!
Reply
#10

Quote:
Originally Posted by GTLS
Посмотреть сообщение
I wont script entirely for you but i can give you a small example to make you understand how it works.


PHP код:
OnGameModeInit()
{
      
Add SetTimer("RandFireTimer",600000,false); //600 Seconds. means 10 Min. Change 600000 to what ever you want.(seconds X 1000).  
}
//First We Forward the Public Timer.
forward RandFireTimer();
//Then Public.
public RandFireTimer()
{
   
     new 
random(0MAX_HOUSES+1);
     
FireObject CreateObject(18691HouseInfo[a][hEntranceX],HouseInfo[a][hEntranceY],HouseInfo[a][hEntranceZ],0,0,0,10); //the Object ID for Fire is 18691. There are other Fire Objects too. Set the Rotation according to your needs. Also remember to declare FireObject Globally above this.
     
    
foreach(Playeri)
    {
            if(
IsAParamedic(i)) // Your Variable for if he is a Fire Fighter or not.
            
{
                  
SendClientMessage(iCOLOR"---Fire Dispatch ---");
                 
format(stringsizeof(string), "Fire Was Seen at %s`s House.",HouseInfo[a][hOwner]); 
                 
SendClientMessage(i,COLOR2string);
                  
SendClientMessage(i,COLOR3"Please Fire Fighters Respond to the call.");   //Or what ever your  Messages are.                  
                   
SetPlayerCheckPoint(iHouseInfo[a][hEntranceX],HouseInfo[a][hEntranceY],HouseInfo[a][hEntranceZ],5); //This is like a optional thing to trigger Fire Fighter thing.
            
}
   }
     

You Have to make a Command which sets something in a variable to check if he responded to the call.i will use RespondedToFire[playerid]. you have to Declare the variable Globally. like, new RespondedToFire[MAX_PLAYERS];

PHP код:
//Now we trigger that FireFighter is there. and for that we use, OnPlayerEnterCheckpoint.
public OnPlayerEnterCheckpoint(playerid)
{
    if(
RespondedToFire[playerid] == 1)
    {
             
SendClientMessage(playeridCOLOR"You are at the Random Fire Location. Take Out your Extingusher.");
             
IsAtFire[playerid] = 1//Global Variable.
    
}

Now we detect if he is Extingushing the fire. for that we will use OnPlayerKeyStateChange.

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys == KEY_FIRE) && RespondedToFire[playerid] == && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && IsAtFire[playerid] == 1//You can also check here if he has a Extingusher or not.
   
{
             
                
FireTimer[playerid] = SetTimerEx("PuttingOutFire",180000false"i",playerid); // its just a timer.
    
}
    }

Now we create Timer Public.
PHP код:
forward PuttingOutFire(playerid);
public 
PuttingOutFire(playerid)
{
          
DestroyObject(FireObject);
         
SendClientMessage(playerid,COLOR"You have Extingushed the Fire.");
        
DisablePlayerCheckpoint(playerid);
        
RespondedToFire[playerid] = 0;
           
SetTimer("RandFireTimer",600000,false);

What ever i created is a Example, you will have to make changes according to your needs. i posted this from my phone, so didnt had time to check if it works or not. if you get any error, ask us here.

Hope that helped.
Thank you for speding time with me, i tryed your tutorial but i didn't have MaxHouses where i cand define it?And i have some warnings.
Код:
error 017: undefined symbol "MAX_HOUSES"
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition
warning 204: symbol is assigned a value that is never used: "FireObject"
"
Lines with warning
Код:
new a = random(0, MAX_HOUSES+1);
Код:
  if(IsAParamedic(i))
Код:
FireObject = CreateObject(18691, HouseInfo[a][hEntrancex],HouseInfo[a][hEntrancey],HouseInfo[a][hEntrancez],0,0,0,10);
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)