[Tutorial] /goto and /gethere command
#1

Introduction
Hello people today i am gonna show you how you can create a /goto and /gethere command
What is it & what does it do?
Well the /goto command teleports a admin/player(whatever u like) to another player
and the /gethere command brings a player to a admin/player (whatever you like)
How's this scripted
Of course like always in zcmd using sscanf2
Shall we start
Of course but this time my tutorial is a little different earlier i used to explain the code afterward but now i will explain side by side..
Code of /goto
pawn Code:
CMD:goto(playerid, params[])
{
    new ID;//creates a new something idk what we call it :P but it is defined later on or used in something this 1 is used in next line
    if(sscanf(params, "u", ID)) SendClientMessage(playerid, 0xFF0000FF, "USAGE: /goto [id]");//checks if you have written something after /goto if no it sends error
    else if(!IsPlayerConnected(id) || id == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");//checks if the player you are teleporting to is connected or if it is yourself if yes then comes an error
    else//ELSE what will happen if no errors
    {
    new Float:x, Float:y, Float:z;//creates new floats
    GetPlayerPos(ID, x, y, z);//gets the player id(which we have entered after /goto position and like saves them into x,y,z defined above as floats
    SetPlayerPos(playerid, x+1, y+1, z);//sets the player position the id of that player +1 in x +1 in y and z remains same as it defines height
    }
    return 1;
}
Code for /gethere command
pawn Code:
CMD:gethere(playerid,params[])
{
    new targetid, Float:x, Float:y, Float:z;//defines floats and targetid(same which we did as id above)
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR, "USAGE: /gethere [id]");//checks if there is something written after /gethere if no sends the usage error
    if(!IsPlayerConnected(id) || id == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");//checks if the player is conneted or not and also checks that we are not teleporting ourselves to our self :P if we are it sends error
    GetPlayerPos(playerid, x, y, z);//gets player pos PLAYER POS not targetid
    SetPlayerPos(targetid, x+1, y+1, z);//gets the TARGETID player to the PLAYERID x+1,y+1 and z remains same as it defines height
    return 1;
}
End
Hope you have understood my tutorial if you have any problems reply here ,if you find bugs reply here and please do the first thing thats written on my sign if you liked it
Reply


Messages In This Thread
/goto and /gethere command - by §с†¶e®РµРe - 07.12.2011, 14:19
Re: /goto and /gethere command - by seanny - 07.12.2011, 14:31
Re: /goto and /gethere command - by CSSI - 07.12.2011, 15:08
Re: /goto and /gethere command - by Tigerkiller - 07.12.2011, 17:52
Re: /goto and /gethere command - by xMichaelx - 07.12.2011, 19:14
Re : /goto and /gethere command - by mehdi-jumper - 07.12.2011, 19:44
Re: /goto and /gethere command - by xMichaelx - 07.12.2011, 22:36
Re: /goto and /gethere command - by MP2 - 08.12.2011, 10:10
Re: /goto and /gethere command - by Tanush123 - 08.12.2011, 20:25
Re: /goto and /gethere command - by Wayn - 13.10.2012, 17:08

Forum Jump:


Users browsing this thread: 1 Guest(s)