Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ** ---------- Away From Keyboard (AFK) + Private Message (PM) System ----------- **
- ** ----------- Author : SevenSlash ------------- **
- ** ----------------------------------------------------------------------------- **
- **
- ** ==> PM System ==>
- 1) /pm
- 2) /disablepms
- 3) /enablepms
- 4) /ignore
- 5) /unignore
- ** ==> AFK System ==>
- 1) /afk
- 2) /back
- 3) /afklist
- */
- #include <a_samp>
- #include <sscanf2>
- #include <zcmd>
- new isAFK[MAX_PLAYERS];
- new isDisabled[MAX_PLAYERS];
- new ignored[MAX_PLAYERS];
- stock GetName (playerid)
- {
- new pName[MAX_PLAYER_NAME];
- GetPlayerName( playerid, pName, sizeof(pName) );
- return pName;
- }
- public OnFilterScriptInit()
- {
- print("\n::-> 7Slash AFK + PM System loaded.\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- isAFK[playerid] = 0;
- isDisabled[playerid] = 0;
- ignored[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- isAFK[playerid] = 0;
- isDisabled[playerid] = 0;
- ignored[playerid] = 0;
- return 1;
- }
- CMD:afk (playerid, params[])
- {
- new str[128], str2[128];
- if ( isAFK[playerid] == 1 ) return SendClientMessage( playerid, -1, "{FC1C1C}ERROR: {CFE5E8}You are already in AFK mode! Type {E6EBB9}/back {CFE5E8}to deactivate AFK mode!" );
- TogglePlayerControllable(playerid, 0);
- format( str, sizeof(str), "{B8F279}-AFK- {F7F265}%s(%d) is now Away From Keyboard (AFK)!", GetName( playerid ), playerid );
- format( str2, sizeof(str2), "~g~%s[%d] ~w~is AFK", GetName(playerid), playerid );
- GameTextForAll( str2, 2500, 1 );
- SendClientMessageToAll( -1, str );
- isAFK[playerid] = 1;
- return 1;
- }
- CMD:back (playerid, params[])
- {
- new str[128], str2[128];
- if ( isAFK[playerid] == 0 ) return SendClientMessage( playerid, -1, "{FC1C1C}ERROR: {CFE5E8}You are not in AFK mode! Type {E6EBB9}/afk {CFE5E8}to activate AFK mode!" );
- TogglePlayerControllable(playerid, 1);
- format( str, sizeof(str), "{B8F279}-AFK- {F7F265}%s(%d) is now back in game!", GetName( playerid ), playerid );
- format( str2, sizeof(str2), "~g~%s[%d] ~w~is BACK", GetName(playerid), playerid );
- GameTextForAll( str2, 2500, 1 );
- SendClientMessageToAll( -1, str );
- isAFK[playerid] = 0;
- return 1;
- }
- CMD:pm ( playerid, params[] )
- {
- new str1[128], msg[128], str2[128], str3[128], giveid;
- if ( sscanf(params, "us[128]", giveid, msg)) return SendClientMessage( playerid, -1, "{9DEBEB}USAGE: /pm <ID> <Text>" );
- else if ( giveid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "{FC1C1C}ERROR: {CFE5E8}Invalid player ID!" );
- else
- format( str1, sizeof(str1), "{F7F265}PM sent to %s(%d): {ACE2E6}%s", GetName( playerid ), playerid, msg );
- format( str2, sizeof(str2), "{F7F265}PM received from %s(%d): {ACE2E6}%s", GetName( giveid ), giveid, msg );
- if (isDisabled[giveid] == 1)
- {
- format( str3, sizeof(str3), "{FC1C1C}ERROR: {CFE5E8}%s(%d) has PMs disabled!", GetName(giveid), giveid );
- SendClientMessage( playerid, -1, str3 );
- return 1;
- }
- if (ignored[giveid] == 1)
- {
- format( str3, sizeof(str3), "{FC1C1C}ERROR: {CFE5E8}%s(%d) has chosen not to receive your PMs!", GetName(giveid), giveid );
- SendClientMessage( playerid, -1, str3 );
- return 1;
- }
- GameTextForPlayer( giveid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~~h~PM received!", 3000, 3 );
- GameTextForPlayer( playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~~h~PM sent!", 3000, 3 );
- SendClientMessage( playerid, -1, str1 );
- SendClientMessage( giveid, -1, str2 );
- return 1;
- }
- CMD:disablepms ( playerid )
- {
- isDisabled[playerid] = 1;
- SendClientMessage( playerid, -1, "{F7F265}You will no longer receive PMs from other players!" );
- return 1;
- }
- CMD:enablepms ( playerid )
- {
- isDisabled[playerid] = 0;
- SendClientMessage( playerid, -1, "{11ED65}You will now receive PMs from other players!" );
- return 1;
- }
- CMD:ignore ( playerid, params[] )
- {
- new giveid, str[126];
- if ( sscanf(params, "u", giveid )) return SendClientMessage( playerid, -1, "{9DEBEB}USAGE: /ignore <ID>" );
- if ( giveid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "{FC1C1C}ERROR: {CFE5E8}Invalid player ID!" );
- else
- ignored[giveid] = 1;
- format( str, sizeof(str), "{FC1C1C}You have ignored %s(%d) and you will no longer receive PMs from this player!", GetName( giveid ), giveid );
- SendClientMessage( playerid, -1, str );
- return 1;
- }
- CMD:unignore ( playerid, params[] )
- {
- new giveid, str[126];
- if ( sscanf(params, "u", giveid )) return SendClientMessage( playerid, -1, "{9DEBEB}USAGE: /unignore <ID>" );
- if ( giveid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "{FC1C1C}ERROR: {CFE5E8}Invalid player ID!" );
- else
- ignored[giveid] = 0;
- format( str, sizeof(str), "{11ED65}You have un-ignored %s(%d)!", GetName( giveid ), giveid );
- SendClientMessage( playerid, -1, str );
- return 1;
- }
- CMD:afklist ( playerid, params[] )
- {
- new str[128];
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- if (isAFK[i] == 1)
- {
- format( str, sizeof(str), "{F75A05}** Away From Keyboard (AFK) Players:\n{F07F1D}%s(%d)\r\n", GetName(i), i );
- ShowPlayerDialog( playerid, 0, DIALOG_STYLE_MSGBOX, "{FF0000}AFK List", str, "OK", "" );
- }
- else
- {
- SendClientMessage( playerid, -1, "{CFE5E8}No players are Away From Keyboard (AFK)." );
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement