Help with /enter and /exit
#1

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/enter", cmdtext, true, 10) == 0) // Hospital Enter
	{
 	if(PlayerToPoint(playerid,1172.6697,-1321.4301,15.3988,3)) {
 	SetPlayerPos(playerid,288.745971,169.350997,1007.171875);
  	SetPlayerInterior(playerid,3);
  }
  return 1;
	}
	if (strcmp("/exit", cmdtext, true, 10) == 0) // Hospital Exit
	{
 	if(PlayerToPoint(playerid,288.745971,169.350997,1007.171875,3)) {
 	SetPlayerPos(playerid,1172.6697,-1321.4301,15.3988);
 	SetPlayerInterior(playerid,0);
 	 }
 	return 1;
	}
	if (strcmp("/enter", cmdtext, true, 10) == 0) // Bloods Enter
	{
 		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) // Bloods Exit
	{
	  if(PlayerToPoint(playerid,2454.717041,-1700.871582,1013.515197,3)) {
	  SetPlayerPos(playerid,2148.9336,-1484.9655,26.6240);
	  SetPlayerInterior(playerid,0);
	  }
	  return 1;
	}
So i made 2 places where i want do /enter the building 1 is at ballas house and other hospital
But if i compiled and went tryed it, it only allowed me to go in hospital, bloods house didnt work anymore, what im doing wrong?
Without the hospital /enter and /exit, bloods house works
Reply
#2

You have the /enter and /exit command twice. That means it basicly executes the first ones only.
Solution: Merge the enter commands and exit commands into one command. But watch out! Do not merge the strcmp line, only whats inside of it.

You would get something like this:
Code:
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(PlayerToPoint(..)) { //Hospital
//code }
else if(PlayerToPoint(..)) { //Ballas
//code
}
}
I'd also strongly advise you to watch the indenting, each line after a { requires a tab.
Reply
#3

Uhm... Cant understand anything what u did

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp("/enter", cmdtext, true, 10) == 0);
	{
	if(PlayerToPoint(1172.6697,-1321.4301,15.3988,3)) { //Hospital
	SetPlayerPos(playerid,288.745971,169.350997,1007.171875);
 	SetPlayerInterior(playerid,3);
	}
	else if(PlayerToPoint(2148.9336,-1484.9655,26.6240)) { //Ballas
 	SetPlayerPos(playerid,2454.717041,-1700.871582,1013.515197);
	SetPlayerInterior(playerid,2);
	}
	return 1;
	}
	if (strcmp("/exit", cmdtext, true, 10) == 0);
	{
	if(PlayerToPoint(288.745971,169.350997,1007.171875,3)) { //Hospital
	SetPlayerPos(playerid,1172.6697,-1321.4301,15.3988);
 	SetPlayerInterior(playerid,0);
	}
	else if(PlayerToPoint(2454.717041,-1700.871582,1013.515197,3)) { //Ballas
	SetPlayerPos(playerid,2148.9336,-1484.9655,26.6240);
	SetPlayerInterior(playerid,0);
	}
	return 1;
}
	return 0;
}
You mean like this? I get errors

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/enter", cmdtext, true, 10) == 0)
	{
	if(PlayerToPoint(playerid,1172.6697,-1321.4301,15.3988,3)) { //Hospital
	SetPlayerPos(playerid,288.745971,169.350997,1007.171875);
  	SetPlayerInterior(playerid,3);
	}
	else if(PlayerToPoint(playerid,2148.9336,-1484.9655,26.6240,3)) { //Ballas
 	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)) { //Hospital
	SetPlayerPos(playerid,1172.6697,-1321.4301,15.3988);
 	SetPlayerInterior(playerid,0);
	}
	else if(PlayerToPoint(playerid,2454.717041,-1700.871582,1013.515197,3)) { //Ballas
 	SetPlayerPos(playerid,2148.9336,-1484.9655,26.6240);
 	SetPlayerInterior(playerid,0);
	}
	return 1;
 }
	return 0;
}
Okay, no errors here, and works, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)