Problem on server restart -
TaMeD - 08.11.2011
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.
Re: Problem on server restart -
=WoR=G4M3Ov3r - 08.11.2011
Check your SetPlayerSkin under the OnPlayerSpawn callback, and make sure the skin isn't set to PedSkin.
Re: Problem on server restart -
TaMeD - 08.11.2011
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.
Re: Problem on server restart -
=WoR=G4M3Ov3r - 08.11.2011
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(playerid, 0); // Change the 0.
Re: Problem on server restart -
TaMeD - 08.11.2011
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 ^
Re: Problem on server restart -
=WoR=G4M3Ov3r - 08.11.2011
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
Re: Problem on server restart -
TaMeD - 08.11.2011
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.
Re: Problem on server restart -
=WoR=G4M3Ov3r - 08.11.2011
Show me your OnPlayerDisconnect and OnPlayerSpawn callbacks codes.
Re: Problem on server restart -
TaMeD - 08.11.2011
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.
Re: Problem on server restart -
TaMeD - 09.11.2011
Bump! Help, pleasee?