[HELP] Two cmd's with the same name?
#1

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

using else if?
Reply
#3

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
}
Reply
#4

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
Reply
#5

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!
Reply
#6

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?
Reply
#7

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.
Reply
#8

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.
Reply
#9

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
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)