08.10.2011, 13:47
(
Last edited by array13; 09/10/2011 at 10:10 AM.
)
Hello all,today im going to teach you(newbies) how to make a AFK command.
first of all, let's gonna create the "base command" for afk.
Ok, now we need to take the player location.
with this, you will be "recording" the current position of the player, now let's go to teleport the player for another virtual world.
we are almost done!
now let's gonna put the player on the other virtual world but on the same position and frozen(with a message saying he is afk):
ok your afk command is done!
if you want to all player know that player is afk,just add this on the command:
--------------------------------------------------------
Now the back command:
itґs almost the same thing, you just need to write all code again and need to do the correct modifications, the command already done need to look like this:
P.S.: I'm bad with tutorials,so if you didn't understand, feel free to ask.
first of all, let's gonna create the "base command" for afk.
PHP Code:
COMMAND:afk(playerid,params[])
{
//do something here
}
PHP Code:
COMMAND:afk(playerid,params[])
{
new Float: p[3] // this will be needed for the code below
GetPlayerPos(playerid, p[0], p[1], p[2]); //this code will take your player position
}
PHP Code:
COMMAND:afk(playerid,params[])
{
new Float: p[3] // this will be needed for the code below
GetPlayerPos(playerid, p[0], p[1], p[2]); //this code will take your player position
SetPlayerVirtualWorld(playerid, 1331); //this fuction will teleport you for another virtual world
}
now let's gonna put the player on the other virtual world but on the same position and frozen(with a message saying he is afk):
PHP Code:
COMMAND:afk(playerid,params[])
{
new Float: p[3] // this will be needed for the code below
GetPlayerPos(playerid, p[0], p[1], p[2]); //this code will take your player position
SetPlayerVirtualWorld(playerid, 1331); //this fuction will teleport you for another virtual world
SetPlayerPos(playerid, p[0], p[1], p[2]); //this will place the player on the same place, but on the other virtual world
TogglePlayerControllable(playerid, 0); //this fuction will freeze you during the afk time.
SendClientMessage(playerid, -1, "You are afk, Please type '/back' to return."); //this will send the message to player informing to him he his afk
return 1;
}
if you want to all player know that player is afk,just add this on the command:
PHP Code:
new PlayerName[MAX_PLAYER_NAME], //this will be needed to take the player name
string[128]; //the string for the message
GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); //this will take the player name
format(string, sizeof(string), "%s is Now afk", PlayerName); // the message with the string
SendClientMessageToAll(0xFF0000AA, string); //the message
Now the back command:
itґs almost the same thing, you just need to write all code again and need to do the correct modifications, the command already done need to look like this:
PHP Code:
COMMAND:back(playerid,params[])
{
new Float: p[3]
GetPlayerPos(playerid, p[0], p[1], p[2]);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid, p[0], p[1], p[2]);
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, -1, "Welcome back!");
new PlayerName[MAX_PLAYER_NAME],
string[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "%s is Back!", PlayerName);
SendClientMessageToAll(0xFF0000AA, string);
return 1;
}