Jump to content

unloding functions


UAEpro

Recommended Posts

«love0031.giflove0041.gifhappy0064.gif»

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ɪᴛ

«sad.gifcry.gifbeee.gif»

Link to comment
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
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
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 by Guest
Link to comment
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
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
  
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...