Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*--S-AFK system created by simo0000--*/
- #include <a_samp>
- #include <ZCMD>
- #include <sscanf2>
- #include <foreach>
- #include <YSI\y_timers>
- #pragma tabsize 0
- new AFKTime[MAX_PLAYERS];
- new Text3D:AFKLabel[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("S-AFK system by simo0000 is loaded.");
- print("--------------------------------------\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SetPVarInt(playerid, "AFK", 0);
- AFKTime[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SetPVarInt(playerid, "AFK", 0);
- AFKTime[playerid] = 0;
- return 1;
- }
- public OnPlayerText(playerid,text[])
- {
- if(GetPVarInt(playerid, "AFK") == 1) return SendClientMessage(playerid, 0xAA3333AA, "You cannot talk while you are in AFK MODE."), 0;
- return 1;
- }
- stock GetName(playerid)
- {
- new name[24];
- GetPlayerName(playerid, name, sizeof(name));
- return name;
- }
- task AfkTimer[1000]()
- {
- foreach(new i: Player)
- {
- if(GetPVarInt(i, "AFK") == 1)
- {
- AFKTime[i]++;
- }
- }
- return 1;
- }
- CMD:afklist(playerid)
- {
- new
- AFKCount = 0, String[1024];
- SendClientMessage(playerid, 0x33CCFFAA, "| AFK List |");
- foreach(new i: Player)
- {
- if(GetPVarInt(i, "AFK") == 1)
- {
- format(String, sizeof(String), "%s >> AFK (%d secondes)", GetName(i), AFKTime[i]);
- SendClientMessage(playerid, -1, String);
- AFKCount++;
- }
- }
- if(AFKCount == 0) return SendClientMessage(playerid, -1, "There is no players AFK.");
- return 1;
- }
- CMD:afk(playerid)
- {
- new string[128];
- if(GetPVarInt(playerid, "AFK") == 1) return SendClientMessage(playerid, 0xAA3333AA, "You are already AFK");
- SendClientMessage(playerid, 0x33CCFFAA, "You are now AFK, You can't move or talk.!");
- TogglePlayerControllable(playerid,0);
- SetPVarInt(playerid, "AFK", 1);
- AFKLabel[playerid] = Create3DTextLabel("[Away from keyboard]",0xFF9900AA,30.0,40.0,50.0,40.0,0);
- Attach3DTextLabelToPlayer(AFKLabel[playerid], playerid, 0.0, 0.0, 0.7);
- format(string, sizeof(string), "%s is now Away from the keyboard!", GetName(playerid));
- SendClientMessageToAll(0xFFFF00AA, string);
- return 1;
- }
- CMD:back(playerid)
- {
- new string[128];
- if(GetPVarInt(playerid, "AFK") == 0) return SendClientMessage(playerid, 0xAA3333AA, "You are not AFK");
- SendClientMessage(playerid, 0x33CCFFAA, "You are now back from AFK, Welcome back!");
- TogglePlayerControllable(playerid,1);
- SetPVarInt(playerid, "AFK", 0);
- AFKTime[playerid] = 0;
- format(string, sizeof(string), "%s is now Back!", GetName(playerid));
- SendClientMessageToAll(0xFFFF00AA, string);
- Delete3DTextLabel(Text3D:AFKLabel[playerid]);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement