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;
}
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);
}
}
|
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. |
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.
}
}
}
//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.
}
}
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.
}
}
}
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);
}
|
I wont script entirely for you but i can give you a small example to make you understand how it works.
PHP код:
PHP код:
PHP код:
PHP код:
Hope that helped. ![]() |
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" "
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);