TogglePlayerSpectating causing problems
#1

pawn Код:
public  OnPlayerConnect( playerid ) {

    if( fexist( find_accPath( playerid ) ) ) { //They are returning users - Account already exists!
        INI_ParseFile(find_accPath(playerid), "LoadAccount_%s", .bExtra = true, .extra = playerid);
        LOGDIALOG;
    }
    else { //They are new users - Account does not exist!
        REGDIALOG;
    }
   
    SetPlayerTime(playerid, 0, 0);
   
    JoinVehicle[ playerid ] = CreateVehicle ( 411, 92.7663, -164.9878, 2.5938, 269.3596, 3, 3, 360000 );
    SetVehicleVirtualWorld( JoinVehicle[ playerid ], playerid+1 );
    SetPlayerVirtualWorld( playerid, playerid+1 );
    PutPlayerInVehicle( playerid, JoinVehicle[ playerid ], 0 );
    TogglePlayerControllable( playerid, 0 );
    TogglePlayerSpectating( playerid, 1 );
   
    SetPlayerCameraPos( playerid, 100.9195, -164.8617, 2.5182 );
    SetPlayerCameraLookAt( playerid, 92.7663, -164.9878, 2.5938 );
   
    firstSpawn[ playerid ] = true;
    return true;
}

public  OnPlayerSpawn( playerid ) {
    if(firstSpawn[ playerid ] == true ) {
   
        DestroyVehicle( JoinVehicle[ playerid ] );
        TogglePlayerSpectating( playerid, 0 );
        SetPlayerVirtualWorld( playerid, 0 );
        SetCameraBehindPlayer( playerid );
        firstSpawn[ playerid ] = false;
    }
    return true;
}
Before I added TogglePlayerSpectating, this code worked perfectly - what happened to it?
Reply
#2

Quote:
Originally Posted by 2KY
Посмотреть сообщение
Before I added TogglePlayerSpectating, this code worked perfectly - what happened to it?
What happened is that you added TogglePlayerSpectating. Remove it and see if it fixes the problem.
Reply
#3

Well, how does it not work perfectly? Do you mean like the login/register wise? Or camera position wise?
Reply
#4

Quote:
Originally Posted by coole210
Посмотреть сообщение
What happened is that you added TogglePlayerSpectating. Remove it and see if it fixes the problem.
Well, duh..

Quote:
Originally Posted by Walsh
Посмотреть сообщение
Well, how does it not work perfectly? Do you mean like the login/register wise? Or camera position wise?
Camera Position-wise, sorry, I didn't specify. The camera position resets to Blueberry (the normal position near the bridge)
Reply
#5

Quote:
Originally Posted by 2KY
Посмотреть сообщение
Well, duh..



Camera Position-wise, sorry, I didn't specify. The camera position resets to Blueberry (the normal position near the bridge)
It's because the player isn't spawned when you called TogglePlayerSpectating, which would set the camera to the blueberry position.
Reply
#6

Well that's what TogglePlayerSpectating does. You can cycle through the players, and if there are no players then that is the default spectating screen.

So, TogglePlayerSpectating will always set the camera position to that blueberry screen.
Reply
#7

Quote:
Originally Posted by coole210
Посмотреть сообщение
It's because the player isn't spawned when you called TogglePlayerSpectating, which would set the camera to the blueberry position.
Is there a way to set them to spectate AND set the camera position?
Reply
#8

Quote:
Originally Posted by 2KY
Посмотреть сообщение
Is there a way to set them to spectate AND set the camera position?
Don't think so since all spectating uses is SetCameraPos/SetPlayerPos. etc.
Reply
#9

Alright, well, I've run into another problem. This only works directly after GMX. After the GMX is finished (E.G: a player disconnects then connects, or even is JUST connecting) none of the other code is executed. The time doesn't get set, nothing like that happens, BUT the textdraws so show up, and the dialog is displayed. This is confusing the hell out of me.

pawn Код:
public  OnPlayerConnect( playerid ) {

    if( fexist( find_accPath( playerid ) ) ) { //They are returning users - Account already exists!
        INI_ParseFile(find_accPath(playerid), "LoadAccount_%s", .bExtra = true, .extra = playerid);
        LOGDIALOG;
    }
    else { //They are new users - Account does not exist!
        REGDIALOG;
    }
   
    SetPlayerTime(playerid, 0, 0);
   
    JoinVehicle[ playerid ] = CreateVehicle ( 411, 92.7663, -164.9878, 2.5938, 269.3596, 3, 3, -1 );
    SetVehicleVirtualWorld( JoinVehicle[ playerid ], playerid+1 );
    SetPlayerVirtualWorld( playerid, playerid+1 );
    PutPlayerInVehicle( playerid, JoinVehicle[ playerid ], 0 );
    TogglePlayerControllable( playerid, 0 );
    //TogglePlayerSpectating( playerid, 1 );
   
    SetPlayerCameraPos( playerid, 100.9195, -164.8617, 3.5182 );
    SetPlayerCameraLookAt( playerid, 92.7663, -164.9878, 2.5938 );
   
    TextDrawShowForPlayer( playerid, MissionTitle );
    TextDrawShowForPlayer( playerid, RevisionNumber );
   
    firstSpawn[ playerid ] = true;
    return true;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerCameraPos( playerid, 100.9195, -164.8617, 3.5182 );
    SetPlayerCameraLookAt( playerid, 92.7663, -164.9878, 2.5938 );
    SetPlayerTime(playerid, 0, 0);
    return true;
}
Reply
#10

This may not have anything to do with this ,but do you have anything under
Код:
OnGameModeExit
??

I'm stumped here too. D:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)