Mr Wet Posted June 7, 2015 Share Posted June 7, 2015 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 More sharing options...
Fireboyd78 Posted June 7, 2015 Share Posted June 7, 2015 (edited) 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 June 7, 2015 by Fireboyd78 Link to comment Share on other sites More sharing options...
Mr Wet Posted June 8, 2015 Author Share Posted June 8, 2015 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 More sharing options...
Fireboyd78 Posted June 8, 2015 Share Posted June 8, 2015 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 More sharing options...
Mr Wet Posted June 8, 2015 Author Share Posted June 8, 2015 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 More sharing options...
Mr Wet Posted June 8, 2015 Author Share Posted June 8, 2015 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 More sharing options...
Fireboyd78 Posted June 8, 2015 Share Posted June 8, 2015 Are you using the code I posted? Link to comment Share on other sites More sharing options...
Mr Wet Posted June 8, 2015 Author Share Posted June 8, 2015 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 More sharing options...
Fireboyd78 Posted June 8, 2015 Share Posted June 8, 2015 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 More sharing options...
Mgel Posted June 11, 2015 Share Posted June 11, 2015 (edited) 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 June 11, 2015 by Mgel Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now