1Geek

AFK System by 1Geek

Aug 13th, 2013
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.56 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. //Created by 1Geek, Please don't remove the credits !
  4.  
  5. new names[24], string[128];
  6. new PlayerText3D:afktext;
  7. new IsAfk[MAX_PLAYERS];
  8.  
  9. public OnFilterScriptInit()
  10. {
  11.     print("\n--------------------------------------");
  12.     print(" Script created by 1Geek");
  13.     print("--------------------------------------\n");
  14.     return 1;
  15. }
  16.  
  17. public OnPlayerCommandText(playerid, cmdtext[])
  18. {
  19.  
  20.     new Float:X, Float:Y, Float:Z;
  21.    
  22.     GetPlayerName(playerid, names, sizeof(names));
  23.    
  24.     if (strcmp("/afk", cmdtext, true, 10) == 0)
  25.     {
  26.         if(IsAfk[playerid]) return SendClientMessage(playerid, 0xADD8E6FF, "You're already in AFK mode.");
  27.         IsAfk[playerid] = 1;
  28.         TogglePlayerControllable(playerid, 0);
  29.         format(string,sizeof(string),"%s {FFFFFF} is now in AFK mode.", names);
  30.         SendClientMessageToAll(0xADD8E6FF, string);
  31.         GetPlayerPos(playerid, X, Y, Z);
  32.         afktext = CreatePlayer3DTextLabel(playerid,"{FF0000}I'm in AFK Mode :P.",0x008080FF, X,Y,Z,40.0);
  33.         return 1;
  34.     }
  35.     if (strcmp("/back", cmdtext, true, 10) == 0)
  36.     {
  37.         if(IsAfk[playerid] == 1)
  38.         {
  39.             Afk_Back(playerid);
  40.         }
  41.         else
  42.           SendClientMessage(playerid, 0xADD8E6FF, "You're not in AFK mode.");
  43.         return 1;
  44.     }
  45.     return 0;
  46. }
  47.  
  48. /*public OnPlayerStateChange(playerid, newstate, oldstate)
  49. {
  50.     if(IsAfk[playerid] == 1)
  51.     {
  52.         Afk_Back(playerid);
  53.     }
  54.     else
  55.        SendClientMessage(playerid, 0xADD8E6FF, "You're not in AFK mode.");
  56.     return 1;
  57. }*/
  58.  
  59. public OnPlayerText(playerid,text[])
  60. {
  61.     if(IsAfk[playerid] == 1)
  62.     {
  63.         Afk_Back(playerid);
  64.     }
  65.     else
  66.        SendClientMessage(playerid, 0xADD8E6FF, "You're not in AFK mode.");
  67.     return 1;
  68. }
  69.  
  70. stock Afk_Back(playerid)
  71. {
  72.     IsAfk[playerid] = 0;
  73.     TogglePlayerControllable(playerid, 1);
  74.     format(string,sizeof(string),"%s {FFFFFF} is now BACK from AFK mode.", names);
  75.     SendClientMessageToAll(0xADD8E6FF, string);
  76.     DeletePlayer3DTextLabel(playerid, afktext);
  77.     return 1;
  78. }
  79.  
  80.  
  81. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  82. {
  83.     new OtherPlayerName[24], OtherPlayer;
  84.    
  85.     GetPlayerName(OtherPlayer, OtherPlayerName, sizeof(OtherPlayerName));
  86.    
  87.     if(IsAfk[clickedplayerid] == 1)
  88.     {
  89.         format(string, 128, "%s {FFFFFF}is in AFK mode :P .", OtherPlayerName);
  90.         SendClientMessage(playerid, 0xADD8E6FF, string);
  91.     }
  92.     else
  93.        format(string, 128, "%s {FFFFFF}is not in AFK mode.", OtherPlayerName);
  94.     SendClientMessage(playerid, 0xADD8E6FF, string);
  95.     return 1;
  96. }
  97. public OnPlayerConnect(playerid)
  98. {
  99.        SendClientMessage(playerid, -1, "This server uses 1Geek AFK System");
  100.     return 1;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment