SA-MP Forums

Go Back   SA-MP Forums > SA-MP > Bug Reports

Reply
 
Thread Tools Display Modes
Old 09/01/2017, 02:25 PM   #1
beijind
Little Clucker
 
Join Date: Oct 2016
Posts: 8
Reputation: 15
Exclamation SetPlayerSkin will make your players crash anytime randomly even with a valid skin id

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;
}
beijind is offline   Reply With Quote
Old 09/01/2017, 02:57 PM   #2
Jelly23
Guest
 
Posts: n/a
Default Re: SetPlayerSkin will make your players crash anytime randomly even with a valid skin id

I'm pretty sure it only crashes if you try to set somebody's skin while entering a vehicle, never had any problems with it.
  Reply With Quote
Old 09/01/2017, 03:34 PM   #3
beijind
Little Clucker
 
Join Date: Oct 2016
Posts: 8
Reputation: 15
Default Re: SetPlayerSkin will make your players crash anytime randomly even with a valid skin id

No, when I implemented this, people crash a lot less, it's just a total random crash. You can run around or fly with heli and you will crash. It's not an instant one.

I experianced these crashes myself also and this fix helped for not only my gamemode,but for other scripters also.

Maybe it's more common when SetPlayerSkin is used often in the gamemode.
__________________
Advanced Gang Zones (Draw numbers and borders on the map) (updated beaZone project): http://forum.sa-mp.com/showthread.php?t=618475
beijind is offline   Reply With Quote
Old 09/01/2017, 03:51 PM   #4
beijind
Little Clucker
 
Join Date: Oct 2016
Posts: 8
Reputation: 15
Default Re: SetPlayerSkin will make your players crash anytime randomly even with a valid skin id

When I ******d, I found a topic that I think could also be related to this issue:
https://forum.sa-mp.com/showthread.php?t=96611&page=2
__________________
Advanced Gang Zones (Draw numbers and borders on the map) (updated beaZone project): http://forum.sa-mp.com/showthread.php?t=618475
beijind is offline   Reply With Quote
Old 11/04/2017, 10:53 AM   #5
iSanchez
Huge Clucker
 
Join Date: Nov 2014
Posts: 258
Reputation: 4
Default Respuesta: SetPlayerSkin will make your players crash anytime randomly even with a valid skin id

omg so thats why my players get crashed randomly everytime in my NPC server..
I'll give it a try.


EDIT: I did it!.

Apparently, this really works. Good job whitetiger and thank you beijind for sharing.

Last edited by iSanchez; 14/04/2017 at 05:27 AM.
iSanchez is offline   Reply With Quote
Old 01/05/2017, 12:24 AM   #6
Kar
High-roller
 
Kar's Avatar
 
Join Date: May 2010
Location: Black Asylum
Posts: 3,332
Reputation: 426
Default Re: SetPlayerSkin will make your players crash anytime randomly even with a valid skin id

Only set skin while onfoot (check special actions and states)

You'll be fine.
__________________
Kar is offline   Reply With Quote
Old 03/05/2017, 11:22 PM   #7
ISmokezU
Gangsta
 
Join Date: Aug 2016
Posts: 510
Reputation: 53
Default Re: SetPlayerSkin will make your players crash anytime randomly even with a valid skin id

Quote:
Originally Posted by Kar View Post
Only set skin while onfoot (check special actions and states)

You'll be fine.
True, but Not True at the same time. (Well at least for me).

For one i've never come across this bug but when i set skin while the player is in a vehicle he/she does an Animation with their legs sticking out the vehicle seems a bit unrealistic lol, What i do is, Set them back in their vehicle in their old seat and it works!

Another one i heard people saying is that when they're entering a vehicle and setplayerskin is used the player tends to crash, (Again never happened to me) And i've tried it, But for example a jumped while setskin is used, He'll Freeze immediately after, Solution is just to toggle their controller back to true and it works!
__________________
AFTER ALL
ISmokezU is offline   Reply With Quote
Old 04/05/2017, 01:34 AM   #8
Kar
High-roller
 
Kar's Avatar
 
Join Date: May 2010
Location: Black Asylum
Posts: 3,332
Reputation: 426
Default Re: SetPlayerSkin will make your players crash anytime randomly even with a valid skin id

So how is what I said is not true for you? lol
__________________
Kar is offline   Reply With Quote
Old 04/05/2017, 08:56 PM   #9
ISmokezU
Gangsta
 
Join Date: Aug 2016
Posts: 510
Reputation: 53
Default Re: SetPlayerSkin will make your players crash anytime randomly even with a valid skin id

Well, You said only set it while On - foot, So i'm saying it could be set elsewhere without crashes. (At least for me).
__________________
AFTER ALL
ISmokezU is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Randomly select players? MythicalMarauder Scripting Help 1 29/06/2014 08:26 PM
Players disconnect randomly. SparkyTheGamer Server Support 4 15/06/2014 04:19 PM
Server crash randomly players [DFE]Ike Bug Reports 11 01/04/2013 04:13 PM
unknown crash address? 0x0075803C ... randomly crashing players Kar Client Support 13 22/08/2012 10:32 AM
How to make Skin random? New players loganout Scripting Help 2 14/09/2011 06:52 PM


All times are GMT. The time now is 06:02 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.