DarkWolf21

xafk System by revolver..

Dec 29th, 2015
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.72 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf2>
  4.  
  5. #define FILTERSCRIPT
  6.  
  7. #define blue 0x0000BBAA
  8. #define white 0xFFFFFFAA
  9. #define lightred 0xFF0000AA
  10. #define blue 0x24FF0AB9
  11. #define red 0xEEEEFFC4
  12.  
  13. new Text:DescriptionText[MAX_PLAYERS];
  14.  
  15. new DescriptionTimer[MAX_PLAYERS];
  16.  
  17. forward HideDescriptionText(playerid);
  18.  
  19. public HideDescriptionText(playerid)
  20. {
  21.     TextDrawHideForPlayer(playerid, DescriptionText[playerid]);
  22.     return 1;
  23. }
  24.  
  25. forward HideDescriptionText(playerid);
  26.  
  27. new PNAME[MAX_PLAYER_NAME];
  28. new afk[MAX_PLAYERS];
  29. new Text3D:label[MAX_PLAYERS];
  30.  
  31.  
  32. stock ShowDescriptionText(playerid, string[])
  33. {
  34.     KillTimer(DescriptionTimer[playerid]);
  35.     TextDrawSetString(DescriptionText[playerid], string);
  36.     TextDrawShowForPlayer(playerid, DescriptionText[playerid]);
  37.     DescriptionTimer[playerid] = SetTimerEx("HideDescriptionText", 5000, 0, "i", playerid);
  38.     return 1;
  39. }
  40.  
  41.  
  42. CMD:afk(playerid, params[])
  43. {
  44.    if(afk[playerid] == 1) return SendClientMessage(playerid,blue, "{00FFFF}[Information]{FFFFFF} You are already away, use {00FFFF}/back{FFFFFF} to return back and announce your recurrence -|");
  45.         ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{00FFFF}-Reason:", "{FFFF00}Please insert here why would you be in afk - status", "Done", "Exit");
  46.     return 1;
  47.  
  48. }
  49.  
  50. CMD:back(playerid,params[])
  51. {
  52.     if(afk[playerid] == 0) return SendClientMessage(playerid,blue, "{00FFFF}[Error]:{FFFFFF} You ain't afk to use this command{CC0000}..");
  53. {
  54.      ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{00FFFF}-Welcome:", "{FFFF00}Please insert here a comment for being back", "Done", "Exit");
  55. }
  56.     return 1;
  57. }
  58.  
  59. public OnPlayerConnect(playerid)
  60. {
  61.  afk[playerid] = 0;
  62.  return 1;
  63. }
  64. public OnPlayerDisconnect(playerid)
  65. {
  66.  afk[playerid] = 0;
  67.  return 1;
  68. }
  69. public OnPlayerText(playerid, text[])
  70. {
  71.  if(afk[playerid] == 1) {
  72.  SendClientMessage(playerid, blue, "{00FFFF}[Error]:{FFFFFF} You can't chat while you are afk{CC0000}..");
  73.  return 0;
  74.  }
  75.  return 1;
  76. }
  77.  
  78.  
  79.  
  80. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  81. {
  82.  
  83. if(dialogid == 1)
  84.                 if(response == 0) {
  85.             new string[128];
  86.             SendClientMessage(playerid, blue,"{00FFFF}[Exited]:{FFFFFF} You have choosed the option {FF0000}'Exit'{FFFFFF} instead if going away, Complete Playing{FF0000}..");
  87.                 return 1;
  88.                 }
  89.                 else if(response == 1) {
  90.                 if(!strlen(inputtext)) {
  91.             SendClientMessage(playerid, blue, "{00FFFF}[Error]:{FFFFFF} You have to type a reason for being afk{FF0000}..");
  92.         } else if(strlen(inputtext))
  93.                      {
  94.                  new string[128],pname[32];
  95.                  GetPlayerName(playerid,pname,sizeof(pname));
  96.                  format(string,sizeof(string),"{00FFFF}[Appointment]:{CC0000} %s {FFFFFF}is now away from keyboard, {00FFFF}[Reason]: {CC0000}%s.. ",pname,inputtext);
  97.                  SendClientMessageToAll(blue, string);
  98.              label[playerid] = Create3DTextLabel(" ",0xFF0000FF,30.0,40.0,50.0,15.0,0);
  99.              format(string,sizeof(string),"AFK |-Reason: %s -|",inputtext);
  100.              SendClientMessage(playerid, blue, "{00FFFF}[Information]{FFFFFF} Type {00FFFF}/back{FFFFFF} when you come back, and to recurrence your return{FF0000}..");
  101.              TogglePlayerControllable(playerid,0);
  102.             SetPlayerHealth(playerid, 999999);
  103.             SetPlayerArmour(playerid, 999999);
  104. SetPlayerVirtualWorld(playerid, 191);
  105.              format(string, sizeof(string), "~w~You are afk~w~");
  106.             ShowDescriptionText(playerid, string);
  107.              afk[playerid] = 1;
  108.     return 1;
  109.         }
  110.  }
  111.  
  112. if(dialogid == 2)
  113.                 if(response == 0) {
  114.             new string[128];
  115.             SendClientMessage(playerid, blue,"{00FFFF}[Exited]:{FFFFFF} You have choosed the {00FFFF}'Exit'{FFFFFF} Option, therefore you still away from keybaord{CC0000}..");
  116.                 return 1;
  117.                 }
  118.                 else if(response == 1) {
  119.                 if(!strlen(inputtext)) {
  120.             SendClientMessage(playerid, blue, "{00FFFF}[Error]:{FFFFFF} You have to type a {00FFFF}'Comment'{FFFFFF} to get back{CC0000}..");
  121.         } else if(strlen(inputtext))
  122.                      {
  123.                  new string[128],pname[32];
  124.                  GetPlayerName(playerid,pname,sizeof(pname));
  125.                  format(string,sizeof(string),"{00FFFF}[Appointment]{CC0000} %s {FFFFFF}is now back, {00FFFF}[Comment]:{CC0000} %s.. ",pname,inputtext);
  126.                  SendClientMessageToAll(blue, string);
  127.              SendClientMessage(playerid, blue, "{00FFFF}[Welcome]{FFFFFF} Welcome back, enjoy your stay{CC0000}..");
  128.             label[playerid] = Create3DTextLabel("Playing",0xE60000FF,30.0,40.0,50.0,40.0,0);
  129.             Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
  130.              TogglePlayerControllable(playerid,1);
  131.         SetPlayerHealth(playerid, 100);
  132.             SetPlayerArmour(Playerid, 24);    
  133. SetPlayerVirtualWorld(playerid, 0)  
  134.     GameTextForPlayer(playerid,"Welcome Back",15000,6);
  135.              afk[playerid] = 0;
  136.                 return 1;
  137.         }
  138.     }
  139. return 0;
  140. }
  141.  
  142. CMD:afklist(playerid,params[])
  143. {
  144.         new count = 0, string[2500], pName[MAX_PLAYER_NAME];
  145.  
  146.     for(new i = 0; i < MAX_PLAYERS; i++)
  147.     {
  148.         if (GetPlayerName(i, pName,sizeof(pName)))
  149.         {
  150.             if(afk[i] == 1)
  151.             {
  152.                 format(string, sizeof(string), "%sPlayer: {FF0000}%s, {FF0000}ID: {FFFFFF}%d\n",
  153.                 string, pName, i);
  154.                 count++;
  155.             }
  156.         }
  157.     }
  158.     if (count == 0)
  159.     {
  160.         SendClientMessage(playerid, blue, "{FF0000}[Alert]{FFFFFF} There is no any afk player{CC0000}..");
  161.  
  162.     }
  163.         else ShowPlayerDialog(playerid,837,DIALOG_STYLE_LIST,"-Afk Players",string,"Exit","");
  164.     return 1;
  165. }
Advertisement
Add Comment
Please, Sign In to add comment