[Tutorial] How to create a AFK system with zcmd.
#1

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.

PHP Code:
COMMAND:afk(playerid,params[]) 
{   
   
//do something here

Ok, now we need to take the player location.

PHP Code:
COMMAND:afk(playerid,params[]) 
{   
   new 
Floatp[3// this will be needed for the code below
   
GetPlayerPos(playeridp[0], p[1], p[2]); //this code will take your player position

with this, you will be "recording" the current position of the player, now let's go to teleport the player for another virtual world.

PHP Code:
COMMAND:afk(playerid,params[]) 
{   
   new 
Floatp[3// this will be needed for the code below
   
GetPlayerPos(playeridp[0], p[1], p[2]); //this code will take your player position
   
SetPlayerVirtualWorld(playerid1331); //this fuction will teleport you 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):

PHP Code:
COMMAND:afk(playerid,params[]) 
{   
    new 
Floatp[3// this will be needed for the code below
    
GetPlayerPos(playeridp[0], p[1], p[2]); //this code will take your player position
    
SetPlayerVirtualWorld(playerid1331); //this fuction will teleport you for another virtual world
    
SetPlayerPos(playeridp[0], p[1], p[2]); //this will place the player on the same place, but on the other virtual world
    
TogglePlayerControllable(playerid0); //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;

ok your afk command is done!
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(playeridPlayerNamesizeof(PlayerName)); //this will take the player name
    
format(stringsizeof(string), "%s is Now afk"PlayerName); // the message with the string
    
SendClientMessageToAll(0xFF0000AAstring); //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 
Floatp[3]    
    
GetPlayerPos(playeridp[0],  p[1],  p[2]);
    
SetPlayerVirtualWorld(playerid0);
    
SetPlayerPos(playeridp[0],  p[1],  p[2]);             
    
TogglePlayerControllable(playerid1);     
    
SendClientMessage(playerid, -1"Welcome back!");
    new 
PlayerName[MAX_PLAYER_NAME],
    
string[128];
    
GetPlayerName(playeridPlayerNamesizeof(PlayerName));
    
format(stringsizeof(string), "%s is Back!"PlayerName);
    
SendClientMessageToAll(0xFF0000AAstring);
    return 
1

P.S.: I'm bad with tutorials,so if you didn't understand, feel free to ask.
Reply


Messages In This Thread
How to create a AFK system with zcmd. - by array13 - 08.10.2011, 13:47
Re: How to create a AFK system with zcmd. - by Scenario - 08.10.2011, 13:51
Re: How to create a AFK system with zcmd. - by array13 - 08.10.2011, 13:52
Re: How to create a AFK system with zcmd. - by Scenario - 08.10.2011, 13:56
Re: How to create a AFK system with zcmd. - by array13 - 08.10.2011, 13:57
Re: How to create a AFK system with zcmd. - by BaubaS - 08.10.2011, 15:03
Re: How to create a AFK system with zcmd. - by array13 - 08.10.2011, 15:24
Re: How to create a AFK system with zcmd. - by BaubaS - 08.10.2011, 16:09
Re: How to create a AFK system with zcmd. - by FireCat - 08.10.2011, 20:26
Re: How to create a AFK system with zcmd. - by gtakillerIV - 28.07.2012, 17:20

Forum Jump:


Users browsing this thread: 1 Guest(s)