uwe_baker

AFK-System

Oct 29th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. #define notafkdialog 1
  2.  
  3. #define leuchtgruen 0x9ACD32AA
  4. #define grau 0xB4B5B7FF
  5. #define gruen 0x33AA33AA
  6. #define leuchtrot 0xFF6347AA
  7. #define leuchtblau 0x33CCFFAA
  8. #define gelb 0xFFFF00AA
  9. #define rot 0xAA3333AA
  10.  
  11. new Text:NOTAFK1,Text:NOTAFKCODE,Text:NOTAFK2,AFKKICK[MAX_PLAYERS],Code[MAX_PLAYERS],Float:PlayerPos[MAX_PLAYERS][6];
  12.  
  13. new idletimer = 900000; //10 min.
  14.  
  15. forward AFKOn(playerid);
  16. forward IdleKick();
  17. forward KickAFK(playerid);
  18.  
  19. //GameModeInit
  20. NOTAFK1 = TextDrawCreate(277.000000, 133.000000, "~r~AFK-System");
  21. TextDrawBackgroundColor(NOTAFK1, 255);
  22. TextDrawFont(NOTAFK1, 1);
  23. TextDrawLetterSize(NOTAFK1, 0.390000, 1.699999);
  24. TextDrawColor(NOTAFK1, -1);
  25. TextDrawSetOutline(NOTAFK1, 0);
  26. TextDrawSetProportional(NOTAFK1, 1);
  27. TextDrawSetShadow(NOTAFK1, 1);
  28.  
  29. NOTAFKCODE = TextDrawCreate(168.000000, 133.000000, " ");
  30. TextDrawBackgroundColor(NOTAFKCODE, 255);
  31. TextDrawFont(NOTAFKCODE, 1);
  32. TextDrawLetterSize(NOTAFKCODE, 0.390000, 1.699999);
  33. TextDrawColor(NOTAFKCODE, -1);
  34. TextDrawSetOutline(NOTAFKCODE, 0);
  35. TextDrawSetProportional(NOTAFKCODE, 1);
  36. TextDrawSetShadow(NOTAFKCODE, 1);
  37. TextDrawUseBox(NOTAFKCODE, 1);
  38. TextDrawBoxColor(NOTAFKCODE, 150);
  39. TextDrawTextSize(NOTAFKCODE, 462.000000, 0.000000);
  40.  
  41. NOTAFK2 = TextDrawCreate(230.000000, 178.000000, "~y~Du hast 60 Sekunden Zeit.");
  42. TextDrawBackgroundColor(NOTAFK2, 255);
  43. TextDrawFont(NOTAFK2, 1);
  44. TextDrawLetterSize(NOTAFK2, 0.390000, 1.699999);
  45. TextDrawColor(NOTAFK2, -1);
  46. TextDrawSetOutline(NOTAFK2, 0);
  47. TextDrawSetProportional(NOTAFK2, 1);
  48. TextDrawSetShadow(NOTAFK2, 1);
  49.  
  50. //OnPlayerConnect
  51. TextDrawHideForPlayer(playerid, NOTAFK1);
  52. TextDrawHideForPlayer(playerid, NOTAFKCODE);
  53. TextDrawHideForPlayer(playerid, NOTAFK2);
  54. AFKKICK[playerid] = 1;
  55. Code[playerid] = 0;
  56.  
  57. //CommandText
  58. //Admin Abfrage erfolgt über /rcon login ob eingeloggt oder nicht
  59. if(strcmp(cmd,"/notafk",true) == 0)
  60. {
  61. if(AFKKICK[playerid] == 1)
  62. {
  63. SendClientMessage(playerid, grau,"Du stehst nicht unter AFK verdacht!");
  64. return 1;
  65. }
  66. if(AFKKICK[playerid] == 0)
  67. {
  68. format(string,sizeof(string),"Du wurdest vom System als AFK anerkannt.\nGib hier deinen Code ein.");
  69. ShowPlayerDialog(playerid, notafkdialog,DIALOG_STYLE_INPUT,"AFK-System Code Eingabe",string,"Absenden","Abbruch");
  70. return 1;
  71. }
  72. return 1;
  73. }
  74. if(strcmp(cmd, "/afk", true) == 0)
  75. {
  76. if(IsPlayerAdmin(playerid))
  77. {
  78. tmp = strtok(cmdtext, idx);
  79. if(!strlen(tmp))
  80. {
  81. SendClientMessage(playerid, grau, "* /afk [playerid]");
  82. return 1;
  83. }
  84. giveplayerid = ReturnUser(tmp);
  85. if(IsPlayerConnected(giveplayerid))
  86. {
  87. if(giveplayerid != INVALID_PLAYER_ID)
  88. {
  89. SendClientMessage(playerid, leuchtblau,"* Du hast den Spieler Erfolgreich auf AFK überprüft!");
  90. AFKOn(giveplayerid);
  91. return 1;
  92. }
  93. }
  94. }
  95. else
  96. {
  97. SendClientMessage(playerid, grau, "Du bist nicht der Projektleiter/Administrator.");
  98. }
  99. return 1;
  100. }
  101.  
  102. //DialogResponse
  103. if(dialogid == notafkdialog)
  104. {
  105. if(response == 0)
  106. {
  107. return 1;
  108. }
  109. if(response == 1)
  110. {
  111. if(Code[playerid] == strval(inputtext))
  112. {
  113. SendClientMessage(playerid, leuchtblau,"* Anwesenheit bestätigt.");
  114. AFKKICK[playerid] = 1;
  115. TextDrawHideForPlayer(playerid, NOTAFK1);
  116. TextDrawHideForPlayer(playerid, NOTAFKCODE);
  117. TextDrawHideForPlayer(playerid, NOTAFK2);
  118. return 1;
  119. }
  120. else
  121. {
  122. format(string,sizeof(string),"Falscher Code!\nDu musst den richtigen Code hier eingeben! ({F3FF02}%d{FFFFFF})",Code[playerid]);
  123. ShowPlayerDialog(playerid, notafkdialog,DIALOG_STYLE_INPUT,"AFK-System Code Eingabe",string,"Absenden","Abbruch");
  124. }
  125. }
  126. }
  127.  
  128. public AFKOn(playerid)
  129. {
  130. if(IsPlayerConnected(playerid) && AFKKICK[playerid] == 1)
  131. {
  132. new string[250];
  133. SetCodeArray(playerid);
  134. AFKKICK[playerid] = 0;
  135. SetTimerEx("KickAFK",60000,0,"i",playerid);
  136. format(string,255,"~n~~w~Du stehst im Verdacht, AFK zu sein. Wenn du~n~ nicht AFK bist, gib ~g~/notafk %d~w~ ein.~n~",Code[playerid]);
  137. TextDrawSetString(NOTAFKCODE, string);
  138. TextDrawShowForPlayer(playerid, NOTAFK1);
  139. TextDrawShowForPlayer(playerid, NOTAFKCODE);
  140. TextDrawShowForPlayer(playerid, NOTAFK2);
  141. }
  142. return 1;
  143. }
  144.  
  145. public IdleKick()
  146. {
  147. for(new i = 0; i < MAX_PLAYERS; i++)
  148. {
  149. if(IsPlayerConnected(i))
  150. {
  151. if(IsPlayerAdmin(i))
  152. {
  153. GetPlayerPos(i, PlayerPos[i][0], PlayerPos[i][1], PlayerPos[i][2]);
  154. if(PlayerPos[i][0] == PlayerPos[i][3] && PlayerPos[i][1] == PlayerPos[i][4] && PlayerPos[i][2] == PlayerPos[i][5])
  155. {
  156. AFKOn(i);
  157. }
  158. PlayerPos[i][3] = PlayerPos[i][0];
  159. PlayerPos[i][4] = PlayerPos[i][1];
  160. PlayerPos[i][5] = PlayerPos[i][2];
  161. }
  162. }
  163. }
  164. }
  165.  
  166. public KickAFK(playerid)
  167. {
  168. if(AFKKICK[playerid] == 0)
  169. {
  170. SendClientMessage(playerid, leuchtrot,"Du wurdest gekickt (AFK)");
  171. Kick(playerid);
  172. return 1;
  173. }
  174. return 1;
  175. }
Advertisement
Add Comment
Please, Sign In to add comment