Giving Money to all fireman
#1

Fixed
Reply
#2

Your problem is in your "if's" it doesn't allow the script to proceed.
Reply
#3

if player have one thing (proceed)

else if player have another thing (proceed)
Reply
#4

Well i am pretty aware of that, The textdraw updates for every prrson who has pMission =1 so whenever a fire source is extinguished it updates the textdraw strig but when the last fire is put out it gives the money only to the person who put it out and not everyone who is involved in the mission,when the mission is over The textdraw should be destroyed for all fireman but as said when the last fire is put out it destroyes it only for the person who extinguishrd the fire source
Reply
#5

i tired some different stuff but still no luck, if you guys could locate a problem with the code provided it would be a great help.
Reply
#6

Its been a couple of days since i am looking for a solution. Please help.
Reply
#7

pawn Код:
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;
}
Test this
Reply
#8

Nope does not work. Still need help, this is a very important part of my script and it has caused a cease to my development
Reply
#9

Please go through line-by-line because there are a few options which are up to you.
pawn Код:
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;
}
Reply
#10

+rped, it worked, thanks for explaining as well
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)