Problem on server restart
#1

Alright, so I'm scripting my own server from scratch, and I've gotten pretty far in so far. However, I've come across a problem where if I shut down the server, then restart it - and the user hasn't restarted their client, then they login and spawn with the CJ skin automatically. I was wondering if there'd be any way to stop this kind of bug through scripting?

I've narrowed down the problem a bit. When the person logs in, SpawnPlayer is called on them, however, this doesn't launch the OnPlayerSpawn callback. What's up with that?

In addition to this, when I manually call my extension to the SpawnPlayer function (SpawnPlayerEx) - which usually sets their skin - their skin is not set, instead it remains CJ.
Reply
#2

Check your SetPlayerSkin under the OnPlayerSpawn callback, and make sure the skin isn't set to PedSkin.
Reply
#3

Quote:
Originally Posted by =WoR=G4M3Ov3r
Посмотреть сообщение
Check your SetPlayerSkin under the OnPlayerSpawn callback, and make sure the skin isn't set to PedSkin.
What do you mean by this?

pawn Код:
SetPlayerSkin(playerid, 299);
Is what's in the callback. As I updated in my OP, the OnPlayerSpawn isn't even being called when the user is spawned, instead after spawning them, I have to enforce my own spawning functions on to them without the usage of the callback. And even then, the skin doesn't change properly.
Reply
#4

Quote:
Originally Posted by TaMeD
Посмотреть сообщение
What do you mean by this?
Open your script, press Cntrl + F search for the public OnPlayerSpawn, then scroll and find SetPlayerSkin

make sure, the skinid is not set to 0.

PHP код:
SetPlayerSkin(playerid0); // Change the 0. 
Reply
#5

Quote:
Originally Posted by TaMeD
Посмотреть сообщение
pawn Код:
SetPlayerSkin(playerid, 299);
Is what's in the callback. As I updated in my OP, the OnPlayerSpawn isn't even being called when the user is spawned, instead after spawning them, I have to enforce my own spawning functions on to them without the usage of the callback. And even then, the skin doesn't change properly.
Updated my post above to this ^
Reply
#6

Quote:
Originally Posted by TaMeD
Посмотреть сообщение
Updated my post above to this ^
Ye, change the 299 to any skin you want the players to spawn in

https://sampwiki.blast.hk/wiki/Skins:All
Reply
#7

299 Is the skin I want them to spawn in. The problem is, it's not changing them to that skin even though I explicitly SetPlayerSkin. For some reason, the player has to be killed before their skin will set.
Reply
#8

Show me your OnPlayerDisconnect and OnPlayerSpawn callbacks codes.
Reply
#9

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(LoggedIn[playerid] == 1) SavePlayerAccount(playerid);
    ResetPlayerVariables(playerid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SpawnPlayerEx(playerid);
    return 1;
}
stock SpawnPlayerEx(playerid)
{
    Spawned[playerid] = 1;
    if(FirstLogin[playerid] && !FirstRegister[playerid]) //Means that the person already has an account, and has is spawning for the first time for this session.
    {
        SetPlayerPos(playerid, Player[playerid][pPosX], Player[playerid][pPosY], Player[playerid][pPosZ]+1.5);
        TogglePlayerControllable(playerid, 0);
        delay:DelayThawPlayer[2500](playerid);
        SetPlayerFacingAngle(playerid, Player[playerid][pAngle]);
        SetCameraBehindPlayer(playerid);
        FirstLogin[playerid] = 0;
        LoggedIn[playerid] = 1;
        //dbug("Your first spawn");
    }
    SetPlayerHealth(playerid, 100.0);
    SetCameraBehindPlayer(playerid);
    //Debug messages
    format(string,sizeof(string), "Setting skin to %d",Player[playerid][pSkin]);
    dbug(string);
    SetPlayerSkin(playerid, 299);
    format(string,sizeof(string), "Your skin is currently %d", GetPlayerSkin(playerid));
    dbug(string);
    return 1;
}

ResetPlayerVariables is just a stock that does exactly what it should.

I want to make it very clear. I have no problems when people rejoin the server. No problems when I start the server, and people join.

ONLY when the server is restarted, and the client leaves GTA open and it reconnects without restarting their GTA.
Reply
#10

Bump! Help, pleasee?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)