09.05.2017, 06:28
I wont script entirely for you but i can give you a small example to make you understand how it works.
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];
Now we detect if he is Extingushing the fire. for that we will use OnPlayerKeyStateChange.
Now we create Timer Public.
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.
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 a = random(0, MAX_HOUSES+1);
FireObject = CreateObject(18691, HouseInfo[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(Player, i)
{
if(IsAParamedic(i)) // Your Variable for if he is a Fire Fighter or not.
{
SendClientMessage(i, COLOR, "---Fire Dispatch ---");
format(string, sizeof(string), "Fire Was Seen at %s`s House.",HouseInfo[a][hOwner]);
SendClientMessage(i,COLOR2, string);
SendClientMessage(i,COLOR3, "Please Fire Fighters Respond to the call."); //Or what ever your Messages are.
SetPlayerCheckPoint(i, HouseInfo[a][hEntranceX],HouseInfo[a][hEntranceY],HouseInfo[a][hEntranceZ],5); //This is like a optional thing to trigger Fire Fighter thing.
}
}
}
PHP код:
//Now we trigger that FireFighter is there. and for that we use, OnPlayerEnterCheckpoint.
public OnPlayerEnterCheckpoint(playerid)
{
if(RespondedToFire[playerid] == 1)
{
SendClientMessage(playerid, COLOR, "You are at the Random Fire Location. Take Out your Extingusher.");
IsAtFire[playerid] = 1; //Global Variable.
}
}
PHP код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_FIRE) && RespondedToFire[playerid] == 1 && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && IsAtFire[playerid] == 1) //You can also check here if he has a Extingusher or not.
{
FireTimer[playerid] = SetTimerEx("PuttingOutFire",180000, false, "i",playerid); // its just a timer.
}
}
}
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);
}
Hope that helped.



