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


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: 2 Guest(s)