07.12.2011, 14:19
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
Code for /gethere command
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
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;
}
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;
}
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