Guest User

[MUG] Afk + Random Message

a guest
Jan 24th, 2013
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 6.00 KB | None | 0 0
  1. //--
  2. //   This is an Brand new afk system + Random server message by team of MughuL
  3. //   Hope you'll like it . For more info & detail loggon to www.unstunting.tk
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7.  
  8. forward SendRandomMessage();
  9. #define CURRENT_MESSAGES 4
  10. #define MESSAGE_INTERVAL 60
  11. #define MESSAGE_COLOR 0x4169E1FF
  12. new RM[CURRENT_MESSAGES][128];
  13. #define CURRENT_MESSAGES 4
  14. #define green 0xFF0000 //Color green.
  15. #define red 0xFF0000FF //Color red.
  16. #define orange 0xFF9900AA // Color orange.
  17. #define Disable_AFKCHAT == true //Change it from true to false if you don't want AFK users to be restricted in Chatting.
  18. #define sname "SERVER" //Change the SERVER to your hostname but it must be typed between the quotes(").
  19.  
  20.  
  21. new AFK[MAX_PLAYERS];
  22. new Text3D: tAFK[MAX_PLAYERS];
  23. new AFKcount;
  24. #define COLOR_PINK 0xFF66FFAA
  25.  
  26. public OnFilterScriptInit()
  27. {
  28.     print("\n------------------------------------------");
  29.     print(" Afk system");
  30.     print(" Random Message");
  31.     print(" Fully Loaded By MughuL Bacha");
  32.     print("--------------------------------------------\n");
  33.     AddRandomMessage("{FF0000}[TIP]: {FFFFFF}Please use {FF0000}/commands, /jumps, /dms, /stuns, /credits and /help {FFFFFF}for help.");
  34.     AddRandomMessage("{FF0000}[TIP]: {FFFFFF}Did you see any player hacking/cheating ? Please use {FF0000}/report {FFFFFF}to report them.");
  35.     AddRandomMessage("{FF0000}[TIP]: {FFFFFF}Want to Edit Your Game Profile ? Please use {FF0000}/cp.");
  36.     AddRandomMessage("{FF0000}[TIP]: {FFFFFF}Please make sure to visit our Website {FF0000} -=- www.unstunting.smffy.com -=-");
  37.     SetTimer("SendRandomMessage", MESSAGE_INTERVAL * 9000, 1);
  38.     return 1;
  39. }
  40.  
  41. new Float:xpos,Float:ypos,Float:zpos;
  42. new ainterior;
  43. new Float:hp[MAX_PLAYERS];
  44. new Float:armour[MAX_PLAYERS];
  45.  
  46.  
  47. CMD:afk(playerid,params[])
  48. {
  49.     if(AFK[playerid] == 1)
  50.     {
  51.         return GameTextForPlayer(playerid, "You are already in AFK. Use /back",3000,3);
  52.     }
  53.     new Lname[MAX_PLAYER_NAME];
  54.     new string[128];
  55.     GetPlayerName(playerid,Lname,sizeof(Lname));
  56.     SetPlayerPos(playerid,xpos,ypos,zpos);
  57.     SetPlayerInterior(playerid,ainterior);
  58.     GetPlayerHealth(playerid,hp[playerid]);
  59.     GetPlayerArmour(playerid,armour[playerid]);
  60.     SetPlayerHealth(playerid,100000);
  61.     SetPlayerArmour(playerid,0);
  62.     SetPlayerInterior(playerid,3);
  63.     SetPlayerPos(playerid,-2668.868408,1410.360107,906.460937);
  64.     TogglePlayerControllable(playerid,0);
  65.     ApplyAnimation(playerid,"DANCING","dance_loop", 4.1,1,1,1,1,1);
  66.     tAFK[playerid] = Create3DTextLabel("AFK-MODE", 0xFF0000FF, 0.0, 0.0, 2.0, 40, 0, 0);
  67.     Attach3DTextLabelToPlayer(tAFK[playerid],playerid, 0.0, 0.0, 0.4);
  68.     PlayerPlaySound(playerid,1185,2944.7271,-729.7914,1.9063);
  69.     format(string, sizeof(string), "{00FFBF}[INFO]:{FCD9AC}%s is now Away From Keyboard.{00FFBF}(/Afk)", Lname);
  70.     SendClientMessageToAll(green,string);
  71.     AFK[playerid]=1;
  72.  
  73.     AFKcount++;
  74.     return 1;
  75. }
  76.  
  77. CMD:back(playerid,params[])
  78. {
  79.     if(AFK[playerid] == 0)
  80.     {
  81.         GameTextForPlayer(playerid, "You are not in AFK to use this command.",3000,3);
  82.     }
  83.     else
  84.     {
  85.     SpawnPlayer(playerid);
  86.     new string[192];
  87.     new Bname[MAX_PLAYER_NAME];
  88.     GetPlayerName(playerid,Bname,sizeof(Bname));
  89.     SetPlayerPos(playerid,xpos,ypos,zpos);
  90.     SetPlayerInterior(playerid,ainterior);
  91.     SetPlayerHealth(playerid,hp[playerid]);
  92.     SetPlayerArmour(playerid,armour[playerid]);
  93.     PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
  94.     Delete3DTextLabel(tAFK[playerid]);
  95.     format(string, sizeof(string), "{00FFBF}[INFO]:{FCD9AC}%s is now back.{FCD9AC}{00FFBF}(/Back)", Bname);
  96.     SendClientMessageToAll(green,string);
  97.     AFK[playerid]=0;
  98.     new str1[128];
  99.     format(str1, sizeof(str1),"Welcome Back To Server Please Enjoy your Stay.", sname);
  100.     SendClientMessage(playerid, orange, str1);
  101.     AFKcount--;
  102.     }
  103.     return 1;
  104. }
  105. CMD:afkhelp(playerid,prams[])
  106. {
  107.     SendClientMessage(playerid, red, "~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=");
  108.     SendClientMessage(playerid, orange, "Universal Team has succesfully fixed the afk sys.");
  109.     SendClientMessage(playerid, red, "{00FFBF}/Afk, /Back, /Afklist, /afkhelp");
  110.     SendClientMessage(playerid, orange, "Please Send us Feedback or any request at unstunting.tk");
  111.     SendClientMessage(playerid, red, "~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=");
  112.     return 1;
  113. }
  114. CMD:afklist(playerid,params[])
  115. {
  116.     new string[128];
  117.     new Lsname[MAX_PLAYER_NAME];
  118.     new cstring[128];
  119.     SendClientMessage(playerid, orange, "****************************************");
  120.     SendClientMessage(playerid, green, "       Players Away From keyBoard");
  121.     SendClientMessage(playerid, orange, "****************************************");
  122.     format(cstring,sizeof(cstring),"There are currently %d player(s) in AFK mode.", AFKcount);
  123.     SendClientMessage(playerid, orange, cstring);
  124.     for(new i = 0; i< MAX_PLAYERS; i++)
  125.    {
  126.        if(IsPlayerConnected(i))
  127.        {
  128.            if(AFK[i] == 1)
  129.            {
  130.                GetPlayerName(i,Lsname,sizeof(Lsname));
  131.                format(string,sizeof(string),"{ff0000}%s (ID:%d)", Lsname, i);
  132.                SendClientMessage(playerid, orange, string);
  133.            }
  134.       }
  135.    }
  136.    return 1;
  137. }
  138. public SendRandomMessage()
  139. {
  140.     static lastmessage = 0;
  141.     new rand = random(CURRENT_MESSAGES);
  142.     while(rand == lastmessage && CURRENT_MESSAGES != 1) { rand = random(CURRENT_MESSAGES);  }
  143.     lastmessage = rand;
  144.     SendClientMessageToAll(MESSAGE_COLOR, RM[lastmessage]);
  145. }
  146.  
  147. stock AddRandomMessage(text[])
  148. {
  149.     for(new m; m < CURRENT_MESSAGES; m++)
  150.     {
  151.         if(!strlen(RM[m]))
  152.         {
  153.             strmid(RM[m], text, 0, 127);
  154.             return 1;
  155.         }
  156.     }
  157.     return 0;
  158. }
  159. #if defined Disable_AFKCHAT == true
  160. public OnPlayerText(playerid,text[])
  161. {
  162.    if(AFK[playerid] == 1)
  163.    {
  164.            GameTextForPlayer(playerid, "You cannot talk while you are in AFK-MODE.",3000,3);
  165.            return 0;
  166.    }
  167.    return 1;
  168. }
  169.    #endif
  170.  
  171. public OnPlayerConnect(playerid)
  172. {
  173.    AFK[playerid] = 0;
  174.    return 1;
  175. }
Advertisement
Add Comment
Please, Sign In to add comment