Check every 5s help
#7

Let's say MAX_PLAYERS is 50. The array will have indexes from 0-49. Each index is unique for playerid.

pawn Код:
#define FILTERSCRIPT

#include <a_samp>
   
// If you don't want MAX_PLAYERS as 500:
//#undef MAX_PLAYERS
//#define MAX_PLAYERS (x)
// Change "x" to the number you want.

new Something_Timer;
new b[MAX_PLAYERS];

public OnFilterScriptInit()
{
    Something_Timer = SetTimer("OnSomethingUpdate", 5000, true);
    return 1;
}

public OnFilterScriptExit()
{
    KillTimer(Something_Timer);
    return 1;
}

public OnPlayerConnect(playerid)
{
    b[playerid] = 30;
    return 1;
}

forward OnSomethingUpdate();
public OnSomethingUpdate()
{
    new Float:x, Float:y, Float:z;
    for (new playerid; playerid != MAX_PLAYERS; ++playerid)
    {
        if (!IsPlayerConnected(playerid)) continue;
        SendClientMessage(playerid,-1,"Preostalo vam je jos kiseonika za 15s ronjenja");
        GetPlayerPos(playerid, x, y, z);
        if(z<=0)
        {
            b[playerid] -= 5;
            if (b[playerid]=15) SendClientMessage(playerid,-1,"Preostalo vam je jos kiseonika za 15s ronjenja");
            else if (b[playerid]=5) SendClientMessage(playerid,-1,"Preostalo vam je jos kiseonika za 5s ronjenja");
            else if (b[playerid]=0)
            {
                SetPlayerHealth(playerid, 0);
                b[playerid]=30;
            }
        }
        if (z>0)
        {
            b[playerid]=30;
        }
    }
}
About arrays: https://sampwiki.blast.hk/wiki/Scripting_Basics#Arrays
https://sampforum.blast.hk/showthread.php?tid=318212
Reply


Messages In This Thread
Check every 5s help - by jovapeba - 10.04.2014, 17:04
Re: Check every 5s help - by Konstantinos - 10.04.2014, 17:11
Re: Check every 5s help - by Patrick - 10.04.2014, 17:12
Re: Check every 5s help - by jovapeba - 10.04.2014, 17:31
Re: Check every 5s help - by Konstantinos - 10.04.2014, 17:38
Re: Check every 5s help - by jovapeba - 10.04.2014, 17:41
Re: Check every 5s help - by Konstantinos - 10.04.2014, 17:47

Forum Jump:


Users browsing this thread: 1 Guest(s)