Error compile
#1

So I wanted to create the command [/ff], that teleports your character 20 meters in front of him. But when I compile it gives me 3 warnings and the command works in-game.

This is the command,
Код:
CMD:ff(playerid, params[])
{
	if(IsPlayerConnected(playerid))
	{
		if(PlayerInfo[playerid][pAdmin] >= 1)
		{
			new Float:px, Float:py, Float:pz, Float:pa;
                    GetPlayerFacingAngle(playerid, pa);
                    if(pa >= 0.0 && pa <= 22.5) //
				{
					GetPlayerPos(playerid, px, py, pz);
					SetPlayerPos(playerid, px, py+20, pz);
				}
				if(pa >= 332.5 && pa < 0.0) //n2
				{
					GetPlayerPos(playerid, px, py, pz);
					SetPlayerPos(playerid, px, py+20, pz);
				}
				if(pa >= 22.5 && pa <= 67.5) //nw
				{
					GetPlayerPos(playerid, px, py, pz);
					SetPlayerPos(playerid, px-10, py+10, pz);
				}
				if(pa >= 67.5 && pa <= 112.5) //w
				{
					GetPlayerPos(playerid, px, py, pz);
					SetPlayerPos(playerid, px-20, py, pz);
				}
				if(pa >= 112.5 && pa <= 157.5) //sw
				{
					GetPlayerPos(playerid, px, py, pz);
					SetPlayerPos(playerid, px-10, py-10, pz);
				}
				if(pa >= 157.5 && pa <= 202.5) //s
				{
					GetPlayerPos(playerid, px, py, pz);
					SetPlayerPos(playerid, px, py-20, pz);
				}
				if(pa >= 202.5 && pa <= 247.5)//se
				{
					GetPlayerPos(playerid, px, py, pz);
					SetPlayerPos(playerid, px+10, py-10, pz);
				}
				if(pa >= 247.5 && pa <= 292.5)//e
				{
					GetPlayerPos(playerid, px, py, pz);
					SetPlayerPos(playerid, px+20, py, pz);
				}
				if(pa >= 292.5 && pa <= 332.5)//e
				{
					GetPlayerPos(playerid, px, py, pz);
					SetPlayerPos(playerid, px+10, py+10, pz);
				}
			return 1;
		}
	}
	return 1;
}
And this is the screenshot with the errors:http://imgur.com/a/7tfQF
Reply
#2

Loose indentation means that you aren't tabulating/indenting your code at a certain/appropriate level. Also, they are warnings, not errors. You can run your script with warnings, but it's always advised to fix them, and not just avoid/ignore them.

pawn Код:
CMD:ff(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][pAdmin] >= 1)
        {
            new Float:px, Float:py, Float:pz, Float:pa;
            GetPlayerFacingAngle(playerid, pa);

            if(pa >= 0.0 && pa <= 22.5) //
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px, py+20, pz);
            }
            else if(pa >= 332.5 && pa < 0.0) //n2
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px, py+20, pz);
            }
            else if(pa >= 22.5 && pa <= 67.5) //nw
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px-10, py+10, pz);
            }
            else if(pa >= 67.5 && pa <= 112.5) //w
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px-20, py, pz);
            }
            else if(pa >= 112.5 && pa <= 157.5) //sw
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px-10, py-10, pz);
            }
            else if(pa >= 157.5 && pa <= 202.5) //s
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px, py-20, pz);
            }
            else if(pa >= 202.5 && pa <= 247.5)//se
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px+10, py-10, pz);
            }
            else if(pa >= 247.5 && pa <= 292.5)//e
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px+20, py, pz);
            }
            else if(pa >= 292.5 && pa <= 332.5)//e
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px+10, py+10, pz);
            }
        }
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Loose indentation means that you aren't tabulating/indenting your code at a certain/appropriate level. Also, they are warnings, not errors. You can run your script with warnings, but it's always advised to fix them, and not just avoid/ignore them.

pawn Код:
CMD:ff(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][pAdmin] >= 1)
        {
            new Float:px, Float:py, Float:pz, Float:pa;
            GetPlayerFacingAngle(playerid, pa);

            if(pa >= 0.0 && pa <= 22.5) //
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px, py+20, pz);
            }
            else if(pa >= 332.5 && pa < 0.0) //n2
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px, py+20, pz);
            }
            else if(pa >= 22.5 && pa <= 67.5) //nw
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px-10, py+10, pz);
            }
            else if(pa >= 67.5 && pa <= 112.5) //w
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px-20, py, pz);
            }
            else if(pa >= 112.5 && pa <= 157.5) //sw
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px-10, py-10, pz);
            }
            else if(pa >= 157.5 && pa <= 202.5) //s
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px, py-20, pz);
            }
            else if(pa >= 202.5 && pa <= 247.5)//se
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px+10, py-10, pz);
            }
            else if(pa >= 247.5 && pa <= 292.5)//e
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px+20, py, pz);
            }
            else if(pa >= 292.5 && pa <= 332.5)//e
            {
                GetPlayerPos(playerid, px, py, pz);
                SetPlayerPos(playerid, px+10, py+10, pz);
            }
        }
    }
    return 1;
}
Thanks.
Reply
#4

PHP код:
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:yFloat:distance)
{
    new 
Float:a;
    
GetPlayerPos(playeridxya);
    
GetPlayerFacingAngle(playerida);
    if (
GetPlayerVehicleID(playerid)) {
        
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }
    
+= (distance floatsin(-adegrees));
    
+= (distance floatcos(-adegrees));

PHP код:
CMD:ff(playeridparams[])
{
    if(
IsPlayerConnected(playerid))
    {
        if(
PlayerInfo[playerid][pAdmin] >= 1)
        {
            new 
Float:pxFloat:pyFloat:pz;
            
GetPlayerPos(playeridpxpypz); // Or you could use SetPlayerPosFindZ if you prefer not to use a z coordinate.
            
GetXYInFrontOfPlayer(playeridpxpy20.0);
            
SetPlayerPos(playeridpxpypz);
        }
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)