SA-MP Forums Archive
/goto command. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /goto command. (/showthread.php?tid=541235)



/goto command. - mkmk - 10.10.2014

Well I'm new to the scripting world and I just need someone to really help me out. I need help with how you'd script a '/goto' command. The command would be used for admins only and would TP one player to another, thank you if you can help, it will be much appreciated. Sorry if I sound 'noobish', but everyone started once, didn't they!

EDIT: Also, where do I actually put the code for plugins etc? >.> Sorry, can somebody please help me out, I'm really having issues.


Re: /goto command. - AmirRFCNR - 10.10.2014

pawn Код:
CMD:goto(playerid,params[])
{
new pname[MAX_PLAYER_NAME],aname[MAX_PLAYER_NAME],string[128],id; /*Creates the player's name to teleport to, and the admin that initiated the command, and the target ID to teleport to.*/
if(!IsPlayerAdmin(playerid)) == 0) /*Checks if the player is logged into RCON. If your script has its own admin system use that.*/
{
if(sscanf(params,"u",id)) SendClientMessage(playerid, 0xAA3333AA, "/goto <id>"); /*Takes the ID you entered and makes it the "id" we defined. If no ID is entered the error message shows up*/
if(playerid == id) return SendClientMessage(playerid, 0xAA3333AA, "You can't teleport to yourself..."); /*Checks if the player id entered is not yours and if it is it shows the error message*/
else {
if(!IsPlayerConnected(id)) SendClientMessage(playerid, 0xAA3333AA, "Player is Not Online"); /*Checks if the ID entered is a player that is online in the server, otherwise sends the error message*/
else {
new Float:x,Float:y,Float:z; //Defines the x,y, and z co-ordinates of the target player
GetPlayerPos(id,Float:x,Float:y,Float:z)://Sets what the x,y, and z means
GetPlayerName(id,pname,sizeof(pname)); //Gets the name of the player that is to be teleported to
SetPlayerPos(playerid,x,y,z);//Teleports the admin to the player's x,y, and z co-ordinates we set earlier
format(string,sizeof(string),"Teleported to %s!",pname);//Shows the admin they teleported to the player
SendClientMessage(playerid, 0xAA333AA, string);//^^
}
}
}
else return 0; //Sends the "SERVER: Unknown command" if the person wanting to teleport isn't an admin
return 1;
}
with using ZCMD


Re: /goto command. - YanLanger - 10.10.2014

mhm. ****** ?


Re: /goto command. - mkmk - 10.10.2014

Quote:
Originally Posted by AmirRFCNR
Посмотреть сообщение
pawn Код:
CMD:goto(playerid,params[])
{
new pname[MAX_PLAYER_NAME],aname[MAX_PLAYER_NAME],string[128],id; /*Creates the player's name to teleport to, and the admin that initiated the command, and the target ID to teleport to.*/
if(!IsPlayerAdmin(playerid)) == 0) /*Checks if the player is logged into RCON. If your script has its own admin system use that.*/
{
if(sscanf(params,"u",id)) SendClientMessage(playerid, 0xAA3333AA, "/goto <id>"); /*Takes the ID you entered and makes it the "id" we defined. If no ID is entered the error message shows up*/
if(playerid == id) return SendClientMessage(playerid, 0xAA3333AA, "You can't teleport to yourself..."); /*Checks if the player id entered is not yours and if it is it shows the error message*/
else {
if(!IsPlayerConnected(id)) SendClientMessage(playerid, 0xAA3333AA, "Player is Not Online"); /*Checks if the ID entered is a player that is online in the server, otherwise sends the error message*/
else {
new Float:x,Float:y,Float:z; //Defines the x,y, and z co-ordinates of the target player
GetPlayerPos(id,Float:x,Float:y,Float:z)://Sets what the x,y, and z means
GetPlayerName(id,pname,sizeof(pname)); //Gets the name of the player that is to be teleported to
SetPlayerPos(playerid,x,y,z);//Teleports the admin to the player's x,y, and z co-ordinates we set earlier
format(string,sizeof(string),"Teleported to %s!",pname);//Shows the admin they teleported to the player
SendClientMessage(playerid, 0xAA333AA, string);//^^
}
}
}
else return 0; //Sends the "SERVER: Unknown command" if the person wanting to teleport isn't an admin
return 1;
}
with using ZCMD
Thank you, much appreciated.
But where do I put the code? >.>


Re: /goto command. - GGRoleplay - 10.10.2014

Quote:
Originally Posted by mkmk
Посмотреть сообщение
Thank you, much appreciated.
But where do I put the code? >.>
Put it just somewhere in your script (not in a public or whatever)
And make sure you got zcmd


Re: /goto command. - AmirRFCNR - 10.10.2014

like you want
like me i did my cmds codes under

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    return 0;
}
//here....



Re: /goto command. - mkmk - 10.10.2014

Quote:
Originally Posted by AmirRFCNR
Посмотреть сообщение
pawn Код:
CMD:goto(playerid,params[])
{
new pname[MAX_PLAYER_NAME],aname[MAX_PLAYER_NAME],string[128],id; /*Creates the player's name to teleport to, and the admin that initiated the command, and the target ID to teleport to.*/
if(!IsPlayerAdmin(playerid)) == 0) /*Checks if the player is logged into RCON. If your script has its own admin system use that.*/
{
if(sscanf(params,"u",id)) SendClientMessage(playerid, 0xAA3333AA, "/goto <id>"); /*Takes the ID you entered and makes it the "id" we defined. If no ID is entered the error message shows up*/
if(playerid == id) return SendClientMessage(playerid, 0xAA3333AA, "You can't teleport to yourself..."); /*Checks if the player id entered is not yours and if it is it shows the error message*/
else {
if(!IsPlayerConnected(id)) SendClientMessage(playerid, 0xAA3333AA, "Player is Not Online"); /*Checks if the ID entered is a player that is online in the server, otherwise sends the error message*/
else {
new Float:x,Float:y,Float:z; //Defines the x,y, and z co-ordinates of the target player
GetPlayerPos(id,Float:x,Float:y,Float:z)://Sets what the x,y, and z means
GetPlayerName(id,pname,sizeof(pname)); //Gets the name of the player that is to be teleported to
SetPlayerPos(playerid,x,y,z);//Teleports the admin to the player's x,y, and z co-ordinates we set earlier
format(string,sizeof(string),"Teleported to %s!",pname);//Shows the admin they teleported to the player
SendClientMessage(playerid, 0xAA333AA, string);//^^
}
}
}
else return 0; //Sends the "SERVER: Unknown command" if the person wanting to teleport isn't an admin
return 1;
}
with using ZCMD
When inserting the script I got 10 errors xD


Re: /goto command. - AmirRFCNR - 10.10.2014

copy it here..
Do you have ZCMD include ?



Re: /goto command. - mkmk - 10.10.2014

Quote:
Originally Posted by AmirRFCNR
Посмотреть сообщение
copy it here..
Do you have ZCMD include ?
I honestly have no idea what that is.


Re: /goto command. - Gogeta - 10.10.2014

You can't make your own server with random scripted commands.You should have your own register system/admin system, always when someone scripts something for you it will contain errors becuase not evryone scripts same.