CP Error.
#1

I'm trying to make some casinos from positions from the real game but the second sets doesn't seem to work

Код:
new Casino[4];

public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
	if(checkpointid == Casino[0])
	{
	if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
	{
		SetPlayerVirtualWorld(playerid, 1);
	    SetPlayerInterior(playerid, 10);
	    SetPlayerPos(playerid, 2015.8330,1017.7784,996.8750);
	    SetPlayerFacingAngle(playerid, 90.0000);
	    SetCameraBehindPlayer(playerid);
	    return 1;
        }
    }
    if(checkpointid == Casino[1])
	{
	 if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
	{
		if(GetPlayerVirtualWorld(playerid) == 1)
		{
		SetPlayerVirtualWorld(playerid, 0);
		SetPlayerInterior(playerid, 0);
	    SetPlayerPos(playerid, 2024.6432,1007.8961,10.8203);
	    SetPlayerFacingAngle(playerid, 270.0000);
	    SetCameraBehindPlayer(playerid);
	    return 1;
        }
    }
    if(checkpointid == Casino[2])
	{
	if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
	{
		SetPlayerVirtualWorld(playerid, 2);
		SetPlayerInterior(playerid, 12);
	    SetPlayerPos(playerid, 1133.1400,-10.1003,1000.6797);
	    SetPlayerFacingAngle(playerid, 0.2041);
	    SetCameraBehindPlayer(playerid);
	    return 1;
        }
    }
    if(checkpointid == Casino[3])
	{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
	{
		if(GetPlayerVirtualWorld(playerid) == 2)
		{
		SetPlayerVirtualWorld(playerid, 0);
		SetPlayerInterior(playerid, 0);
	    SetPlayerPos(playerid, 2017.5106,1103.2477,10.8203);
	    SetPlayerFacingAngle(playerid, 234.0048);
	    SetCameraBehindPlayer(playerid);
	    return 1;
        }
    }
    }
    }
    return 1;
}
could someone tell me why it isn't working.
Reply
#2

I indented your code and the mistake should be obvious:
PHP код:
new Casino[4];

public 
OnPlayerEnterDynamicCP(playeridcheckpointid)
{
    if(
checkpointid == Casino[0])
    {
        if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            
SetPlayerVirtualWorld(playerid1);
            
SetPlayerInterior(playerid10);
            
SetPlayerPos(playerid2015.8330,1017.7784,996.8750);
            
SetPlayerFacingAngle(playerid90.0000);
            
SetCameraBehindPlayer(playerid);
            return 
1;
        }
    }
    if(
checkpointid == Casino[1])
    {
        if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            if(
GetPlayerVirtualWorld(playerid) == 1)
            {
                
SetPlayerVirtualWorld(playerid0);
                
SetPlayerInterior(playerid0);
                
SetPlayerPos(playerid2024.6432,1007.8961,10.8203);
                
SetPlayerFacingAngle(playerid270.0000);
                
SetCameraBehindPlayer(playerid);
                return 
1;
            }
        }
        if(
checkpointid == Casino[2])
        {
            if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
            {
                
SetPlayerVirtualWorld(playerid2);
                
SetPlayerInterior(playerid12);
                
SetPlayerPos(playerid1133.1400,-10.1003,1000.6797);
                
SetPlayerFacingAngle(playerid0.2041);
                
SetCameraBehindPlayer(playerid);
                return 
1;
            }
        }
        if(
checkpointid == Casino[3])
        {
            if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
            {
                if(
GetPlayerVirtualWorld(playerid) == 2)
                {
                    
SetPlayerVirtualWorld(playerid0);
                    
SetPlayerInterior(playerid0);
                    
SetPlayerPos(playerid2017.5106,1103.2477,10.8203);
                    
SetPlayerFacingAngle(playerid234.0048);
                    
SetCameraBehindPlayer(playerid);
                    return 
1;
                }
            }
        }
    }
    return 
1;

Reply
#3

Could you explain what the problem was? +Rep Though.
Reply
#4

Every if-statement from if(checkpointid == Casino[2]) on is within the body of if(checkpointid == Casino[1]). While that's syntactically correct, it's probably not what you wanted.
Reply
#5

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
Every if-statement from if(checkpointid == Casino[2]) on is within the body of if(checkpointid == Casino[1]). While that's syntactically correct, it's probably not what you wanted.
Thanks,you got your rep though but could you please use [code] tags and color what you did i must be blind.
Reply
#6

He didn't change anything to the code, he only indented the code properly so you can observe where the mistake is.

