26.04.2012, 02:14
Try this:
pawn Код:
#include <a_samp>
#include <YSI\y_hooks>
#define GetPlayerAFKToggle(%0) \
AFKing[%0]
new bool:AFKing[MAX_PLAYERS char];
forward OnPlayerAFK(playerid);
/*
native TogglePlayerAFK(playerid, toggle);
native GetPlayerAFK(playerid);
*/
#if defined _FILTERSCRIPT_
hook roAFK_OnFilterScriptInit()
{
print("Your filterscript is using RollTi's Afficient AFK v1.0");
SetTimer("eOnPlayerAFK", 300000, true);
}
#else
hook roAFK_OnGameModeInit()
{
print("Your gamemode is using RollTi's Afficient AFK v1.0");
}
#endif
stock TogglePlayerAFK(playerid, bool:toggle)
{
static Float:hp; GetPlayerHealth(playerid, hp);
if(!toggle)
{
TogglePlayerControllable(playerid, true);
SetPlayerHealth(playerid, hp);
KillTimer(AFKTimer[playerid]);
AFKing{playerid} = true;
}
if(toggle == true)
{
SetPlayerHealth(playerid, 9999999.9);
TogglePlayerControllable(playerid, 0);
AFKing{playerid} = true;
}
return 1;
}
eOnPlayerAfk(); public eOnPlayerAfk()
{
for(new i, e = GetMaxPlayers(); i != e; ++i){
if(IsPlayerConnected(i)) {
if(AFKing{i}){
CallLocalFunction("OnPlayerAFK", "i", i);
}
}
}
return 1;
}