10.04.2014, 17:47
Let's say MAX_PLAYERS is 50. The array will have indexes from 0-49. Each index is unique for playerid.
About arrays: https://sampwiki.blast.hk/wiki/Scripting_Basics#Arrays
https://sampforum.blast.hk/showthread.php?tid=318212
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;
}
}
}
https://sampforum.blast.hk/showthread.php?tid=318212