Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. /*
  2. **** AFK System - UberEverywhere ****
  3. */
  4.  
  5.  
  6. #define FILTERSCRIPT
  7.  
  8. #include <a_samp>
  9.  
  10. new AFK[MAX_PLAYERS];
  11. new OldSkin[MAX_PLAYERS];
  12. new OldCol[MAX_PLAYERS];
  13.  
  14. new PlayerText:Afk[MAX_PLAYERS];
  15. new PlayerText:Back[MAX_PLAYERS];
  16.  
  17. new PlayerText3D:afk[MAX_PLAYERS];
  18.  
  19.  
  20. public OnFilterScriptInit()
  21. {
  22. print(" ._._._._._._._._._._._._._._._._._.");
  23. print(" AFK System by UberEverywhere loaded");
  24. print(" .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.");
  25. return 1;
  26. }
  27.  
  28. public OnPlayerConnect(playerid)
  29. {
  30. AFK[playerid] = 0;
  31.  
  32. Afk[playerid] = CreatePlayerTextDraw(playerid, 257.000061, 192.074111, "~g~afk_~w~mode");
  33. PlayerTextDrawLetterSize(playerid, Afk[playerid], 0.786000, 3.184592);
  34. PlayerTextDrawAlignment(playerid, Afk[playerid], 1);
  35. PlayerTextDrawColor(playerid, Afk[playerid], -1);
  36. PlayerTextDrawSetShadow(playerid, Afk[playerid], 0);
  37. PlayerTextDrawSetOutline(playerid, Afk[playerid], 1);
  38. PlayerTextDrawBackgroundColor(playerid, Afk[playerid], 255);
  39. PlayerTextDrawFont(playerid, Afk[playerid], 3);
  40. PlayerTextDrawSetProportional(playerid, Afk[playerid], 1);
  41. PlayerTextDrawSetShadow(playerid, Afk[playerid], 0);
  42.  
  43. Back[playerid] = CreatePlayerTextDraw(playerid, 123.000091, 219.037048, "type_~r~/back_~w~to_leave_afk_mode");
  44. PlayerTextDrawLetterSize(playerid, Back[playerid], 0.786000, 3.184592);
  45. PlayerTextDrawAlignment(playerid, Back[playerid], 1);
  46. PlayerTextDrawColor(playerid, Back[playerid], -1);
  47. PlayerTextDrawSetShadow(playerid, Back[playerid], 0);
  48. PlayerTextDrawSetOutline(playerid, Back[playerid], 1);
  49. PlayerTextDrawBackgroundColor(playerid, Back[playerid], 255);
  50. PlayerTextDrawFont(playerid, Back[playerid], 3);
  51. PlayerTextDrawSetProportional(playerid, Back[playerid], 1);
  52. PlayerTextDrawSetShadow(playerid, Back[playerid], 0);
  53. return 1;
  54. }
  55.  
  56. public OnPlayerDisconnect(playerid)
  57. {
  58. AFK[playerid] = 0;
  59. return 1;
  60. }
  61.  
  62. public OnPlayerCommandText(playerid, cmdtext[])
  63. {
  64. new pname[24], str[128];
  65. GetPlayerName(playerid, pname, 24);
  66. if(!strcmp(cmdtext, "/afk", true))
  67. {
  68. if(AFK[playerid] == 1)
  69. {
  70. SendClientMessage(playerid, -1, "{FF0000}ERROR:{FFFFFF} You are already AFK! Type /back to get back from AFK");
  71. return 1;
  72. }
  73. SendClientMessage(playerid, 0x74FF00AA, "You are now AFK! Type /back to get back from AFK");
  74. format(str, sizeof(str), "%s [%d] is now {74FF00}AFK{FFFFFF}!", pname, playerid);
  75. SendClientMessageToAll(-1, str);
  76. OldSkin[playerid] = GetPlayerSkin(playerid);
  77. OldCol[playerid] = GetPlayerColor(playerid);
  78. SetPlayerHealth(playerid, 99999999);
  79. SetPlayerColor(playerid, 0xF4F800AA);
  80. afk[playerid] = CreatePlayer3DTextLabel(playerid, "AFK", 0x74FF00AA, 30.0, 40.0, 50.0, 40.0, 0);
  81. Attach3DTextLabelToPlayer(Text3D:afk[playerid], playerid, 0.0, 0.0, 0.3);
  82. PlayerTextDrawShow(playerid, Afk[playerid]);
  83. PlayerTextDrawShow(playerid, Back[playerid]);
  84. SetPlayerSkin(playerid, 0);
  85. TogglePlayerControllable(playerid, 0);
  86. AFK[playerid] = 1;
  87. return 1;
  88. }
  89.  
  90. if(!strcmp(cmdtext, "/back", true))
  91. {
  92. if(AFK[playerid] == 0)
  93. {
  94. SendClientMessage(playerid, -1, "{FF0000}ERROR:{FFFFFF} You are not AFK! Type /afk to go AFK");
  95. return 1;
  96. }
  97. SendClientMessage(playerid, -1, "Welcome back :)");
  98. TogglePlayerControllable(playerid, 1);
  99. format(str, sizeof(str), "%s [%d] is now back from {74FF00}AFK{FFFFFF}!", pname, playerid);
  100. SendClientMessageToAll(-1, str);
  101. SetPlayerHealth(playerid, 100);
  102. SetPlayerColor(playerid, OldCol[playerid]);
  103. SetPlayerSkin(playerid, OldSkin[playerid]);
  104. DeletePlayer3DTextLabel(playerid, afk[playerid]);
  105. PlayerTextDrawHide(playerid, Afk[playerid]);
  106. PlayerTextDrawHide(playerid, Back[playerid]);
  107. AFK[playerid] = 0;
  108. return 1;
  109. }
  110. return 0;
  111. }
  112.  
  113. public OnPlayerText(playerid, text[])
  114. {
  115. if(AFK[playerid] == 1)
  116. {
  117. SendClientMessage(playerid, -1, "{FF0000}ERROR:{FFFFFF} You are AFK. Type /back to talk again.");
  118. return 0;
  119. }
  120. return 1;
  121. }
  122.  
  123. public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
  124. {
  125. if(AFK[damagedid] == 1)
  126. {
  127. GameTextForPlayer(playerid, "~R~player is ~n~afk", 3000, 3);
  128. return 0;
  129. }
  130. return 1;
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement