#include <zcmd>
#include <a_samp>
#include <zcmd>
#define COLOR_GREEN 0x33AA33AA
#define COLOR_ORANGE 0xFF9900AA
#include <a_samp>
#include <zcmd>
#define COLOR_GREEN 0x33AA33AA
#define COLOR_ORANGE 0xFF9900AA
new
afk[ MAX_PLAYERS char ]
;
CMD:afk(playerid, params[]) {
new name[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, name, sizeof(name));
if( afk{ playerid } ) SendClientMessage(playerid, COLOR_ORANGE, "[AFK] - You're already afk!");
if( afk{ playerid } ) SendClientMessage(playerid, COLOR_ORANGE, "[AFK] - You're already afk!");
else
{
afk{ playerid } = true;
SetPlayerHealth(playerid, 99999);
SetPlayerArmour(playerid, 99999);
TogglePlayerControllable(playerid, 0);
TogglePlayerControllable(playerid, 0);
format(string, sizeof(string), "[AFK] - %s is now afk!", name);
SendClientMessageToAll(COLOR_ORANGE, string);
SendClientMessage(playerid, COLOR_ORANGE, "[AFK] - When you come back, use /back!");
CMD:afk(playerid, params[]) {
new name[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, name, sizeof(name));
if( afk{ playerid } ) SendClientMessage(playerid, COLOR_ORANGE, "[AFK] - You're already afk!");
else
{
afk{ playerid } = true;
SetPlayerHealth(playerid, 99999);
SetPlayerArmour(playerid, 99999);
TogglePlayerControllable(playerid, 0);
format(string, sizeof(string), "[AFK] - %s is now afk!", name);
SendClientMessageToAll(COLOR_ORANGE, string);
SendClientMessage(playerid, COLOR_ORANGE, "[AFK] - When you come back, use /back!");
}
return 1;
}
CMD:back(playerid, params[]) {
if( !afk{ playerid } ) SendClientMessage(playerid, COLOR_ORANGE, "[BACK] - You aren't afk!");
else
{
new name[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, name, sizeof(name));
SetPlayerHealth(playerid, 99);
SetPlayerArmour(playerid, 99);
TogglePlayerControllable(playerid, 1);
TogglePlayerControllable(playerid, 1);
format(string, sizeof(string), "[BACK] - %s is now back!", name);
SendClientMessageToAll(COLOR_GREEN, string);
SendClientMessage(playerid, COLOR_GREEN, "[BACK] - Welcome back!");
afk{ playerid } = false;
format(string, sizeof(string), "[BACK] - %s is now back!", name);
SendClientMessageToAll(COLOR_GREEN, string);
SendClientMessage(playerid, COLOR_GREEN, "[BACK] - Welcome back!");
afk{ playerid } = false;
if( !afk{ playerid } ) SendClientMessage(playerid, COLOR_ORANGE, "[BACK] - You aren't afk!");
afk{ playerid } = false;
CMD:back(playerid, params[]) {
if( !afk{ playerid } ) SendClientMessage(playerid, COLOR_ORANGE, "[BACK] - You aren't afk!");
else
{
new name[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, name, sizeof(name));
SetPlayerHealth(playerid, 99);
SetPlayerArmour(playerid, 99);
TogglePlayerControllable(playerid, 1);
format(string, sizeof(string), "[BACK] - %s is now back!", name);
SendClientMessageToAll(COLOR_GREEN, string);
SendClientMessage(playerid, COLOR_GREEN, "[BACK] - Welcome back!");
afk{ playerid } = false;
}
return 1;
}
Maybe you can put some SetPlayerPos with saving old when typing /back because you can abuse this for god mode or something...
|
ResetPlayerWeapons(playerid);
SetPlayerPos(playerid, 373.825653,-117.270904,1001.499511);
SetPlayerInterior(playerid, 5);
CMD:afk(playerid, params[]) {
new name[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, name, sizeof(name));
if( afk{ playerid } ) SendClientMessage(playerid, COLOR_ORANGE, "[AFK] - You're already afk!");
else
{
SetPlayerPos(playerid, 373.825653,-117.270904,1001.499511);
SetPlayerInterior(playerid, 5);
afk{ playerid } = true;
SetPlayerHealth(playerid, 99999);
SetPlayerArmour(playerid, 99999);
ResetPlayerWeapons(playerid);
TogglePlayerControllable(playerid, 0);
format(string, sizeof(string), "[AFK] - %s is now afk!", name);
SendClientMessageToAll(COLOR_ORANGE, string);
SendClientMessage(playerid, COLOR_ORANGE, "[AFK] - When you come back, use /back!");
}
return 1;
}
public OnPlayerUpdate(playerid)
{
if( afk { playerid }) {
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x,y,z);
if(x != 373.825653 && y != -117.270904 && z != 1001.499511) //If a hacker will try to teleport to people.
SetPlayerPos(playerid, 373.825653,-117.270904,1001.499511);//He will be set to this position.
SetPlayerInterior(playerid, 5);
}
return 1;
}
CMD:back(playerid, params[]) {
if( !afk{ playerid } ) SendClientMessage(playerid, COLOR_ORANGE, "[BACK] - You aren't afk!");
else
{
new name[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, name, sizeof(name));
SetPlayerInterior(playerid, 0);
SpawnPlayer(playerid); //Spawns the player, so the player isn't stuck in the shop interior.
SetPlayerHealth(playerid, 99);
SetPlayerArmour(playerid, 99);
TogglePlayerControllable(playerid, 1);
format(string, sizeof(string), "[BACK] - %s is now back!", name);
SendClientMessageToAll(COLOR_GREEN, string);
SendClientMessage(playerid, COLOR_GREEN, "[BACK] - Welcome back!");
afk{ playerid } = false;
}
return 1;
}