Problem with spawning
#1

Well, I got a wierd problem with my player spawning.
When I spawn at first, soon as I log into the server, it spawns me by my skin, and in my current position.
Right after I die, it sets my skin to 0 and spawns me at the same place I died, witch it should not do!
If I die again, it pops up a message of "stay within the world bounds", and crashes my game.
This is my OnPlayerSpawn public:
Код:
public OnPlayerSpawn(playerid)
{
    if(GetPVarInt(playerid, "Newbie") == 1)
	{
		GivePlayerCash(playerid, 5000);
	 	SetPlayerScore(playerid, 1);
	 	SetPlayerSkin(playerid, random(299));
	 	SetPlayerPos(playerid, -2706.5261, 397.7129, 4.3672);
		DeletePVar(playerid, "Newbie");
	}
	else if(GetPVarInt(playerid, "JustLogged") == 1)
	{
	    GivePlayerCash(playerid, pStats[playerid][pMoney]);
	    SetPlayerScore(playerid, pStats[playerid][pScore]);
	    SetPlayerSkin(playerid, pStats[playerid][pSkin]);
	    SetPlayerPos(playerid, pStats[playerid][pPosX], pStats[playerid][pPosY], pStats[playerid][pPosZ]+3);
		DeletePVar(playerid, "JustLogged");
	}
	else if(GetPVarInt(playerid, "JustDied") == 1)
	{
	 	SetPlayerPos(playerid, -2706.5261, 397.7129, 4.3672);
	 	SetPlayerSkin(playerid, pStats[playerid][pSkin]);
	 	DeletePVar(playerid, "JustDied");
	}
	return 1;
}
OnPlayerDeath:
Код:
SendDeathMessage(killerid, playerid, reason);
    
	SetPVarInt(playerid, "JustDied", 1);
	pStats[playerid][pSkin] = GetPlayerSkin(playerid);
	pStats[playerid][pDeaths] += 1;
	pStats[killerid][pKills] += 1;
OnPlayerConnect:
Код:
public OnPlayerConnect(playerid)
{
	new string[128];
	format(string, sizeof(string), "* %s(%d) has joined the server.", GetName(playerid), playerid);
	SendClientMessageToAll(COLOR_GREY, string);
	SetPlayerColor(playerid, COLOR_GREY);

    TogglePlayerSpectating(playerid, true);
	InitPlayerConnection(playerid);
	SetPlayerPos(playerid,-2706.5261, 397.7129, 4.3672);
	return 1;
}
And the right code witch I call when I log in:
Код:
SetPVarInt(playerid, "Authentication", 1);
           			SetPVarInt(playerid, "JustLogged", 1);

					LoadAccountVariables(playerid);
					
					pStats[playerid][pLogins] += 1;

					SetPlayerColor(playerid, COLOR_WHITE);
					
					TogglePlayerSpectating(playerid, 0);

					SetSpawnInfo(playerid, 0, pStats[playerid][pSkin], pStats[playerid][pPosX], pStats[playerid][pPosY], pStats[playerid][pPosZ], 0.0, 0, 0, 0, 0, 0, 0);
					SpawnPlayer(playerid);
Can anybody help me please?
Reply
#2

BUMPP
Reply
#3

Use OnPlayerStateChange when newstate == PLAYER_STATE_SPAWNED instead of OnPlayerSpawn, OnPlayerSpawn is called before the player literally spawns, and thus can't be teleported when the setplayerpos function is used within the callback.

Example:
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate==PLAYER_STATE_SPAWNED)
    {
        if(GetPVarInt(playerid, "Newbie") == 1)
        {
            GivePlayerCash(playerid, 5000);
            SetPlayerScore(playerid, 1);
            SetPlayerSkin(playerid, random(299));
            SetPlayerPos(playerid, -2706.5261, 397.7129, 4.3672);
            DeletePVar(playerid, "Newbie");
        }
        else if(GetPVarInt(playerid, "JustLogged") == 1)
        {
            GivePlayerCash(playerid, pStats[playerid][pMoney]);
            SetPlayerScore(playerid, pStats[playerid][pScore]);
            SetPlayerSkin(playerid, pStats[playerid][pSkin]);
            SetPlayerPos(playerid, pStats[playerid][pPosX], pStats[playerid][pPosY], pStats[playerid][pPosZ]+3);
            DeletePVar(playerid, "JustLogged");
        }
        else if(GetPVarInt(playerid, "JustDied") == 1)
        {
            SetPlayerPos(playerid, -2706.5261, 397.7129, 4.3672);
            SetPlayerSkin(playerid, pStats[playerid][pSkin]);
            DeletePVar(playerid, "JustDied");
        }
    }
    return 1;
}
Reply
#4

Still doesn't work for me! I really don't know how to do, I can't go on if the base is not well-done.
Could somebody please give me the current lines to make sure my players will spawn each time at the same location without getting the "world bondies" screen, and without spawning next to a ciggarate or a whiskey bottle with skin id 0?
Reply
#5

BUMP!! SilentHuntR's suggestion did not help me at all, I still spawn at position 0,0,0 with CJ skin right after I die, and if I die one more time I'm getting the stay whitin would boundies message. I really need that to be fixed, can anyone help?
Reply
#6

BUMP.. sorry for the double but I really need this to be solved.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)