26.04.2012, 00:42
I'm really sick of it i'm very tired i cannot find the solution on the problem
when i try /afk it freeze me but when i try second /afk it still doesn't unfreeze me
TogglePlayerAFK - true (freeze) : false (unfreeze)
here is exactly what i did
even if i make it if statement it make nonsense it still the same
Include Code
when i try /afk it freeze me but when i try second /afk it still doesn't unfreeze me
TogglePlayerAFK - true (freeze) : false (unfreeze)
here is exactly what i did
pawn Код:
CMD:afk(playerid, params[])
{
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
switch(GetPlayerAFKToggle(playerid))
{
case 0:
{
TogglePlayerAFK(playerid, true);
format(string, 128, "%s(%d) are Away from his Keyboard!", name, playerid);
SendClientMessageToAll(-1, string);
SendClientMessage(playerid, -1, "You are away from your keyboard!");
}
case 1:
{
TogglePlayerAFK(playerid, false);
format(string, 128, "%s(%d) are Back from his Keyboard!", name, playerid);
SendClientMessageToAll(-1, string);
SendClientMessage(playerid, -1, "You are back from your keyboard!");
}
}
return 1;
}
Include Code
pawn Код:
#if defined _roAFK_included
#endinput
#endif
#define _roAFK_included
#include <a_samp>
#include <YSI\y_hooks>
new AFKing[MAX_PLAYERS],
AFKTimer[MAX_PLAYERS];
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");
}
#else
hook roAFK_OnGameModeInit()
{
print("Your gamemode is using RollTi's Afficient AFK v1.0");
}
#endif
stock TogglePlayerAFK(playerid, bool:toggle)
{
new Float:hp;
GetPlayerHealth(playerid, hp);
if(toggle == false)
{
TogglePlayerControllable(playerid, 1);
AFKing[playerid] = 1;
SetPlayerHealth(playerid, hp);
KillTimer(AFKTimer[playerid]);
}
else if(toggle == true)
{
SetPlayerHealth(playerid, 9999999.9);
TogglePlayerControllable(playerid, 0);
AFKing[playerid] = 0;
AFKTimer[playerid] = SetTimerEx("OnPlayerAFK", 300000, false, "d", playerid);
}
return 1;
}
stock GetPlayerAFKToggle(playerid)
{
return AFKing[playerid];
}