SA-MP Forums Archive
Need some help on loop - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need some help on loop (/showthread.php?tid=441810)



Need some help on loop - Zigonja - 04.06.2013

pawn Код:
// What should I be putting here
{

    if (PlayerInfo[playerid][prodshp] == 1)
    {
        if(GetPlayerHealth(i))
        {
            new Float:health;
            GetPlayerHealth(playerid,health);
            if (health < 10.0)
            {
                (PlayerInfo[playerid][prodshp] == 0)
                SendClientMessage(playerid, COLOR_GREEN, "Don't forget to wear safety equipment, to prevent hurting yourself!");
            }
        }
    }
    return 1;
}
So I want to make the loop that would be checking that but, I can't figure out how to do it


Re: Need some help on loop - NvidiaForTheWin - 04.06.2013

on top
Код:
new timer1;
( OnGameModeInit )
Код:
timer1 = SetTimer("MyCheckingFunction", 5000, true);
Код:
forward MyCheckingFunction(playerid);
public MyCheckingFunction(playerid)
{
    if (PlayerInfo[playerid][prodshp] == 1)
    {
        if(GetPlayerHealth(i))
        {
            new Float:health;
            GetPlayerHealth(playerid,health);
            if (health < 10.0)
            {
                (PlayerInfo[playerid][prodshp] == 0)
                SendClientMessage(playerid, COLOR_GREEN, "Don't forget to wear safety equipment, to prevent hurting yourself!");
            }
        }
    }
}
i don't know if its what you are asking for


Re: Need some help on loop - Zigonja - 04.06.2013

Thanks!


Re: Need some help on loop - [DOG]irinel1996 - 04.06.2013

Quote:
Originally Posted by NvidiaForTheWin
Посмотреть сообщение
on top
Код:
new timer1;
( OnGameModeInit )
Код:
timer1 = SetTimer("MyCheckingFunction", 5000, true);
Код:
forward MyCheckingFunction(playerid);
public MyCheckingFunction(playerid)
{
    if (PlayerInfo[playerid][prodshp] == 1)
    {
        if(GetPlayerHealth(i))
        {
            new Float:health;
            GetPlayerHealth(playerid,health);
            if (health < 10.0)
            {
                (PlayerInfo[playerid][prodshp] == 0)
                SendClientMessage(playerid, COLOR_GREEN, "Don't forget to wear safety equipment, to prevent hurting yourself!");
            }
        }
    }
}
i don't know if its what you are asking for
Actually, that's not a good solution, where's the playerid source? I mean you used playerid and it doesn't run for all players, just for ID 0 because there isn't any script sending the ID to MyCheckingFunction.

Give a try to this one:
pawn Код:
new gTimer;

//---OnGameModeInit
gTimer = SetTimer("WarnPlayersAboutHealth", 600000, true); /* 600000 miliseconds = 10 minutes */

//---Somewhere
stock WarnPlayersAboutHealth() {

    new Float:health;

    for (new x; x < MAX_PLAYERS; x++) {

        if (PlayerInfo[x][prodshp] != 1) continue;

        GetPlayerHealth(x, health);
        if (health < 10.0) {
            PlayerInfo[x][prodshp] == 0;
            SendClientMessage(x, -1, "Don't forget to wear safety equipment, to prevent hurting yourself!");
        }
    }
    return 1;
}
Regards.


Re: Need some help on loop - NvidiaForTheWin - 04.06.2013

oh.. f**k my life... playerid have nothing to here