Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Scripthook dot net Changing Player Model on Death


Mr Wet
 Share

Recommended Posts

well i am trying to change the players model when the game detects they have died. so far i have this but dont seem to work.

 void Check_Model()    {     Player player = Game.Player;     if (Game.Player.Character.IsDead && Game.Player.Character.Exists())         Function.Call<bool>(Hash.IS_PLAYER_BEING_ARRESTED, Game.Player.Handle, true);        {            if (Game.Player.Character.Model != PedHash.Michael &&                Game.Player.Character.Model != PedHash.Trevor &&                Game.Player.Character.Model != PedHash.Franklin)            {                UI.Notify("Turning to normal");                Wait(1000);               var model = new Model(GTA.Native.PedHash.Michael);               Function.Call(Hash.REQUEST_MODEL, (model.Hash));               while (!model.IsLoaded)                   Wait(0);               GTA.Native.Function.Call(Hash.SET_PLAYER_MODEL, (model.Hash));               GTA.Native.Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player);               GTA.Native.Function.Call(Hash.SET_MODEL_AS_NO_LONGER_NEEDED, (model.Hash));               while (Function.Call<bool>(Hash.IS_ENTITY_DEAD, (player)))                   Wait(0);            }        }    }

here is some extras to go with it

bool skinchanger_used = false;   void update_stuff()    {        if (skinchanger_used)            Check_Model();    }


 

and then here is where i would be setting my player model on the menu.

 void Animals()    {        var hawk = new Model(GTA.Native.PedHash.ChickenHawk);        hawk.Request(500);               CloseMenus();        update_stuff();        Active_Menu = new GTA.Menu("Animals", new GTA.MenuItem[]{        new GTA.MenuLabel("---Birds---"),        new GTA.MenuButton("Hawk", ()=> {if (hawk.IsInCdImage && hawk.IsValid)        {while (!hawk.IsLoaded) Script.Wait(100);           GTA.Native.Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, hawk.Hash);           GTA.Native.Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, Game.Player);         }hawk.MarkAsNoLongerNeeded();skinchanger_used = true;}),        new GTA.MenuButton("Back", ModelChanger)        });        menu_color();        View.AddMenu(Active_Menu);    }

can someone point me to where i am going wrong please?

Link to comment
Share on other sites

Fireboyd78

You've already asked this question in another thread. You were given a solution (albeit in C++) that can easily be implemented.

 

// player model control, switching on normal ped model when neededvoid check_player_model() {    // common variables    Player player = PLAYER::PLAYER_ID();    Ped playerPed = PLAYER::PLAYER_PED_ID();        if (!ENTITY::DOES_ENTITY_EXIST(playerPed))        return;        Hash model = ENTITY::GET_ENTITY_MODEL(playerPed);        if (ENTITY::IS_ENTITY_DEAD(playerPed) || PLAYER::IS_PLAYER_BEING_ARRESTED(player, TRUE))    {        if (model != GAMEPLAY::GET_HASH_KEY("player_zero") &&        model != GAMEPLAY::GET_HASH_KEY("player_one") &&        model != GAMEPLAY::GET_HASH_KEY("player_two"))        {            set_status_text("turning to normal");            WAIT(1000);                        model = GAMEPLAY::GET_HASH_KEY("player_zero");                        STREAMING::REQUEST_MODEL(model);                        while (!STREAMING::HAS_MODEL_LOADED(model))                WAIT(0);                            PLAYER::SET_PLAYER_MODEL(PLAYER::PLAYER_ID(), model);            PED::SET_PED_DEFAULT_COMPONENT_VARIATION(PLAYER::PLAYER_PED_ID());            STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(model);                        // wait until player is ressurected            while (ENTITY::IS_ENTITY_DEAD(PLAYER::PLAYER_PED_ID()) || PLAYER::IS_PLAYER_BEING_ARRESTED(player, TRUE))            WAIT(0);        }    }}
I don't have Visual Studio on this rig so I've done my best to convert it for you:

 

