Moveobject trouble
#1

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/enter", true, 10)==0)
    {
        if(IsPlayerInRangeOfPoint(playerid,3.0,1552.4473,-1674.9888,16.1953))
        {
            SendClientMessage(playerid,0x00ABFFFF,"Welcome to the LAPD");
            SetPlayerInterior(playerid, 14);
            SetPlayerPos(playerid,1550.9105,-1683.8849,1723.1050);
            return 1;
        }
    }
    if(strcmp(cmdtext, "/exit", true, 10)==0)
    {
        if(IsPlayerInRangeOfPoint(playerid,3.0,1550.9105,-1683.8849,1723.1050))
        {
            SetPlayerPos(playerid,1552.4473,-1674.9888,17);
            return 1;
        }
    }
    if(strcmp(cmdtext, "/Gate", true, 10)==0)
    {
        if(IsPlayerInRangeOfPoint(playerid,10.0,1596.4467,-1637.9670,14.6039))//Garage
        {
            MoveObject(PDgarage,1597.9567,-1637.9670,14.6039,1.5);//Garage
        }
        else
        {
            MoveObject(PDgarage,1589.4362,-1637.9670,14.6039,1.5);//Garageclose
        }
        return 1;
    }
    return 0;
}
The problem is, when i do /gate. it opens. when I want to do /gate again, It doesn't close while it should. Did I forgot something?
Reply
#2

if(strcmp(cmdtext, "/Gate", true, 10)==0)
try to change:
if(strcmp(cmdtext, "/Gate", true, 5)==0)
Reply
#3

You need to create a var, and set it to 1, when you do /gate (to open).

pawn Код:
if(!strcmp(cmdtext, "/gate", true))
{
if(var == 1)
{
//Close Object
}
else if(var == 0)
{
//close object
}
Reply
#4

I have the var: PDgarage=Createobject(myobject, Float:X, Float:Y, Float:Z, Float:Speed);
Can I use that as var, or do I have to create a new var or something.
pawn Код:
public OnPlayerCommandText
}
    if(strcmp(cmdtext, "/Gate", true))
    {
        if(IsPlayerInRangeOfPoint(playerid,10.0,1596.4467,-1637.9670,14.6039))
        {
            if(PDgarage == 1)//Garage
            {
            MoveObject(PDgarage,1597.9567,-1637.9670,14.6039,1.5);//Garage
            }
            else if(PDgarage == 0)
            {
            MoveObject(PDgarage,1589.4362,-1637.9670,14.6039,1.5);//Garageclose
            }
            return 1;
        }
    }
    return 0;
 }
it compiles, but it still doesn't work. Can someone maybe fix it or something?
Reply
#5

Create a new var, 'PDgarage' is already assigned to a object not a value, so you can't use both in 1.

Make a new one like, new gateopenclose = 0;
Reply
#6

It works now, but now i have another thing, the spot where you do /gate, moves wo the position of the opened gate, how to fix that?
Reply
#7

You need put, in the CLOSED gates COORDINATES the gate coordinates
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)