SA-MP Forums Archive
Command issue - 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: Command issue (/showthread.php?tid=98955)



Command issue - Shinzei_Banzai - 24.09.2009

Well.. I have abseloutely no idea what went wrong.. I just entered a simple /enter cmd, yet it doesn't work.. Also I can't find the problem with line 385(/mdelevator). There is a loose indentation, can't find it.. But here it is:
pawn Код:
}
if (strcmp("/mdelevator", cmdtext, true, 10) == 0)
    {
    if (PlayerToPoint(26, playerid,1148.358032,-1315.570678,24.000000))
    if(MDElevatorstatus)
    {
        MoveObject(MDElevator, 1148.358032,-1315.570678,31.79 , 2);
        MDElevatorstatus = 0;
    }
    else
    {
        MoveObject(MDElevator, 1148.358032,-1315.570678,14 , 2);
        MDElevatorstatus = 1;
    }
    return 1;
}

if (strcmp("/enter", cmdtext, true, 10) == 0)
{
        if (PlayerToPoint(3.0,playerid,1173.0345,-1323.7742,15.3973))
        {
            SetPlayerPos(playerid,1174.5543,-1310.0366,-4.9240);
           
     }
      return 1;
 }
}
return 0;
}
And line 385 is the /mdelevator cmd:
pawn Код:
C:\Users\Bastian\Documents\Samp_server\gamemodes\FD_Station.pwn(385) : warning 217: loose indentation



Re: Command issue - MB@ - 24.09.2009

Try this

Код:
}
if (strcmp("/mdelevator", cmdtext, true, 10) == 0)
{
if (PlayerToPoint(26, playerid,1148.358032,-1315.570678,24.000000))
if(MDElevatorstatus)
{
MoveObject(MDElevator, 1148.358032,-1315.570678,31.79 , 2);
MDElevatorstatus = 0;
}
else
{
MoveObject(MDElevator, 1148.358032,-1315.570678,14 , 2);
MDElevatorstatus = 1;
}
return 1;
}

if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if (PlayerToPoint(3.0,playerid,1173.0345,-1323.7742,15.3973))
{
SetPlayerPos(playerid,1174.5543,-1310.0366,-4.9240);

}
return 1;
}
}
return 0;
}



Re: Command issue - Shinzei_Banzai - 24.09.2009

Didn't change anything.
Here are all my cmds, if that'd help you find the issue:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/fdhangar", cmdtext, true, 10) == 0)
   
  {
   
    if (PlayerToPoint(20, playerid, 1701.0929,-1507.6711,13.3828))
    if(FDGate1status)
    {
       MoveObject(FDGate1, 1700.859375 , -1507.785156 , 14.566914, 1);
       FDGate1status = 0;
    }
    else
    {
      MoveObject(FDGate1, 1700.859375 , -1507.785156 , 8.566914, 1);
      FDGate1status = 1;
    }
    return 1;

 }
if (strcmp("/fdmaingate", cmdtext, true, 10) == 0)

  {
    if (PlayerToPoint(15, playerid, 1679.9694,-1479.9602,13.3828))
    if(FDMaingatestatus)
    {
       MoveObject(FDMaingate, 1680.0 , -1479.0 , 14.0, 1);
       FDMaingatestatus = 0;
    }
    else
    {
      MoveObject(FDMaingate, 1680.0 , -1471.0 , 14.0, 1);
      FDMaingatestatus = 1;
    }
    return 1;
 }
if (strcmp("/fdelevator", cmdtext, true, 10) == 0)

{
    if (PlayerToPoint(20, playerid,1709.761596 , -1465.448852 , 16))
    if(FDElevatorstatus)
    {
       MoveObject(FDElevator, 1709.761596 , -1465.448852 , 33.256496 , 2);
       FDElevatorstatus = 0;
    }
    else
    {
      MoveObject(FDElevator, 1709.761596 , -1465.448852 , 13.812069 , 2);
      FDElevatorstatus = 1;
        }
   
        return 1;
 }

if (strcmp("/mdmaingate", cmdtext, true, 10) == 0)
{
    if (PlayerToPoint(20, playerid,1142.2526,-1289.9144,13.5873))
    if(MDGate1status)

    {
       MoveObject(MDGate1, 1138.368408 , -1290.706909 , 14 , 2);
       MDGate1status = 0;

    }
    else
    {
      MoveObject(MDGate1, 1146.368408 , -1290.706909 , 14 , 2);
      MDGate1status = 1;
            return 1;
 }
if (strcmp("/mdelevator", cmdtext, true, 10) == 0)
    {
    if (PlayerToPoint(26, playerid,1148.358032,-1315.570678,24.000000))
    if(MDElevatorstatus)
    {
        MoveObject(MDElevator, 1148.358032,-1315.570678,31.79 , 2);
        MDElevatorstatus = 0;
    }
    else
    {
        MoveObject(MDElevator, 1148.358032,-1315.570678,14 , 2);
        MDElevatorstatus = 1;
    }
    return 1;
}

if (strcmp("/enter", cmdtext, true, 10) == 0)
{
        if (PlayerToPoint(3.0,playerid,1173.0345,-1323.7742,15.3973))
        {
            SetPlayerPos(playerid,1174.5543,-1310.0366,-4.9240);

        }
      return 1;
}
}
return 0;
}



Re: Command issue - DracoBlue - 24.09.2009

Fix your indention style then. Code in the same block should not change indention, thats what the warning tells you.

Try http://dracoblue.net/tidy/pawn/ to properly format this part of your code.

- Draco


Re: Command issue - Peter_Corneile - 24.09.2009

Its just a matter of wrong identation


Re: Command issue - Shinzei_Banzai - 24.09.2009

Quote:
Originally Posted by Peter Corneile [hugu-hosting.co.uk
]
Its just a matter of wrong identation
Well. What about the /enter code. It's disabled somehow..?


Re: Command issue - DracoBlue - 24.09.2009

Quote:
Originally Posted by Shinzei_Banzai
Well. What about the /enter code. It's disabled somehow..?
This: if (strcmp("/enter", cmdtext, true, 10) == 0)
Tests the first 10 characters, for /enter. What will not work.

In general this: if (strcmp("/enter", cmdtext, true) == 0)
will do the trick.

But consider to create your commands with a proper solution like dcmd or the new zcmd.

- Draco


Re: Command issue - Sznupek - 24.09.2009

Very chaotic code

Warning 207 is important, if you want to have legible code
But it doesn't affect correct working of the script (like every warning though)

You can fix indentations or use

pawn Код:
#pragma tabsize 0
...somewhere below your includes, but I don't recommend it


Re: Command issue - Peter_Corneile - 24.09.2009

Quote:
Originally Posted by Sznupek
Very chaotic code

Warning 207 is important, if you want to have legible code
But it doesn't affect correct working of the script (like every warning though)

You can fix indentations or use

pawn Код:
#pragma tabsize 0
...somewhere below your includes, but I don't recommend it
It can be used to solve the warning but its not a very innovative step ...


Re: Command issue - Sznupek - 24.09.2009

Quote:
Originally Posted by Peter Corneile [hugu-hosting.co.uk
It can be used to solve the warning but its not a very innovative step ...
Yes, and it's why I don't recommend it
I prefer making clear and solid code to fixing it with these forced solutions