05.02.2014, 15:25
(
Последний раз редактировалось ZBits; 16.08.2014 в 20:32.
)
Fixed
public f_OnPlayerUpdate(playerid)
{
for(new a = 0; a < MAX_PLAYERS; a++)
{
if(pInfo[a][pMission] == 1)
{
new newkeys,l,u;
GetPlayerKeys(a, newkeys, l, u);
new i;
if(Holding(KEY_FIRE))
{
if(GetPlayerWeapon(a) == 42)
{
for(i = 0; i<MaxFire; i++)
{
if(IsValidFire(i))
{
if(PlayerFaces(a, FirePos[i][0], FirePos[i][1], FirePos[i][2], 1) && IsPlayerInRangeOfPoint(playerid, 4, FirePos[i][0], FirePos[i][1], FirePos[i][2]))
{
FireHealth[i]-=1;
#if defined Labels
new string[128];
format(string, sizeof(string), "Fire Source\n%d/%d", FireHealth[i], FireHealthMax[i]);
Update3DTextLabelText(FireText[i], 0x49E843FF, string);
//Delete3DTextLabel(FireText[i]);
//FireText[i] = Create3DTextLabel(string, 0xFFFFFFFF, FirePos[i][0], FirePos[i][1], FirePos[i][2], 20, 0);
#endif
if(FireHealth[i] <= 0)
{
new randa = randal(200, 350);
DeleteFire(i);
CallRemoteFunction("OnFireKill", "dd", i, a);
SendClientMessage(a,COLOR_LAWNGREEN,"You have extinguished a fire source");
GivePlayerMoney(a,randa);
format(string,sizeof(string),"No. Of Fire Sources: %d",TotalFires);
TextDrawSetString(Text:Textdraw1,string);
if(IsPlayerInRangeOfPoint(a, 4.0, FirePos[i][0], FirePos[i][1], FirePos[i][2]))
{
new mo = randal(3000, 3500);
GivePlayerMoney(a,mo);
}
}
if(TotalFires == 0)
{
SendClientMessage(a, COLOR_LAWNGREEN, "Mission Over");
mission = 0;
if(mission == 0)
{
TextDrawHideForPlayer(a, Textdraw0);
TextDrawHideForPlayer(a, Textdraw1);
TextDrawHideForPlayer(a, Textdraw3);
}
}
}
}
}
}
}
}
}
return 1;
}
public f_OnPlayerUpdate(playerid)
{
if(pInfo[playerid][pMission] != 1)
{
// if the current player is not on a mission, do not continue
return 1; // important to return 1 or the player will desync
}
// current player is on a mission, check if (s)he is fighting a fire
new newkeys,l,u;
GetPlayerKeys(playerid, newkeys, l, u);
if (!(Holding(KEY_FIRE))) return 1;
if (GetPlayerWeapon(playerid) != 42) return 1;
new i, randa;
new string[128];
// search for the fire(s) the player fighting against
for (i = 0; i<MaxFire; i++)
{
if (!IsValidFire(i)) continue;
if (!IsPlayerInRangeOfPoint(playerid, 4, FirePos[i][0], FirePos[i][1], FirePos[i][2])) continue;
if (!PlayerFaces(playerid, FirePos[i][0], FirePos[i][1], FirePos[i][2], 1)) continue;
FireHealth[i]--;
#if defined Labels
format(string, sizeof(string), "Fire Source\n%d/%d", FireHealth[i], FireHealthMax[i]);
Update3DTextLabelText(FireText[i], 0x49E843FF, string);
#endif
if(FireHealth[i] > 0) continue;
DeleteFire(i);
// NOTICE:
// maybe you need to decrement TotalFires by one here
// If your DeleteFire function decrements it, you don't need to uncomment this line:
//TotalFires--;
//
CallRemoteFunction("OnFireKill", "dd", i, playerid);
SendClientMessage(playerid,COLOR_LAWNGREEN,"You have extinguished a fire source");
randa = randal(200, 350);
GivePlayerMoney(playerid, randa);
format(string,sizeof(string),"No. Of Fire Sources: %d",TotalFires);
TextDrawSetString(Text:Textdraw1,string);
if (TotalFires > 0) continue;
// Mission is over. Now loop through all players and give reward
for (new a=0; a < MAX_PLAYERS; a++) // if you have a foreach include, use that instead
{
if (!IsPlayerConnected(a)) continue;
if (pInfo[a][pMission] != 1) continue;
// If you don't want to check if the player is in range of the fire, comment the following line
if (!IsPlayerInRangeOfPoint(a, 4.0, FirePos[i][0], FirePos[i][1], FirePos[i][2])) continue;
SendClientMessage(a, COLOR_LAWNGREEN, "Mission Over");
randa = randal(3000, 3500);
GivePlayerMoney(a, randa);
// Maybe you want to set the player's mission to 0 here.
// Comment the following line if you don't want to.
pInfo[a][pMission] = 0;
TextDrawHideForPlayer(a, Textdraw0);
TextDrawHideForPlayer(a, Textdraw1);
TextDrawHideForPlayer(a, Textdraw3);
}
// Mission is over, no need to loop on further fires because there aren't any
return 1;
}
return 1;
}