Need some help on loop
#1

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
Reply
#2

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
Reply
#3

Thanks!
Reply
#4

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.
Reply
#5

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


Forum Jump:


Users browsing this thread: 1 Guest(s)