Jump to content

It looks that client-side scripts are sometimes not unloaded


ryden

Recommended Posts

Try this code as a client-side script in a gamemode type resource:

buggy = { } 
  
function buggy.Start(resource) 
  if (resource ~= getThisResource()) then return end 
  local self = buggy 
  
  bindKey("tab", "both", buggy.onTab) 
  addEventHandler("onClientResourceStop", getRootElement(), buggy.Stop) 
end 
  
function buggy.Stop(resource) 
  if (resource ~= getThisResource()) then return end 
  local self = buggy 
  
  if (self.theTimer) then 
    killTimer(self.theTimer) 
  end 
end 
  
function buggy.PrintText() 
  outputChatBox("You still have the TAB key pressed #1") 
end 
  
function buggy.onTab(key, keyState) 
  local self = buggy 
  
  if (keyState == "down") then 
    self.theTimer = setTimer(buggy.PrintText, 1500, 0) 
  else 
    killTimer(self.theTimer) 
    self.theTimer = nil 
  end 
end 
  
addEventHandler("onClientResourceStart", getRootElement(), buggy.Start) 

Hold TAB pressed and look what is happening. Everything is OK, every 1.5 seconds it displays the message in the chatbox.

Now change that "You still have the TAB key pressed #1" string to, for example, "You still have the TAB key pressed #2". Type in the console "restart TheContainingResource", and it will download the new script with the string modified. Now hold TAB key down again, and you will see that old and new scripts were executed, showing two different messages in the chat box every 1.5 seconds.

If it doesn't fail in the first try, change the string again to #3 and restart the resource again. Sometimes doesn't fail in the first try.

It works fine again if you /reconnect to the server.

Link to comment
  • Recently Browsing   0 members

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