Gate Isnt Closing?
#1

So here are my two commands

Код:
	if(strcmp("/Modshopgateopen", cmdtext, true, 10) == 0)
	{
 			MoveObject(garage, 1694.30664062,758.06933594,15.19236946, 2.0);
 			GameTextForPlayer(playerid, "Garage ~r~opening", 5000, 6);
 			new Float:pX, Float:pY, Float:pZ;
			PlayerPlaySound(playerid,1057,pX,pY,pZ);
    		return 1;
	}
	if(strcmp("/Modshopgateclose", cmdtext, true, 10) == 0)
	{
 			MoveObject(garage, 1694.30664062,758.06933594,11.65923691,  2.0);
 			GameTextForPlayer(playerid, "Garage ~g~closing", 5000, 6);
 			new Float:pX, Float:pY, Float:pZ;
			PlayerPlaySound(playerid,1057,pX,pY,pZ);
   			return 1;
   	}
The first one works but the second one dosnt. it says gate closing but it dosnt close. Whys that?
Reply
#2

Double check again to make sure. Try removing the '10' parameter in your string compare function. Also, you can just play the player sound at 0, 0, 0. It will just play it at the player's position.
Reply
#3

Quote:
Originally Posted by Backwardsman97
Посмотреть сообщение
Double check again to make sure. Try removing the '10' parameter in your string compare function. Also, you can just play the player sound at 0, 0, 0. It will just play it at the player's position.
What would i set 10 to? would i set it blank?
Reply
#4

To the length of the command. Ex. "/Modshopgateclose" = 17
Reply
#5

The 10 means checking the first 10 characters of the string which would be "/ModShopGa", so removing the 10 is ideal. Also, you should use a else if for the second command check, that way it's going to be one or the other & never trigger both. Seems to be an extra space before the 2.0 on the 2nd Command Check, but that shouldn't really affect anything.

The only problem I can think of with the details you provided is maybe the object is still opening (Moving) when you attempt to close it, maybe ignoring the MoveObject... Or somehow the Open is triggered lastly setting it to move to the open position making it look like nothing's happening...

Either way, try to fix up what I recommended, the problem might then solve itself
Reply
#6

Try this.

pawn Код:
if(strcmp("/Modshopgateopen", cmdtext, true) == 0)
{
    MoveObject(garage, 1694.30664062,758.06933594,15.19236946, 2.0);
    GameTextForPlayer(playerid, "Garage ~r~opening", 5000, 6);
    PlayerPlaySound(playerid,1057,0,0,0);
    return 1;
}
if(strcmp("/Modshopgateclose", cmdtext, true) == 0)
{
    MoveObject(garage, 1694.30664062,758.06933594,11.65923691,  2.0);
    GameTextForPlayer(playerid, "Garage ~g~closing", 5000, 6);
    PlayerPlaySound(playerid,1057,0,0,0);
    return 1;
}
Reply
#7

Quote:
Originally Posted by Backwardsman97
Посмотреть сообщение
Try this.

pawn Код:
if(strcmp("/Modshopgateopen", cmdtext, true) == 0)
{
    MoveObject(garage, 1694.30664062,758.06933594,15.19236946, 2.0);
    GameTextForPlayer(playerid, "Garage ~r~opening", 5000, 6);
    PlayerPlaySound(playerid,1057,0,0,0);
    return 1;
}
if(strcmp("/Modshopgateclose", cmdtext, true) == 0)
{
    MoveObject(garage, 1694.30664062,758.06933594,11.65923691,  2.0);
    GameTextForPlayer(playerid, "Garage ~g~closing", 5000, 6);
    PlayerPlaySound(playerid,1057,0,0,0);
    return 1;
}
Thanks! That worked! but how would i to make it all one command? just like

/modshopgate

and thats the only command needed
Reply
#8

Make variable that will be 0 on gamemode init. First time player types /modshopgate set variable to 1, then when he types it again use if([variable] == 1) and then post closing function and so on.

Also the problem in first thing with 2 commands is that you have 10 as others said so it is matching only first 10 characters which are totally same for both of your commands and when it is scrolling those commands it will first find open so it doesnt even check closing gate command.
Reply
#9

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
Make variable that will be 0 on gamemode init. First time player types /modshopgate set variable to 1, then when he types it again use if([variable] == 1) and then post closing function and so on.

Also the problem in first thing with 2 commands is that you have 10 as others said so it is matching only first 10 characters which are totally same for both of your commands and when it is scrolling those commands it will first find open so it doesnt even check closing gate command.
Okay, i somewhat under stand the varibles, but just getting it started as what i do not know, because this is my first time doing Varibles.

Second, so what should what i do with the 2 10's?
Reply
#10

This is what i got so far.

Код:
  	if(strcmp("/Modshopgate", cmdtext, true) == 0)
	{
    	if(garage_status == 1)
    	{
    		MoveObject(garage, 1694.30664062,758.06933594,15.19236946, 2.0);
    		GameTextForPlayer(playerid, "Garage ~r~opening", 5000, 6);
    		PlayerPlaySound(playerid,1057,0,0,0);
    		garage_status = 0;
   		}
   		else if(garage_status == 0)
				{
     				MoveObject(garage, 1694.30664062,758.06933594,11.65923691,  2.0);
					GameTextForPlayer(playerid, "Garage ~r~closing", 5000, 6);
					PlayerPlaySound(playerid,1057,0,0,0);
					garage_status = 1;
				}
			}
		return 1;
	}
But it crashes Pawno. I think its indenting. Whats wrong?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)