Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // AFK System v1,2b
- // By Sim_sima
- // Made for Sim_sima's, Madsen's and HeavyBass's RPG server project.
- #include <a_samp>
- #define AFKVW 10 // Use this line to change the number of virtual world for AKF players
- new currentvw; // Gets the current virtual world of the player
- new currentcolor[MAX_PLAYERS]; // Gets the current color of the player
- new afk[MAX_PLAYERS];
- new Text:Textdraw0;
- new Text:Textdraw1;
- #define COLOR_YELLOW 0xFFFF00FF
- #define COLOR_GREY 0xAFAFAFFF
- #define COLOR_NORMALRED 0xAF0000FF
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_GREEN 0x009900FF
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("AFK System by Sim_sima loaded!");
- print("--------------------------------------\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SendClientMessage(playerid, COLOR_GREEN, "This server is using AFK-System v1.2b by Sim_sima. Type /afkhelp for more info.");
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/goafk", cmdtext, true, 10) == 0)
- {
- if(afk[playerid] == 1)
- {
- SendClientMessage(playerid, COLOR_NORMALRED, "You are already in AFK mode. Type /back to return");
- }
- else
- {
- afk[playerid] = 1;
- currentcolor[playerid] = GetPlayerColor(playerid);
- SetPlayerColor(playerid, COLOR_GREY);
- currentvw = GetPlayerVirtualWorld(playerid);
- SetPlayerVirtualWorld(playerid, AFKVW);
- TogglePlayerControllable(playerid, 0);
- new name[MAX_PLAYER_NAME], string[44];
- GetPlayerName(playerid, name, sizeof(name));
- format(string, sizeof(string), "%s is now in AFK mode",name);
- SendClientMessageToAll(COLOR_GREY, string);
- Textdraw0 = TextDrawCreate(266.000000, 145.000000, "Type /back to return");
- TextDrawBackgroundColor(Textdraw0, 255);
- TextDrawFont(Textdraw0, 1);
- TextDrawLetterSize(Textdraw0, 0.300000, 0.799998);
- TextDrawColor(Textdraw0, -1);
- TextDrawSetOutline(Textdraw0, 1);
- TextDrawSetProportional(Textdraw0, 1);
- Textdraw1 = TextDrawCreate(268.000000, 124.000000, "AFK Mode");
- TextDrawBackgroundColor(Textdraw1, 255);
- TextDrawFont(Textdraw1, 2);
- TextDrawLetterSize(Textdraw1, 0.500000, 2.599998);
- TextDrawColor(Textdraw1, 65535);
- TextDrawSetOutline(Textdraw1, 1);
- TextDrawSetProportional(Textdraw1, 1);
- TextDrawShowForPlayer(playerid, Textdraw0);
- TextDrawShowForPlayer(playerid, Textdraw1);
- }
- return 1;
- }
- if (strcmp("/back", cmdtext, true, 10) == 0)
- {
- if(afk[playerid] == 1)
- {
- afk[playerid] = 0;
- SetPlayerColor(playerid, currentcolor[playerid]);
- SetPlayerVirtualWorld(playerid, currentvw);
- TogglePlayerControllable(playerid, 1);
- GameTextForPlayer(playerid, "Welcome back", 3000, 5);
- new name[MAX_PLAYER_NAME], string[44];
- GetPlayerName(playerid, name, sizeof(name));
- format(string, sizeof(string), "%s is back from AFK mode",name);
- SendClientMessageToAll(COLOR_GREY, string);
- TextDrawHideForPlayer(playerid, Textdraw0);
- TextDrawDestroy(Textdraw0);
- TextDrawHideForPlayer(playerid, Textdraw1);
- TextDrawDestroy(Textdraw1);
- return 1;
- }
- else SendClientMessage(playerid, COLOR_NORMALRED, "You need to be in AFK mode to use this command. Type /goafk to go AFK");
- return 1;
- }
- new string[256];
- if (strcmp("/afklist", cmdtext, true) == 0)
- {
- SendClientMessage(playerid, COLOR_YELLOW, "-----------------------------------");
- SendClientMessage(playerid, COLOR_GREEN, "AFK LIST:");
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(afk[i] == 1)
- {
- new name[128];
- GetPlayerName(i,name,128);
- format(string, 256, "%s", name);
- SendClientMessage(playerid, COLOR_GREY, string);
- }
- }
- }
- SendClientMessage(playerid, COLOR_YELLOW, "-----------------------------------");
- return 1;
- }
- if (strcmp("/afkhelp", cmdtext, true, 10) == 0)
- {
- SendClientMessage(playerid, COLOR_YELLOW, "------------------------------------------------------------------------");
- SendClientMessage(playerid, COLOR_GREEN, "AFK System v1.1b by Sim_sima");
- SendClientMessage(playerid, COLOR_YELLOW, "------------------------------------------------------------------------");
- SendClientMessage(playerid, COLOR_WHITE, "AFK Commands:");
- SendClientMessage(playerid, COLOR_WHITE, "/goafk = Changes your status to AFK mode.");
- SendClientMessage(playerid, COLOR_WHITE, "/back = Returns you from AFK mode.");
- SendClientMessage(playerid, COLOR_WHITE, "/afklist = Shows a list of AFK players.");
- SendClientMessage(playerid, COLOR_YELLOW, "------------------------------------------------------------------------");
- return 1;
- }
- return 0;
- }
- public OnPlayerText(playerid, text[])
- {
- if(afk[playerid] == 1)
- {
- SendClientMessage(playerid, COLOR_NORMALRED, "You can not chat while in AFK mode. Type /back to return");
- return 0;
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(afk[playerid] == 1)
- {
- afk[playerid] = 0;
- SetPlayerVirtualWorld(playerid, currentvw);
- SetPlayerColor(playerid, currentcolor[playerid]);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement