Advertisement
Guest User

AFK System 1.2b by Sim_sima

a guest
Mar 23rd, 2011
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.21 KB | None | 0 0
  1. // AFK System v1,2b
  2. // By Sim_sima
  3. // Made for Sim_sima's, Madsen's and HeavyBass's RPG server project.
  4. #include <a_samp>
  5.  
  6. #define AFKVW 10 // Use this line to change the number of virtual world for AKF players
  7.  
  8. new currentvw; // Gets the current virtual world of the player
  9. new currentcolor[MAX_PLAYERS]; // Gets the current color of the player
  10. new afk[MAX_PLAYERS];
  11. new Text:Textdraw0;
  12. new Text:Textdraw1;
  13.  
  14. #define COLOR_YELLOW 0xFFFF00FF
  15. #define COLOR_GREY 0xAFAFAFFF
  16. #define COLOR_NORMALRED 0xAF0000FF
  17. #define COLOR_WHITE 0xFFFFFFAA
  18. #define COLOR_GREEN 0x009900FF
  19.  
  20. public OnFilterScriptInit()
  21. {
  22.     print("\n--------------------------------------");
  23.     print("AFK System by Sim_sima loaded!");
  24.     print("--------------------------------------\n");
  25.     return 1;
  26. }
  27.  
  28. public OnPlayerConnect(playerid)
  29. {
  30.     SendClientMessage(playerid, COLOR_GREEN, "This server is using AFK-System v1.2b by Sim_sima. Type /afkhelp for more info.");
  31.     return 1;
  32. }
  33.  
  34. public OnPlayerCommandText(playerid, cmdtext[])
  35. {
  36.     if (strcmp("/goafk", cmdtext, true, 10) == 0)
  37.     {
  38.         if(afk[playerid] == 1)
  39.         {
  40.             SendClientMessage(playerid, COLOR_NORMALRED, "You are already in AFK mode. Type /back to return");
  41.         }
  42.         else
  43.         {
  44.             afk[playerid] = 1;
  45.             currentcolor[playerid] = GetPlayerColor(playerid);
  46.             SetPlayerColor(playerid, COLOR_GREY);
  47.             currentvw = GetPlayerVirtualWorld(playerid);
  48.             SetPlayerVirtualWorld(playerid, AFKVW);
  49.             TogglePlayerControllable(playerid, 0);
  50.             new name[MAX_PLAYER_NAME], string[44];
  51.             GetPlayerName(playerid, name, sizeof(name));
  52.             format(string, sizeof(string), "%s is now in AFK mode",name);
  53.             SendClientMessageToAll(COLOR_GREY, string);
  54.             Textdraw0 = TextDrawCreate(266.000000, 145.000000, "Type /back to return");
  55.             TextDrawBackgroundColor(Textdraw0, 255);
  56.             TextDrawFont(Textdraw0, 1);
  57.             TextDrawLetterSize(Textdraw0, 0.300000, 0.799998);
  58.             TextDrawColor(Textdraw0, -1);
  59.             TextDrawSetOutline(Textdraw0, 1);
  60.             TextDrawSetProportional(Textdraw0, 1);
  61.             Textdraw1 = TextDrawCreate(268.000000, 124.000000, "AFK Mode");
  62.             TextDrawBackgroundColor(Textdraw1, 255);
  63.             TextDrawFont(Textdraw1, 2);
  64.             TextDrawLetterSize(Textdraw1, 0.500000, 2.599998);
  65.             TextDrawColor(Textdraw1, 65535);
  66.             TextDrawSetOutline(Textdraw1, 1);
  67.             TextDrawSetProportional(Textdraw1, 1);
  68.             TextDrawShowForPlayer(playerid, Textdraw0);
  69.             TextDrawShowForPlayer(playerid, Textdraw1);
  70.         }
  71.         return 1;
  72.     }
  73.    
  74.     if (strcmp("/back", cmdtext, true, 10) == 0)
  75.     {
  76.         if(afk[playerid] == 1)
  77.         {
  78.             afk[playerid] = 0;
  79.             SetPlayerColor(playerid, currentcolor[playerid]);
  80.             SetPlayerVirtualWorld(playerid, currentvw);
  81.             TogglePlayerControllable(playerid, 1);
  82.             GameTextForPlayer(playerid, "Welcome back", 3000, 5);
  83.             new name[MAX_PLAYER_NAME], string[44];
  84.             GetPlayerName(playerid, name, sizeof(name));
  85.             format(string, sizeof(string), "%s is back from AFK mode",name);
  86.             SendClientMessageToAll(COLOR_GREY, string);
  87.             TextDrawHideForPlayer(playerid, Textdraw0);
  88.             TextDrawDestroy(Textdraw0);
  89.             TextDrawHideForPlayer(playerid, Textdraw1);
  90.             TextDrawDestroy(Textdraw1);
  91.             return 1;
  92.         }
  93.         else SendClientMessage(playerid, COLOR_NORMALRED, "You need to be in AFK mode to use this command. Type /goafk to go AFK");
  94.         return 1;
  95.     }
  96.  
  97.     new string[256];
  98.  
  99.     if (strcmp("/afklist", cmdtext, true) == 0)
  100.     {
  101.             SendClientMessage(playerid, COLOR_YELLOW, "-----------------------------------");
  102.             SendClientMessage(playerid, COLOR_GREEN, "AFK LIST:");
  103.             for(new i = 0; i < MAX_PLAYERS; i++)
  104.             {
  105.                 if(IsPlayerConnected(i))
  106.                 {
  107.                     if(afk[i] == 1)
  108.                     {
  109.                             new name[128];
  110.                             GetPlayerName(i,name,128);
  111.                             format(string, 256, "%s", name);
  112.                             SendClientMessage(playerid, COLOR_GREY, string);
  113.                     }
  114.                 }
  115.             }
  116.             SendClientMessage(playerid, COLOR_YELLOW, "-----------------------------------");
  117.             return 1;
  118.     }
  119.  
  120.     if (strcmp("/afkhelp", cmdtext, true, 10) == 0)
  121.     {
  122.         SendClientMessage(playerid, COLOR_YELLOW, "------------------------------------------------------------------------");
  123.         SendClientMessage(playerid, COLOR_GREEN, "AFK System v1.1b by Sim_sima");
  124.         SendClientMessage(playerid, COLOR_YELLOW, "------------------------------------------------------------------------");
  125.         SendClientMessage(playerid, COLOR_WHITE, "AFK Commands:");
  126.         SendClientMessage(playerid, COLOR_WHITE, "/goafk = Changes your status to AFK mode.");
  127.         SendClientMessage(playerid, COLOR_WHITE, "/back = Returns you from AFK mode.");
  128.         SendClientMessage(playerid, COLOR_WHITE, "/afklist = Shows a list of AFK players.");
  129.         SendClientMessage(playerid, COLOR_YELLOW, "------------------------------------------------------------------------");
  130.         return 1;
  131.     }
  132.     return 0;
  133. }
  134.  
  135. public OnPlayerText(playerid, text[])
  136. {
  137.     if(afk[playerid] == 1)
  138.     {
  139.         SendClientMessage(playerid, COLOR_NORMALRED, "You can not chat while in AFK mode. Type /back to return");
  140.         return 0;
  141.     }
  142.     return 1;
  143. }
  144.  
  145. public OnPlayerDeath(playerid, killerid, reason)
  146. {
  147.     if(afk[playerid] == 1)
  148.     {
  149.         afk[playerid] = 0;
  150.         SetPlayerVirtualWorld(playerid, currentvw);
  151.         SetPlayerColor(playerid, currentcolor[playerid]);
  152.     }
  153.     return 1;
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement