UAEpro Posted August 2, 2012 Share Posted August 2, 2012 ❝ «≈≈» ✪‹Eɴᴛᴇʀ›✪ Hello i made a script using this topic [TUT] Protect Client Script at the Highest Level and i know that loadstring() is used to read string (functions) etc but is there any way that i can unload this function ? without restarting the resource i tried to create another resource (temporary) then the script will write meta.xml and write the script file then .. rewrite the script file and meta.xml and restart resource .. but this is a long story .. is there any why ? ✪‹Exɪᴛ›✪ «≈≈» ❝ Link to comment
qaisjp Posted August 2, 2012 Share Posted August 2, 2012 You have to code it manually [make sure event handlers are added/removed at the right times, if timers are used, kill any and all when wanting to 'unload' it] Link to comment
UAEpro Posted August 3, 2012 Author Share Posted August 3, 2012 ok ... for example i used loadstring() for a script is full of timers .. then i want to unload it .. how i can detect the timers created by the loadstring .. i hope you understand Link to comment
UAEpro Posted August 4, 2012 Author Share Posted August 4, 2012 ummm .. no one know ? ! Link to comment
arezu Posted August 6, 2012 Share Posted August 6, 2012 function overriding, like i told you on skype. Link to comment
UAEpro Posted August 7, 2012 Author Share Posted August 7, 2012 function overriding, like i told you on skype. i still didn't understood what is that .. but as i think i need to get all handlers,commands,timers,binds and disable it after knowing the name For example .. removeEventHanler .. removeCommandHandler etc .. but the problem now .. how i can get (handler name) from a string Link to comment
Tete omar Posted August 7, 2012 Share Posted August 7, 2012 function overriding, like i told you on skype. i still didn't understood what is that .. but as i think i need to get all handlers,commands,timers,binds and disable it after knowing the name For example .. removeEventHanler .. removeCommandHandler etc .. but the problem now .. how i can get (handler name) from a string string.find ? Link to comment
UAEpro Posted August 7, 2012 Author Share Posted August 7, 2012 (edited) function overriding, like i told you on skype. i still didn't understood what is that .. but as i think i need to get all handlers,commands,timers,binds and disable it after knowing the name For example .. removeEventHanler .. removeCommandHandler etc .. but the problem now .. how i can get (handler name) from a string string.find ? i know that .. but if it was addEventHandler( "onPlayerSpawn", rootElement, onPlayerSpawnHandler ) string.find(scriptString, "addEventHandler") then i can find the handler but how i can know the string (event) 'onPlayerSpawn' Edited August 7, 2012 by Guest Link to comment
TAPL Posted August 7, 2012 Share Posted August 7, 2012 https://wiki.multitheftauto.com/wiki/AddEventHandler eventName: the name of the event which triggered the handler function. Link to comment
UAEpro Posted August 7, 2012 Author Share Posted August 7, 2012 https://wiki.multitheftauto.com/wiki/AddEventHandlereventName: the name of the event which triggered the handler function. table ,, i mean in String.find .. Link to comment
Tete omar Posted August 7, 2012 Share Posted August 7, 2012 string.find("the string") Link to comment
TAPL Posted August 7, 2012 Share Posted August 7, 2012 addEventHandler("onPlayerSpawn", rootElement, onPlayerSpawnHandler) if string.find(scriptString, "addEventHandler") then eventString = string.sub(scriptString, 18, #scriptString) end i think this will return "onPlayerSpawn", rootElement, onPlayerSpawnHandler)" try to fix it.. Link to comment
Arisu Posted August 7, 2012 Share Posted August 7, 2012 addEventHandler("onPlayerSpawn", rootElement, onPlayerSpawnHandler) if string.find(scriptString, "addEventHandler") then eventString = string.sub(scriptString, 18, #scriptString) end You are wrong. What would you do with compiled scripts? You could override addEventHandler with such code: local __eventsList = {} -- table to save event handlers data local __addEventHandler = addEventHandler -- save original function address local addEventHandler = function (eventName, element, handlerFunc) -- override with own if __addEventHandler(eventName, element, handlerFunc) then table.insert(__eventsList, { ["name"] = eventName, ["element"] = element, ["handler"] = handlerFunc}) end end Now, think of what you can do with that events table. Same method could be applied to other functions, liek setTimer, removeEventHandler and so on. Of course, this should be loaded before executing any loadstring. Link to comment
qaisjp Posted August 7, 2012 Share Posted August 7, 2012 WRAPPER. Code extracted from NPG, please credits us where due: http://pastebin.com/BmfYYPyn use addCommand to add it to the list. then use installCommands() to load all commands and removeCommands() to delete all commands. doing installCommands after deleting commands will work (because its still listed) Link to comment
UAEpro Posted August 8, 2012 Author Share Posted August 8, 2012 local __eventsList = {} -- table to save event handlers data local __addEventHandler = addEventHandler -- save original function address local addEventHandler = function (eventName, element, handlerFunc) -- override with own if __addEventHandler(eventName, element, handlerFunc) then table.insert(__eventsList, { ["name"] = eventName, ["element"] = element, ["handler"] = handlerFunc}) end end Now, think of what you can do with that events table. Same method could be applied to other functions, liek setTimer, removeEventHandler and so on. Of course, this should be loaded before executing any loadstring. ok i have add this table to the script string and i load it with the script string .. but it didn't work .. did i do something wrong ? Link to comment
UAEpro Posted August 10, 2012 Author Share Posted August 10, 2012 ok .. i don't need help anymore .. i found another easier way Link to comment
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