I'll color it for you though (I didn't change anything as well):
Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == Casino[0])
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            SetPlayerVirtualWorld(playerid, 1);
            SetPlayerInterior(playerid, 10);
            SetPlayerPos(playerid, 2015.8330,1017.7784,996.8750);
            SetPlayerFacingAngle(playerid, 90.0000);
            SetCameraBehindPlayer(playerid);
            return 1;
        }
    }
    if(checkpointid == Casino[1])
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            if(GetPlayerVirtualWorld(playerid) == 1)
            {
                SetPlayerVirtualWorld(playerid, 0);
                SetPlayerInterior(playerid, 0);
                SetPlayerPos(playerid, 2024.6432,1007.8961,10.8203);
                SetPlayerFacingAngle(playerid, 270.0000);
                SetCameraBehindPlayer(playerid);
                return 1;
            }
        }
        if(checkpointid == Casino[2])
        {
            if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
            {
                SetPlayerVirtualWorld(playerid, 2);
                SetPlayerInterior(playerid, 12);
                SetPlayerPos(playerid, 1133.1400,-10.1003,1000.6797);
                SetPlayerFacingAngle(playerid, 0.2041);
                SetCameraBehindPlayer(playerid);
                return 1;
            }
        }
        if(checkpointid == Casino[3])
        {
            if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
            {
                if(GetPlayerVirtualWorld(playerid) == 2)
                {
                    SetPlayerVirtualWorld(playerid, 0);
                    SetPlayerInterior(playerid, 0);
                    SetPlayerPos(playerid, 2017.5106,1103.2477,10.8203);
                    SetPlayerFacingAngle(playerid, 234.0048);
                    SetCameraBehindPlayer(playerid);
                    return 1;
                }
            }
        }
    }
    return 1;
}
Basically the last two will be called if it is the casino 1 so you have forgotten a closed bracket before (plus an extra closed bracket at the end).
Reply
#7

I marked the if(checkpointid == Casino[1]) block in red:

Your code:
Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == Casino[0])
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            SetPlayerVirtualWorld(playerid, 1);
            SetPlayerInterior(playerid, 10);
            SetPlayerPos(playerid, 2015.8330,1017.7784,996.8750);
            SetPlayerFacingAngle(playerid, 90.0000);
            SetCameraBehindPlayer(playerid);
            return 1;
        }
    }
    if(checkpointid == Casino[1])
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            if(GetPlayerVirtualWorld(playerid) == 1)
            {
                SetPlayerVirtualWorld(playerid, 0);
                SetPlayerInterior(playerid, 0);
                SetPlayerPos(playerid, 2024.6432,1007.8961,10.8203);
                SetPlayerFacingAngle(playerid, 270.0000);
                SetCameraBehindPlayer(playerid);
                return 1;
            }
        }
        if(checkpointid == Casino[2])
        {
            if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
            {
                SetPlayerVirtualWorld(playerid, 2);
                SetPlayerInterior(playerid, 12);
                SetPlayerPos(playerid, 1133.1400,-10.1003,1000.6797);
                SetPlayerFacingAngle(playerid, 0.2041);
                SetCameraBehindPlayer(playerid);
                return 1;
            }
        }
        if(checkpointid == Casino[3])
        {
            if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
            {
                if(GetPlayerVirtualWorld(playerid) == 2)
                {
                    SetPlayerVirtualWorld(playerid, 0);
                    SetPlayerInterior(playerid, 0);
                    SetPlayerPos(playerid, 2017.5106,1103.2477,10.8203);
                    SetPlayerFacingAngle(playerid, 234.0048);
                    SetCameraBehindPlayer(playerid);
                    return 1;
                }
            }
        }
    }
    return 1;
}
What I assume you wanted:
Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == Casino[0])
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            SetPlayerVirtualWorld(playerid, 1);
            SetPlayerInterior(playerid, 10);
            SetPlayerPos(playerid, 2015.8330,1017.7784,996.8750);
            SetPlayerFacingAngle(playerid, 90.0000);
            SetCameraBehindPlayer(playerid);
            return 1;
        }
    }
    if(checkpointid == Casino[1])
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            if(GetPlayerVirtualWorld(playerid) == 1)
            {
                SetPlayerVirtualWorld(playerid, 0);
                SetPlayerInterior(playerid, 0);
                SetPlayerPos(playerid, 2024.6432,1007.8961,10.8203);
                SetPlayerFacingAngle(playerid, 270.0000);
                SetCameraBehindPlayer(playerid);
                return 1;
            }
        }
    }
    if(checkpointid == Casino[2])
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            SetPlayerVirtualWorld(playerid, 2);
            SetPlayerInterior(playerid, 12);
            SetPlayerPos(playerid, 1133.1400,-10.1003,1000.6797);
            SetPlayerFacingAngle(playerid, 0.2041);
            SetCameraBehindPlayer(playerid);
            return 1;
        }
    }
    if(checkpointid == Casino[3])
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            if(GetPlayerVirtualWorld(playerid) == 2)
            {
                SetPlayerVirtualWorld(playerid, 0);
                SetPlayerInterior(playerid, 0);
                SetPlayerPos(playerid, 2017.5106,1103.2477,10.8203);
                SetPlayerFacingAngle(playerid, 234.0048);
                SetCameraBehindPlayer(playerid);
                return 1;
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)