SA-MP Forums Archive
[HELP] Two cmd's with the same name? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Two cmd's with the same name? (/showthread.php?tid=82717)



[HELP] Two cmd's with the same name? - FreddeN - 20.06.2009

Hello
I want two cmd's like /enter with the same name... so I dont need to change to example /enterpd and /enterhp, I want more that one /enter cmd's... also /exit,

Thanks


Re: [HELP] Two cmd's with the same name? - MenaceX^ - 20.06.2009

using else if?


Re: [HELP] Two cmd's with the same name? - Grim_ - 20.06.2009

Something like this...
pawn Код:
if(strcmp(cmdtext, "/enter", true) == 0)
{
  if(PlayerToPoint(3, playerid, x, y, z)) //put the coordinates of the enter position of bulding 1
  {
   //code here
  }
  else if(PlayerToPoint(3, playerid, x, y, z)) //put the coordinates of the enter position of building 2
  {
   //code here
  }
  ///and so on
}



Re: [HELP] Two cmd's with the same name? - FreddeN - 20.06.2009

Quote:
Originally Posted by Swift_
Something like this...
pawn Код:
if(strcmp(cmdtext, "/enter", true) == 0)
{
 if(PlayerToPoint(3, playerid, x, y, z)) //put the coordinates of the enter position of bulding 1
 {
   //code here
 }
 else if(PlayerToPoint(3, playerid, x, y, z)) //put the coordinates of the enter position of building 2
 {
   //code here
 }
 ///and so on
}
I have it like this, but i get 4 warnings

Код:
	if (strcmp("/enter", cmdtext, true, 10) == 0)
	{
	if(PlayerToPoint(playerid,1172.6697,-1321.4301,15.3988,3)) { 
	SetPlayerPos(playerid,288.745971,169.350997,1007.171875);
  	SetPlayerInterior(playerid,3);
	}
	else if(PlayerToPoint(playerid,2148.9336,-1484.9655,26.6240,3)) { 
 	SetPlayerPos(playerid,2454.717041,-1700.871582,1013.515197);
 	SetPlayerInterior(playerid,2);
	}
	return 1;
 	}
	if (strcmp("/exit", cmdtext, true, 10) == 0)
	{
	if(PlayerToPoint(playerid,288.745971,169.350997,1007.171875,3)) { 
	SetPlayerPos(playerid,1172.6697,-1321.4301,15.3988);
 	SetPlayerInterior(playerid,0);
	}
	else if(PlayerToPoint(playerid,2454.717041,-1700.871582,1013.515197,3)) { 
 	SetPlayerPos(playerid,2148.9336,-1484.9655,26.6240);
 	SetPlayerInterior(playerid,0);
	}
	return 1;
 	}
	return 0;
}
The Warnings:

Код:
tag mismatch
tag mismatch
tag mismatch
tag mismatch



Re: [HELP] Two cmd's with the same name? - Grim_ - 20.06.2009

You added the params to the PlayerToPoint function incorrectly.
pawn Код:
PlayerToPoint(Float:radius, playerid, Float:x, Float:y, Float:z)
You put the radius at the end instead of the beginning!


Re: [HELP] Two cmd's with the same name? - FreddeN - 20.06.2009

Quote:
Originally Posted by Swift_
You added the params to the PlayerToPoint function incorrectly.
pawn Код:
PlayerToPoint(Float:radius, playerid, Float:x, Float:y, Float:z)
You put the radius at the end instead of the beginning!
Alright, but what do you mean with radius, where can I find that number?


Re: [HELP] Two cmd's with the same name? - Abernethy - 20.06.2009

Quote:
Originally Posted by Swift_
You added the params to the PlayerToPoint function incorrectly.
pawn Код:
PlayerToPoint(Float:radius, playerid, Float:x, Float:y, Float:z)
You put the radius at the end instead of the beginning!
You mean beginning instead of the end.


Re: [HELP] Two cmd's with the same name? - Grim_ - 20.06.2009

The radius is how far away the player can be for the function to be called.
For example, if you set the radius is 3, then the player must be within 3 (meters?) of the x, y, and z coordinates.
Though, you can set it to whatever you like, depending how close or far away you wish the player to be.

@Abernethy: No, he put it at the end of the function, so I stated it needed to go at the front.


Re: [HELP] Two cmd's with the same name? - FreddeN - 20.06.2009

Quote:
Originally Posted by Swift_
The radius is how far away the player can be for the function to be called.
For example, if you set the radius is 3, then the player must be within 3 (meters?) of the x, y, and z coordinates.
Though, you can set it to whatever you like, depending how close or far away you wish the player to be.

@Abernethy: No, he put it at the end of the function, so I stated it needed to go at the front.
It didnt work, I putted radius 3, just to test it, first the warnings become 2, but when I did it on the rest of the coords, it become 4 warnings again


Re: [HELP] Two cmd's with the same name? - Grim_ - 20.06.2009

Err..show the code you have, and which lines are giving which errors.