Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fizz AFK (Unique - With Reason - Disable Chat)
- //-----------------------------------------------------------------
- // Thank's to Zeex
- // Thank's to KoczkaHUN for the AFK List
- // Thank's to Falcon, Rajat, Rafael, and Misiur
- // Thank's to Krisna as a Tester
- //---------------------------Feature-------------------------------
- // - AFK List
- // - Disable Chat when AFK
- // - AFK Reason
- // - 3DTextLabel above the player with Reason
- //-----------------------------------------------------------------
- #include <a_samp>
- #include <zcmd>
- #include <foreach>
- #include <sscanf2>
- #define COLOR_WHITE 0xFFFFFFFF
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_GRAD2 0xBFC0C2FF
- #define C_WHITE "{FFFFFF}"
- #define C_GREEN "{1FD925}"
- new str[64],
- IsPlayerAFK[MAX_PLAYERS],
- Text3D:Label[MAX_PLAYERS],
- AFK_Reason[MAX_PLAYERS];
- main()
- {
- print("\n----------------------------------");
- print(" Fizz AFK by ProPoint a.k.a HaPeace ");
- print("----------------------------------\n");
- }
- public OnPlayerText(playerid, text[])
- {
- if(IsPlayerAFK[playerid] == 1)
- {
- SendClientMessage(playerid, COLOR_GRAD2, "You are now AFK, you can't speak, use /back !");
- return 0;
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- IsPlayerAFK[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- if(IsPlayerAFK[playerid] == 1)
- {
- Delete3DTextLabel(Label[playerid]);
- IsPlayerAFK[playerid] = 0;
- }
- return 1;
- }
- PlayerName(playerid)
- {
- new pName[24];
- GetPlayerName(playerid, pName,24);
- return pName;
- }
- CMD:afk(playerid, params[])
- {
- if(IsPlayerAFK[playerid] == 0)
- {
- new reason[64];
- new strtext[64];
- if(sscanf(params,"s[64]", reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /afk [reason]");
- IsPlayerAFK[playerid] = 1;
- format(str, sizeof(str), "[ %s ] is now AFK, Reason : %s", PlayerName(playerid), reason);
- SendClientMessageToAll(COLOR_WHITE, str);
- format(AFK_Reason[playerid],64,"%s", reason);
- format(strtext, sizeof(strtext), ""C_GREEN"Player is AFK\n"C_WHITE"Reason: %s", reason);
- Label[playerid] = Create3DTextLabel(strtext,COLOR_WHITE,30.0,40.0,50.0,40.0,0);
- Attach3DTextLabelToPlayer(Label[playerid], playerid, 0.0, 0.0, 0.3);
- GameTextForPlayer (playerid, "~w~You are now AFK, type ~b~/back when you come back", 3000, 5);
- TogglePlayerControllable(playerid, 0);
- }
- else if(IsPlayerAFK[playerid] == 1)
- {
- SendClientMessage(playerid, COLOR_WHITE, "You are alredy AFK.");
- }
- return 1;
- }
- CMD:back(playerid, params[])
- {
- if(IsPlayerAFK[playerid] == 1)
- {
- IsPlayerAFK[playerid] = 0;
- format(str, sizeof(str), "[ %s ] is no longer AFK", PlayerName(playerid));
- SendClientMessageToAll(COLOR_WHITE, str);
- Delete3DTextLabel(Text3D:Label[playerid]);
- GameTextForPlayer (playerid, "~w~Welcome Back", 3000, 5);
- TogglePlayerControllable(playerid, 1);
- }
- else if(IsPlayerAFK[playerid] == 0)
- {
- SendClientMessage(playerid, COLOR_WHITE, "You are not AFK.");
- }
- return 1;
- }
- CMD:afklist(playerid,params[])
- {
- new count = 0, string[2500], pName[MAX_PLAYER_NAME];
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if (GetPlayerName(i, pName,sizeof(pName)))
- {
- if(IsPlayerAFK[i] == 1)
- {
- format(string, sizeof(string), "%sPlayer: {99EE22}%s, {992233}ID: {99DDDD}%d\n",
- string, pName, i);
- count++;
- }
- }
- }
- if (count == 0)
- {
- SendClientMessage(playerid, COLOR_GRAD2, "No one AFK!");
- }
- else ShowPlayerDialog(playerid,837,DIALOG_STYLE_LIST,"AFK PLAYERS:",string,"OK","Cancel");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment