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

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

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

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

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
Mr Wet

Scripthook dot net Changing Player Model on Death

Recommended Posts

Mr Wet

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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Mr Wet

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

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Mr Wet

 

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

Share this post


Link to post
Share on other sites
Mr Wet

 

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();    }

Share this post


Link to post
Share on other sites
Fireboyd78

Are you using the code I posted?

Share this post


Link to post
Share on other sites
Mr Wet

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);            }        }    }

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
Mgel

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 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.