help plz with afk system - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help plz with afk system (
/showthread.php?tid=299318)
help plz with afk system -
mineralo - 25.11.2011
PHP код:
#include <a_samp>
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define c_r 0xAA3333AA
new Float:lol[3];
new Float:vlol[3];
enum pooInfo
{
pAfk,
};
new ShitInfo[MAX_PLAYERS][pooInfo];
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("---------------------------------------");
print("---------AFK System by Dorin---------");
print("---------------------------------------");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
}
#endif
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/goafk", true))
{
if(ShitInfo[playerid][pAfk] == 0)
{
new a[1];
a[0] = playerid;
GetPlayerPos(playerid,Float:lol[0],Float:lol[1],Float:lol[2]);
SetTimerEx("AFK",5000,0,a[0]);
SendClientMessage(playerid,COLOR_YELLOW,"( ! ) Don't move ! Please wait 5 seconds...");
}
else
{
SendClientMessage(playerid,c_r,"( ! ) You already going in afk mode !");
}
return 1;
}
if(!strcmp(cmdtext, "/back", true))
{
new pName[MAX_PLAYER_NAME];
new string[48];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "( ! ) You are back from AFK mode");
SetPlayerVirtualWorld(playerid,0);
SendClientMessage(playerid, COLOR_GREY, string);
GameTextForPlayer(playerid,"~w~Welcome back",2000,3);
format(string, sizeof(string), "( ! ) %s is back from AFK mode", pName);
SendPlayerMessageToAll(COLOR_GREY, string);
TogglePlayerControllable(playerid,1);
ShitInfo[playerid][pAfk]=0;
return 1;
}
return 0;
}
forward AFK(playerid);
public AFK(playerid)
{
GetPlayerPos(playerid,Float:vlol[0],Float:vlol[1],Float:vlol[2]);
if(Float:lol[0] == Float:vlol[0])
{
ShitInfo[playerid][pAfk]=1;
new pName[MAX_PLAYER_NAME];
new string[48];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "( ! ) You are now in AFK mode");
SetPlayerVirtualWorld(playerid,1);
SendClientMessage(playerid, COLOR_GREY, string);
GameTextForPlayer(playerid,"~w~AFK Mode",2000,3);
format(string, sizeof(string), "( ! ) %s is now in AFK mode", pName);
SendPlayerMessageToAll(COLOR_GREY, string);
TogglePlayerControllable(playerid,0);
SendClientMessage(playerid, COLOR_WHITE,"( ! ) Type /back to go into game");
return 1;
}
else
{
SendClientMessage(playerid,c_r,"( ! ) Going in afk mode was cancel reason: You moved !");
}
return 0;
}
I made afk system, if you want go in afk mode you have to wait 5sec and then you will go into but it's don't work, help PLEASE !!
Re: help plz with afk system -
Kostas' - 25.11.2011
pawn Код:
SetTimerEx("AFK",5000,0,a[0]);
I don't see any format[] on this line.
Re: help plz with afk system -
SmiT - 25.11.2011
As Kostas' said you didn't enlist any specifier, what you can do is store the playerid in the timer but also the player position:
pawn Код:
SetTimerEx( #AFK, 5000, 0, #ifff, a[ 0 ], lol[ 0 ], lol[ 1 ], lol[ 2 ] );
So you're AFK function would become for example:
pawn Код:
forward AFK( playerid, &Float:X, &Float:Y, &Float:Z );