Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #define FILTERSCRIPT
- #define blue 0x0000BBAA
- #define white 0xFFFFFFAA
- #define lightred 0xFF0000AA
- #define blue 0x24FF0AB9
- #define red 0xEEEEFFC4
- new Text:DescriptionText[MAX_PLAYERS];
- new DescriptionTimer[MAX_PLAYERS];
- forward HideDescriptionText(playerid);
- public HideDescriptionText(playerid)
- {
- TextDrawHideForPlayer(playerid, DescriptionText[playerid]);
- return 1;
- }
- forward HideDescriptionText(playerid);
- new PNAME[MAX_PLAYER_NAME];
- new afk[MAX_PLAYERS];
- new Text3D:label[MAX_PLAYERS];
- stock ShowDescriptionText(playerid, string[])
- {
- KillTimer(DescriptionTimer[playerid]);
- TextDrawSetString(DescriptionText[playerid], string);
- TextDrawShowForPlayer(playerid, DescriptionText[playerid]);
- DescriptionTimer[playerid] = SetTimerEx("HideDescriptionText", 5000, 0, "i", playerid);
- return 1;
- }
- CMD:afk(playerid, params[])
- {
- 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 -|");
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{00FFFF}-Reason:", "{FFFF00}Please insert here why would you be in afk - status", "Done", "Exit");
- return 1;
- }
- CMD:back(playerid,params[])
- {
- if(afk[playerid] == 0) return SendClientMessage(playerid,blue, "{00FFFF}[Error]:{FFFFFF} You ain't afk to use this command{CC0000}..");
- {
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{00FFFF}-Welcome:", "{FFFF00}Please insert here a comment for being back", "Done", "Exit");
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- afk[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- afk[playerid] = 0;
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(afk[playerid] == 1) {
- SendClientMessage(playerid, blue, "{00FFFF}[Error]:{FFFFFF} You can't chat while you are afk{CC0000}..");
- return 0;
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 1)
- if(response == 0) {
- new string[128];
- SendClientMessage(playerid, blue,"{00FFFF}[Exited]:{FFFFFF} You have choosed the option {FF0000}'Exit'{FFFFFF} instead if going away, Complete Playing{FF0000}..");
- return 1;
- }
- else if(response == 1) {
- if(!strlen(inputtext)) {
- SendClientMessage(playerid, blue, "{00FFFF}[Error]:{FFFFFF} You have to type a reason for being afk{FF0000}..");
- } else if(strlen(inputtext))
- {
- new string[128],pname[32];
- GetPlayerName(playerid,pname,sizeof(pname));
- format(string,sizeof(string),"{00FFFF}[Appointment]:{CC0000} %s {FFFFFF}is now away from keyboard, {00FFFF}[Reason]: {CC0000}%s.. ",pname,inputtext);
- SendClientMessageToAll(blue, string);
- label[playerid] = Create3DTextLabel(" ",0xFF0000FF,30.0,40.0,50.0,15.0,0);
- format(string,sizeof(string),"AFK |-Reason: %s -|",inputtext);
- SendClientMessage(playerid, blue, "{00FFFF}[Information]{FFFFFF} Type {00FFFF}/back{FFFFFF} when you come back, and to recurrence your return{FF0000}..");
- TogglePlayerControllable(playerid,0);
- SetPlayerHealth(playerid, 999999);
- SetPlayerArmour(playerid, 999999);
- SetPlayerVirtualWorld(playerid, 191);
- format(string, sizeof(string), "~w~You are afk~w~");
- ShowDescriptionText(playerid, string);
- afk[playerid] = 1;
- return 1;
- }
- }
- if(dialogid == 2)
- if(response == 0) {
- new string[128];
- SendClientMessage(playerid, blue,"{00FFFF}[Exited]:{FFFFFF} You have choosed the {00FFFF}'Exit'{FFFFFF} Option, therefore you still away from keybaord{CC0000}..");
- return 1;
- }
- else if(response == 1) {
- if(!strlen(inputtext)) {
- SendClientMessage(playerid, blue, "{00FFFF}[Error]:{FFFFFF} You have to type a {00FFFF}'Comment'{FFFFFF} to get back{CC0000}..");
- } else if(strlen(inputtext))
- {
- new string[128],pname[32];
- GetPlayerName(playerid,pname,sizeof(pname));
- format(string,sizeof(string),"{00FFFF}[Appointment]{CC0000} %s {FFFFFF}is now back, {00FFFF}[Comment]:{CC0000} %s.. ",pname,inputtext);
- SendClientMessageToAll(blue, string);
- SendClientMessage(playerid, blue, "{00FFFF}[Welcome]{FFFFFF} Welcome back, enjoy your stay{CC0000}..");
- label[playerid] = Create3DTextLabel("Playing",0xE60000FF,30.0,40.0,50.0,40.0,0);
- Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
- TogglePlayerControllable(playerid,1);
- SetPlayerHealth(playerid, 100);
- SetPlayerArmour(Playerid, 24);
- SetPlayerVirtualWorld(playerid, 0)
- GameTextForPlayer(playerid,"Welcome Back",15000,6);
- afk[playerid] = 0;
- return 1;
- }
- }
- return 0;
- }
- 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(afk[i] == 1)
- {
- format(string, sizeof(string), "%sPlayer: {FF0000}%s, {FF0000}ID: {FFFFFF}%d\n",
- string, pName, i);
- count++;
- }
- }
- }
- if (count == 0)
- {
- SendClientMessage(playerid, blue, "{FF0000}[Alert]{FFFFFF} There is no any afk player{CC0000}..");
- }
- else ShowPlayerDialog(playerid,837,DIALOG_STYLE_LIST,"-Afk Players",string,"Exit","");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment