Supacure Posted April 30, 2015 Share Posted April 30, 2015 (edited) Hey, just having some issues with a particular LUA script I'm working with. I never used LUA before and have no idea how to setup the mod environment in C++ because if I did I'd be using that instead however no time right now. That being said here is my problem --[[Crashes on load / reload, only changing the eval to 'not' in the first while loop.]]local supaTools = {}enabled = falsefunction supaTools.tick() while(--[[>>>not<<<]] enabled) do if(get_key_pressed(Keys.F5) and get_key_pressed(Keys.LControlKey)) then enabled = true end local playerPed = PLAYER.PLAYER_PED_ID() local player = PLAYER.GET_PLAYER_PED(playerPed) PLAYER.SET_POLICE_IGNORE_PLAYER(player, false) PLAYER.SET_EVERYONE_IGNORE_PLAYER(player, false) end while(enabled) do if(get_key_pressed(Keys.F5) and get_key_pressed(Keys.LControlKey)) then enabled = false end local playerPed = PLAYER.PLAYER_PED_ID() local player = PLAYER.GET_PLAYER_PED(playerPed) PLAYER.SET_POLICE_IGNORE_PLAYER(player, true) PLAYER.SET_EVERYONE_IGNORE_PLAYER(player, true) end end return supaTools Is anyone able to give me a hand? As I mentioned, first time LUA user and just going from what I can get from the documentation I found online / examples provided. Thanks!Edit: Also if anyone is curious it seems that the SET_POLICE_IGNORE_PLAYER only applies to ground units. Helicopters and wounded officers (last breath) will shoot you regardless. The second one probably applies to red necks and people in impoverished neighborhoods but I have not tested that yet. Any workaround would be awesome. Trying to find a way to make it so aiming at people doesn't scare them as well. Edited April 30, 2015 by Supacure Link to comment Share on other sites More sharing options...
c39687 Posted April 30, 2015 Share Posted April 30, 2015 (edited) If you are new to lua, why not just use c++ (you just have to consider the entire script is in a while true loop so it is a matter of organizing your code differently). if you only use c# then there is hope for you, just be patient... http://ragepluginhook.net/ComingSoon.aspx here is an example of coding a toggle for code you want to only run once in a while true... (you are setting some values in gta repetitively and it is uneccessary although I dont see the harm in it, i would just do it the way below) while (true){ if (EnableKeyPressed()) { enabled = !enabled; if (!enabled) { PoliceAndPedsIgnorePlayer(false);//i made up my own method for simplicity } else { PoliceAndPedsIgnorePlayer(true); } } Wait(0);//so gta can process other scripts when it reaches the end of your loop... MANDATORY} Edited April 30, 2015 by c39687 Link to comment Share on other sites More sharing options...
Supacure Posted May 1, 2015 Author Share Posted May 1, 2015 If you are new to lua, why not just use c++ (you just have to consider the entire script is in a while true loop so it is a matter of organizing your code differently). if you only use c# then there is hope for you, just be patient... http://ragepluginhook.net/ComingSoon.aspx here is an example of coding a toggle for code you want to only run once in a while true... (you are setting some values in gta repetitively and it is uneccessary although I dont see the harm in it, i would just do it the way below) while (true){ if (EnableKeyPressed()) { enabled = !enabled; if (!enabled) { PoliceAndPedsIgnorePlayer(false);//i made up my own method for simplicity } else { PoliceAndPedsIgnorePlayer(true); } } Wait(0);//so gta can process other scripts when it reaches the end of your loop... MANDATORY} I would like to use C++ and would prefer it but I have no idea where to start with setting up the project for asi files. I know a fairly extensive amount about C++ but not much on the side of compilers and environments (I mostly used 2012 / 2010 express which are terribly convoluted). If you could perhaps show me a reference wherein I could learn how to compile and setup files for this I would be very appreciative. I don't need help setting up much more than the basic file structure and project settings. I would much prefer C++ over Lua. Link to comment Share on other sites More sharing options...
DrDaxxy Posted May 1, 2015 Share Posted May 1, 2015 Have you taken a look at the ScriptHookV SDK?The included NativeTrainer sample is a Visual Studio project. Regarding your signature, I'm pretty sure they meant "control the rain" Link to comment Share on other sites More sharing options...
c39687 Posted May 1, 2015 Share Posted May 1, 2015 If you are new to lua, why not just use c++ (you just have to consider the entire script is in a while true loop so it is a matter of organizing your code differently). if you only use c# then there is hope for you, just be patient... http://ragepluginhook.net/ComingSoon.aspx here is an example of coding a toggle for code you want to only run once in a while true... (you are setting some values in gta repetitively and it is uneccessary although I dont see the harm in it, i would just do it the way below) while (true){ if (EnableKeyPressed()) { enabled = !enabled; if (!enabled) { PoliceAndPedsIgnorePlayer(false);//i made up my own method for simplicity } else { PoliceAndPedsIgnorePlayer(true); } } Wait(0);//so gta can process other scripts when it reaches the end of your loop... MANDATORY} I would like to use C++ and would prefer it but I have no idea where to start with setting up the project for asi files. I know a fairly extensive amount about C++ but not much on the side of compilers and environments (I mostly used 2012 / 2010 express which are terribly convoluted). If you could perhaps show me a reference wherein I could learn how to compile and setup files for this I would be very appreciative. I don't need help setting up much more than the basic file structure and project settings. I would much prefer C++ over Lua. 1. make a cpp source file called main.cpp which has the APIEntry method (this is the code that gets injected. Just copy the one from the native trainer.) BOOL APIENTRY DllMain(HMODULE hInstance, DWORD reason, LPVOID lpReserved){ switch (reason) { case DLL_PROCESS_ATTACH: scriptRegister(hInstance, ScriptMain);//this function is declared in main.h, ScriptMain is your method from your script's cpp that has the while true break; } return TRUE;} 2. make your script's source file, call it script.cpp and create this function in it's code... void ScriptMain(){ while (true) { //your code WAIT(0);//tells gta to come back on next loop of script thread, allows the game to process other script (without and game freezes in your script) }} then just get your headers and includes straight Link to comment Share on other sites More sharing options...
headscript Posted May 2, 2015 Share Posted May 2, 2015 Hey, just having some issues with a particular LUA script I'm working with. I never used LUA before and have no idea how to setup the mod environment in C++ because if I did I'd be using that instead however no time right now. That being said here is my problem --[[Crashes on load / reload, only changing the eval to 'not' in the first while loop.]]local supaTools = {}enabled = falsefunction supaTools.tick() while(--[[>>>not<<<]] enabled) do if(get_key_pressed(Keys.F5) and get_key_pressed(Keys.LControlKey)) then enabled = true end local playerPed = PLAYER.PLAYER_PED_ID() local player = PLAYER.GET_PLAYER_PED(playerPed) PLAYER.SET_POLICE_IGNORE_PLAYER(player, false) PLAYER.SET_EVERYONE_IGNORE_PLAYER(player, false) end while(enabled) do if(get_key_pressed(Keys.F5) and get_key_pressed(Keys.LControlKey)) then enabled = false end local playerPed = PLAYER.PLAYER_PED_ID() local player = PLAYER.GET_PLAYER_PED(playerPed) PLAYER.SET_POLICE_IGNORE_PLAYER(player, true) PLAYER.SET_EVERYONE_IGNORE_PLAYER(player, true) end end return supaTools Is anyone able to give me a hand? As I mentioned, first time LUA user and just going from what I can get from the documentation I found online / examples provided. Thanks! Edit: Also if anyone is curious it seems that the SET_POLICE_IGNORE_PLAYER only applies to ground units. Helicopters and wounded officers (last breath) will shoot you regardless. The second one probably applies to red necks and people in impoverished neighborhoods but I have not tested that yet. Any workaround would be awesome. Trying to find a way to make it so aiming at people doesn't scare them as well. dont make a infite while loop inside the tick function the tick is already getting called every some ms Link to comment Share on other sites More sharing options...
Supacure Posted May 2, 2015 Author Share Posted May 2, 2015 (edited) If you are new to lua, why not just use c++ (you just have to consider the entire script is in a while true loop so it is a matter of organizing your code differently). if you only use c# then there is hope for you, just be patient... http://ragepluginhook.net/ComingSoon.aspx here is an example of coding a toggle for code you want to only run once in a while true... (you are setting some values in gta repetitively and it is uneccessary although I dont see the harm in it, i would just do it the way below) while (true){ if (EnableKeyPressed()) { enabled = !enabled; if (!enabled) { PoliceAndPedsIgnorePlayer(false);//i made up my own method for simplicity } else { PoliceAndPedsIgnorePlayer(true); } } Wait(0);//so gta can process other scripts when it reaches the end of your loop... MANDATORY} I would like to use C++ and would prefer it but I have no idea where to start with setting up the project for asi files. I know a fairly extensive amount about C++ but not much on the side of compilers and environments (I mostly used 2012 / 2010 express which are terribly convoluted). If you could perhaps show me a reference wherein I could learn how to compile and setup files for this I would be very appreciative. I don't need help setting up much more than the basic file structure and project settings. I would much prefer C++ over Lua. 1. make a cpp source file called main.cpp which has the APIEntry method (this is the code that gets injected. Just copy the one from the native trainer.) BOOL APIENTRY DllMain(HMODULE hInstance, DWORD reason, LPVOID lpReserved){ switch (reason) { case DLL_PROCESS_ATTACH: scriptRegister(hInstance, ScriptMain);//this function is declared in main.h, ScriptMain is your method from your script's cpp that has the while true break; } return TRUE;} 2. make your script's source file, call it script.cpp and create this function in it's code... void ScriptMain(){ while (true) { //your code WAIT(0);//tells gta to come back on next loop of script thread, allows the game to process other script (without and game freezes in your script) }} then just get your headers and includes straight Wow, thanks a ton that really clarifies a lot. I recommend you post this somewhere in documentation to let newer players get started easier. I had a hard time figuring it out myself and that's not to say I'm great or anything, but more experienced than the average new guy. Hey, just having some issues with a particular LUA script I'm working with. I never used LUA before and have no idea how to setup the mod environment in C++ because if I did I'd be using that instead however no time right now. That being said here is my problem --[[Crashes on load / reload, only changing the eval to 'not' in the first while loop.]]local supaTools = {}enabled = falsefunction supaTools.tick() while(--[[>>>not<<<]] enabled) do if(get_key_pressed(Keys.F5) and get_key_pressed(Keys.LControlKey)) then enabled = true end local playerPed = PLAYER.PLAYER_PED_ID() local player = PLAYER.GET_PLAYER_PED(playerPed) PLAYER.SET_POLICE_IGNORE_PLAYER(player, false) PLAYER.SET_EVERYONE_IGNORE_PLAYER(player, false) end while(enabled) do if(get_key_pressed(Keys.F5) and get_key_pressed(Keys.LControlKey)) then enabled = false end local playerPed = PLAYER.PLAYER_PED_ID() local player = PLAYER.GET_PLAYER_PED(playerPed) PLAYER.SET_POLICE_IGNORE_PLAYER(player, true) PLAYER.SET_EVERYONE_IGNORE_PLAYER(player, true) end end return supaTools Is anyone able to give me a hand? As I mentioned, first time LUA user and just going from what I can get from the documentation I found online / examples provided. Thanks! Edit: Also if anyone is curious it seems that the SET_POLICE_IGNORE_PLAYER only applies to ground units. Helicopters and wounded officers (last breath) will shoot you regardless. The second one probably applies to red necks and people in impoverished neighborhoods but I have not tested that yet. Any workaround would be awesome. Trying to find a way to make it so aiming at people doesn't scare them as well. dont make a infite while loop inside the tick function the tick is already getting called every some ms Oh, sorry. Didn't realized that's what tick meant. Thanks for the help. I just assumed it was a arbitrary function name. I don't Lua and only learned from some doc I found online. Thank you! Edited May 2, 2015 by Supacure 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