Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    kasperbjerby's Avatar
    Join Date
    Nov 2011
    Gender
    male
    Location
    Denmark
    Posts
    133
    Reputation
    10
    Thanks
    687

    Question luaL_loadfile and luaL_loadstring

    I got luaL_loadfile and luaL_loadstring working all fine but when i try to load a "larger" string or file it crash the game..
    I can load the "larger" file or string using the normal lua_run_cl and lua_openscript_cl just fine...

    Anyone know why that is the case and maybe a way to fix it?
    Any feedback would be greatly appreciated

  2. #2
    tdsx's Avatar
    Join Date
    Apr 2014
    Gender
    male
    Posts
    255
    Reputation
    10
    Thanks
    1,004
    How big, exactly? Where is the code you are using to get luaL_loadfile and luaL_loadstring?

  3. #3
    kasperbjerby's Avatar
    Join Date
    Nov 2011
    Gender
    male
    Location
    Denmark
    Posts
    133
    Reputation
    10
    Thanks
    687
    Quote Originally Posted by tdsx View Post
    How big, exactly?
    Allready at around 100 lines of simple "print('test')"

    Quote Originally Posted by tdsx View Post
    Where is the code you are using to get luaL_loadfile and luaL_loadstring?
    Code:
    lua_gettop = (int(*)(lua_State*))(DWORD)GetProcAddress(GetModuleHandle("lua_shared.dll"), "lua_gettop");
    luaL_loadstring = (int(*)(lua_State*, const char*))(DWORD)GetProcAddress(GetModuleHandle("lua_shared.dll"), "luaL_loadstring");
    lua_pcall = (int(*)(lua_State*, int, int, int))(DWORD)GetProcAddress(GetModuleHandle("lua_shared.dll"), "lua_pcall");
    
    if(!lua_gettop(luaState)) {
    	luaL_loadstring(luaState, string);
    	lua_pcall(luaState, 0, 0, 0);
    }
    I just don't understand why running the lua normaly would work but not this way?
    It should be the same thing? Right?
    It's also pretty odd that it works fine if the string or file is small.. Like if it only has 1 line or 10..
    It also dosen't matter if i put it on multiple lines or one line... I think it just don't like doing that many "actions"
    Last edited by kasperbjerby; 07-25-2014 at 02:55 PM.

  4. #4
    tdsx's Avatar
    Join Date
    Apr 2014
    Gender
    male
    Posts
    255
    Reputation
    10
    Thanks
    1,004
    I'll test your code and see if I crash later on today.

  5. #5
    TroubleMakers's Avatar
    Join Date
    Feb 2014
    Gender
    male
    Posts
    65
    Reputation
    10
    Thanks
    27
    My Mood
    Bashful
    use runstring you dumbfuck

  6. #6
    kasperbjerby's Avatar
    Join Date
    Nov 2011
    Gender
    male
    Location
    Denmark
    Posts
    133
    Reputation
    10
    Thanks
    687
    Quote Originally Posted by TroubleMakers View Post
    use runstring you dumbfuck
    Be nice? I am not making a module.. But if you can tell me how to use runstring without the gmod headers i am open for it
    Last edited by kasperbjerby; 07-27-2014 at 10:07 AM.

  7. #7
    Function - OC's Avatar
    Join Date
    Jun 2014
    Gender
    male
    Posts
    1
    Reputation
    10
    Thanks
    4
    Add me on steam for it 功能 - OC

  8. #8
    MFSiNC's Avatar
    Join Date
    Jan 2012
    Gender
    male
    Posts
    28
    Reputation
    10
    Thanks
    25
    My Mood
    Bored
    Quote Originally Posted by Function - OC View Post
    Add me on steam for it 功能 - OC
    Don't keep helping cheaters.

  9. The Following User Says Thank You to MFSiNC For This Useful Post:

    z346etn56jzd7egth (07-27-2014)

  10. #9
    z346etn56jzd7egth's Avatar
    Join Date
    Dec 2010
    Gender
    male
    Posts
    37
    Reputation
    19
    Thanks
    1,123
    My Mood
    Dead
    If you guys could get on my level you could figure it out.

  11. #10
    _Fami's Avatar
    Join Date
    Jul 2014
    Gender
    male
    Posts
    107
    Reputation
    10
    Thanks
    85
    Quote Originally Posted by Function - OC View Post
    Add me on steam for it 功能 - OC
    paster detected

    Quote Originally Posted by kokomika View Post
    If you guys could get on my level you could figure it out.
    you're not even @BigBadWilly 's level so you can stop bragging about your nonexisting skills :willythumb:

  12. #11
    kasperbjerby's Avatar
    Join Date
    Nov 2011
    Gender
    male
    Location
    Denmark
    Posts
    133
    Reputation
    10
    Thanks
    687
    Quote Originally Posted by tdsx View Post
    I'll test your code and see if I crash later on today.
    You ever got to test it?

  13. #12
    tdsx's Avatar
    Join Date
    Apr 2014
    Gender
    male
    Posts
    255
    Reputation
    10
    Thanks
    1,004
    Quote Originally Posted by kasperbjerby View Post
    You ever got to test it?
    nah I got lazy. Go look at dis.

    https://******.com/tdsx/gmcl_externa...uxiliary.h#L46

    It's a shitty way to do it, though. You should do if (!luaL_loadbuffer call) then LUA->Call. I fucked that part up.
    Last edited by tdsx; 08-05-2014 at 01:44 PM.

  14. #13
    MeepDarknessMeep's Avatar
    Join Date
    Aug 2012
    Gender
    female
    Posts
    725
    Reputation
    22
    Thanks
    922
    Code:
    	void RunString(const char* string)
    	{
    		int code = luaL_loadbuffer(m_luaState, string, strlen(string), "=RunString");
    		if(code)
    		{
    			const char* szError = lua_tostring(m_luaState, -2);
    			pCvar->ConsoleColorPrintf(Color(192, 57, 43, 255), "[COMPILE ERROR] %s\n", szError);
    			lua_pop(m_luaState, 2);
    			return;
    		}
    		code = lua_pcall(m_luaState, 0, 0, m_iError);
    		if(code != LUA_SUCCESS) 
    		{
    			lua_pop(m_luaState, 1);
    		}
    	}
    is what i use

  15. #14
    _Fami's Avatar
    Join Date
    Jul 2014
    Gender
    male
    Posts
    107
    Reputation
    10
    Thanks
    85
    skids are helping skids wtf is that shit

  16. #15
    kasperbjerby's Avatar
    Join Date
    Nov 2011
    Gender
    male
    Location
    Denmark
    Posts
    133
    Reputation
    10
    Thanks
    687
    Quote Originally Posted by MeepDarknessMeep View Post
    Code:
    	void RunString(const char* string)
    	{
    		int code = luaL_loadbuffer(m_luaState, string, strlen(string), "=RunString");
    		if(code)
    		{
    			const char* szError = lua_tostring(m_luaState, -2);
    			pCvar->ConsoleColorPrintf(Color(192, 57, 43, 255), "[COMPILE ERROR] %s\n", szError);
    			lua_pop(m_luaState, 2);
    			return;
    		}
    		code = lua_pcall(m_luaState, 0, 0, m_iError);
    		if(code != LUA_SUCCESS) 
    		{
    			lua_pop(m_luaState, 1);
    		}
    	}
    is what i use
    It works 1 in 5 times..
    Others it runs the lua and then crash..
    Just to be sure what is m_iError and LUA_SUCCESS?

Page 1 of 2 12 LastLast

Similar Threads

  1. CS 1.6 VAC2 proof hacks AND cheat death hacks
    By Brunogol in forum General Game Hacking
    Replies: 28
    Last Post: 12-18-2006, 08:26 PM
  2. Get Avatars and Sigs!
    By Dave84311 in forum General
    Replies: 25
    Last Post: 05-17-2006, 08:44 PM
  3. Plz I Want Maple Global Hacks And Where Do I Get Game Engine 2 Make The Hacks Work???
    By mattinthehat in forum MapleStory Hacks, Cheats & Trainers
    Replies: 3
    Last Post: 01-15-2006, 06:12 PM
  4. Lineag2 and Ragnarok
    By suppaman in forum General Gaming
    Replies: 12
    Last Post: 01-01-2006, 04:07 PM
  5. i need short icq number pls and hack to wr..
    By BoneXDBreaker in forum WarRock - International Hacks
    Replies: 1
    Last Post: 12-26-2005, 05:08 PM