// player model control, switching on normal ped model when neededvoid CheckPlayerModel() {    // common variables    var player = Game.Player;    var playerPed = player.Character;        if (!playerPed.Exists())        return;        var playerHash = playerPed.Model.Hash;        if (playerPed.IsDead || Function.Call<bool>(Hash.IS_PLAYER_BEING_ARRESTED, player.Handle, true))    {        if (playerHash != PedHash.Michael &&            playerHash != PedHash.Franklin &&            playerHash != PedHash.Trevor)        {            UI.Notify("turning to normal");            Wait(1000);                        var model = new Model(PedHash.Michael);                        model.Request();                        while (!model.IsLoaded)                Wait(0);                        Function.Call(Hash.SET_PLAYER_MODEL, model.Hash);            Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, player);                        model.MarkAsNoLongerNeeded();                        // wait until player is ressurected            while (player.IsDead || Function.Call<bool>(Hash.IS_PLAYER_BEING_ARRESTED, player.Handle, true))                Wait(0);        }    }}
Edited by Fireboyd78
Link to comment
Share on other sites

okay yes. so where would i call check_player_model();?

is it going to be where i set my player model?

Link to comment
Share on other sites

Fireboyd78

okay yes. so where would i call check_player_model();?

 

is it going to be where i set my player model?

 

I imagine it would go inside of the main tick method.

Link to comment
Share on other sites

 

okay yes. so where would i call check_player_model();?

 

is it going to be where i set my player model?

 

I imagine it would go inside of the main tick method.

 

okay dude, ill give it a try thanks

Link to comment
Share on other sites

 

okay yes. so where would i call check_player_model();?

 

is it going to be where i set my player model?

 

I imagine it would go inside of the main tick method.

 

sadly it did not work when added here

 

 

 void OnTick(Object sender, EventArgs e)    {                Player player = Game.Player;        if (player.IsDead && !player.Character.Exists())            CloseMenus();        Check_Model();    }
Link to comment
Share on other sites

Are you using the code I posted?

yeah i had to change a small part as it was giving me a error with

the

var playerHash = playerPed.Model.Hash;

but after i changed it to this

var playerHash = Game.Player.Character.Model;

so it all now looks like so

 

 void Check_Model()    {        // common variables        var player = Game.Player;        var playerPed = player.Character;        if (!playerPed.Exists())            return;        var playerHash = Game.Player.Character.Model;        if (playerPed.IsDead || Function.Call<bool>(Hash.IS_PLAYER_BEING_ARRESTED, player.Handle, true))        {            if (playerHash != PedHash.Michael &&                playerHash != PedHash.Franklin &&                playerHash != PedHash.Trevor)            {                UI.Notify("turning to normal");                Wait(1000);                var model = new Model(PedHash.Michael);                model.Request();                while (!model.IsLoaded)                    Wait(0);                Function.Call(Hash.SET_PLAYER_MODEL, model.Hash);                Function.Call(Hash.SET_PED_DEFAULT_COMPONENT_VARIATION, player);                model.MarkAsNoLongerNeeded();                // wait until player is ressurected                while (player.IsDead || Function.Call<bool>(Hash.IS_PLAYER_BEING_ARRESTED, player.Handle, true))                    Wait(0);            }        }    }
Link to comment
Share on other sites

Fireboyd78

Well man I'm sorry I couldn't help get this resolved for you. The only thing I can suggest is to look at the source code for other trainers and see how they do it.

 

Best of luck to you!

Link to comment
Share on other sites

I would assume that

var playerHash = Game.Player.Character.Model;if (playerHash != PedHash.Michael &&                playerHash != PedHash.Franklin &&                playerHash != PedHash.Trevor)

is what is causing you problems, because PedHash is an integer and your playerHash variable is a Model.

 

I would've tested this before answering, as I'm not entirely sure if you can compare the two.

But I accidentally updated my GTA, so I can't.

Edited by Mgel
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.