SA-MP Forums Archive
TogglePlayerSpectating causing problems - 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)
+--- Thread: TogglePlayerSpectating causing problems (/showthread.php?tid=322154)



TogglePlayerSpectating causing problems - 2KY - 01.03.2012

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?


Re: TogglePlayerSpectating causing problems - coole210 - 01.03.2012

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.


Re: TogglePlayerSpectating causing problems - Walsh - 01.03.2012

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


Re: TogglePlayerSpectating causing problems - 2KY - 01.03.2012

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)


Re: TogglePlayerSpectating causing problems - coole210 - 01.03.2012

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.


Re: TogglePlayerSpectating causing problems - Walsh - 01.03.2012

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.


Re: TogglePlayerSpectating causing problems - 2KY - 01.03.2012

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?


Re: TogglePlayerSpectating causing problems - Walsh - 01.03.2012

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.


Re: TogglePlayerSpectating causing problems - 2KY - 01.03.2012

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;
}



Re: TogglePlayerSpectating causing problems - Walsh - 01.03.2012

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

I'm stumped here too. D: