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

Good, Rep+'ed.
Reply
#3

pawn Code:
if(!IsPlayerConnected(id)
Sscanf has built-in connection check so Just do
pawn Code:
if(id == INVALID_PLAYER_ID)
Nice tut Btw!
Reply
#4

your cmd can be done with max 7 lines

i dont think this is a tutorial but for beginners. they can play c&p and ye not a tutorial
Reply
#5

Um, hmmmm what to say....... When i first started pawn scripting, i learnt this command in like 5secs, not really useful i am afraid although well explained.
Reply
#6

0/10, not explain so edit your post plz, this is not a Tutoriel, it is a showroom of 2 commands^^
Reply
#7

Also you are aiming this at new scripters, who proberly don't fully now what zcmd and sscanf is, VERY BAD tut 0/10 admins remove,
Reply
#8

Sorry but this tutorial is awful. Your grammar is bad, you don't know what you're talking about and it's biased. Just giving some constructive criticism.
Reply
#9

7/10 good job man and the dude that says 0/10, Seriously how is it 0 while he showed 2 good commands. You shouldn't let someone down by saying 0/10 because 0/10 would be a tutorial with no codes or a post that is extremely horrible.
Reply
#10

please tell me a way how to use the /goto code for admin of level2+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)