SetPlayerSkin will make your players crash anytime randomly even with a valid skin id
#1

Credits: Whitetiger.

You should avoid using SetPlayerSkin anywhere in your code as it was detected to make players crash randomly.

To work around this issue you can do this:
Code:
new bool:IgnoreSpawn[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    IgnoreSpawn[playerid] = false;
    return 1;
}

stock SetPlayerSkinFixed(playerid, skinid)
{
    /*
        // If player is being spectated, force spectators to start spectating again.
        SetTimerEx("ForceRespectate", 1000, false, "i", playerid);
   */
 
    // Store info before re-spawn
    new Float:Pos[4], Float:pHealth[2], CurrWep;
    CurrWep = GetPlayerWeapon(playerid);
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    GetPlayerFacingAngle(playerid, Pos[3]);
    GetPlayerHealth(playerid,pHealth[0]);
    GetPlayerArmour(playerid,pHealth[1]);
   
    // Fixes vehicle bug
    if(IsPlayerInAnyVehicle(playerid))
        SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]+2);
 
    new Weapons[13][2];
    for(new i = 0; i < 13; i++)
        GetPlayerWeaponData(playerid, i, Weapons[i][0], Weapons[i][1]);
 
    // Set spawn info and spawn player
    SetSpawnInfo(playerid, GetPlayerTeam(playerid), skinid, Pos[0], Pos[1], Pos[2]-0.4, Pos[3], 0, 0, 0, 0, 0, 0);
    IgnoreSpawn[playerid] = true;
   
    SpawnPlayer(playerid);
 
    // Set info back after re-spawn
    SetPlayerHealth(playerid, pHealth[0]);
    SetPlayerArmour(playerid, pHealth[1]);
    SetPlayerInterior(playerid, GetPlayerInterior(playerid));
    SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerid));
 
    for(new i = 0; i < 13; i ++)
        GivePlayerWeapon(playerid, Weapons[i][0], Weapons[i][1]);
    SetPlayerArmedWeapon(playerid, CurrWep);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(IgnoreSpawn[playerid])
    {
        IgnoreSpawn[playerid] = false;
        return 1;
    }

    // All of your OnPlayerSpawn code goes here...

    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)