SA-MP Forums Archive
First death after spawn returns to class selection - 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: First death after spawn returns to class selection (/showthread.php?tid=645573)



First death after spawn returns to class selection - sjames - 29.11.2017

Hello.

When players connect to my server, I show them a textdraw and a login dialog (I use TogglePlayerSpectating(playerid, 1) to hide the class selection). Then they log in successfully spawn in LSPD.

BUT, after their first death, they spawn in Grove Street with CJ skin and go to class selection, GIF to show it: https://gyazo.com/e5943a57b69eb5ae5bdafef9e29062fe

And my code:

Код:
public OnPlayerConnect(playerid)
{
	SetSpawnInfo(playerid, NO_TEAM, random(299), defaultSpawn[0], defaultSpawn[1], defaultSpawn[2], defaultSpawn[3], 26, 36, 28, 150, 0, 0 );
	ShowWelcomeTextdraws(playerid);
	SetTimerEx("PreOnPlayerDataCheck", 5000, false, "i", playerid);
	TogglePlayerSpectating(playerid, 1);
    return 1;
}

forward public OnPlayerLogin(playerid);
public OnPlayerLogin(playerid)
{
	pInfo[playerid][LoggedIn] = true;
 	SendClientMessage(playerid, 0x00FF00FF, "Logged in to the account.");
 	showRoomSelection(playerid);
	return 1;
}

// Player logged in, showing another textdraw, then hiding it and turning spec mode off!

stock hideRoomSelection(playerid)
{
	new playerState = GetPlayerState(playerid);
    if(playerState == PLAYER_STATE_SPECTATING)
    {
		TogglePlayerSpectating(playerid,0);
    }

	CancelSelectTextDraw(playerid);
}

// Spec mode now off and player spawns in LSPD like supposed to.

// My other callbacks:

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason);

    if(killerid != INVALID_PLAYER_ID) // Checking if the killer of the player is valid.
    {
        RemovePlayerFromVehicle(playerid);
        pInfo[killerid][pKills]++;
        pInfo[playerid][pDeaths]++;
    }
    return 1;
}
Like I said, the player spawns PERFECTLY in the beginning (in LSPD), this only happens after first death! Die after that I dont return to class selection.
This is same problem from 4 years ago..: https://sampforum.blast.hk/showthread.php?tid=479303


Re: First death after spawn returns to class selection - Overdosed94 - 29.11.2017

Use SetSpawnInfo or SpawnPlayer under OnPlayerRequestClass.


Re: First death after spawn returns to class selection - AjaxM - 30.11.2017

I am experiencing something similar.


Re: First death after spawn returns to class selection - sjames - 30.11.2017

Quote:
Originally Posted by Overdosed94
Посмотреть сообщение
Use SetSpawnInfo or SpawnPlayer under OnPlayerRequestClass.
Sure, that could work, but its not solving the bug, its just covering up the bug by force spawning him.

In my opinion, when I have set the player spawn info correctly, this shouldnt happen? He has once already spawned correctly, but this happens?