Add fire to House Entrance!
#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


Messages In This Thread
Add fire to House Entrance! - by MrTea - 07.05.2017, 08:56
Re: Add fire to House Entrance! - by YouHack - 07.05.2017, 10:33
Re: Add fire to House Entrance! - by MrTea - 07.05.2017, 11:09
Re: Add fire to House Entrance! - by YouHack - 07.05.2017, 11:11
Re: Add fire to House Entrance! - by MrTea - 07.05.2017, 12:59
Re: Add fire to House Entrance! - by GTLS - 08.05.2017, 11:39
Re: Add fire to House Entrance! - by MrTea - 08.05.2017, 23:44
Re: Add fire to House Entrance! - by GTLS - 09.05.2017, 06:28
Re: Add fire to House Entrance! - by zedshadowzw - 09.05.2017, 06:58
Re: Add fire to House Entrance! - by MrTea - 09.05.2017, 10:45

Forum Jump:


Users browsing this thread: 1 Guest(s)