[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
#2

This is not a tutorial.
Reply
#3

^^have you saw the last phrase?
im bad with tutorials '-'
Reply
#4

Quote:
Originally Posted by kikito
View Post
^^have you saw the last phrase?
im bad with tutorials '-'
This doesn't even come close to being a tutorial. You didn't explain anything! Why are you writing up a bunch of BS which isn't going to teach anyone anything, if you don't know how to thoroughly explain why you are doing what you need to do in the tutorial?
Reply
#5

^^im just trying to help '-'
Reply
#6

zcmd for one command, and even without params? I dont see any point of using zcmd here
Reply
#7

Quote:
Originally Posted by BaubaS
View Post
zcmd for one command, and even without params? I dont see any point of using zcmd here
you mean 2 commands
Reply
#8

1, 2.. what ever
Reply
#9

"ps: Im bad with tutoriais,so if you understand,please ask"
"P.S.: I'm bad with tutorials,so if you didn't understand, feel free to ask."
Reply
#10

Guys I am soo new to pawno so what does this mean?

new PlayerName[MAX_PLAYER_NAME]

string[128];

What do thoses two mean please help me thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)