• Content Count

  • Joined

  • Last visited

Community Reputation

1 Neutral

About Bhelic

  • Rank
    I ordered some spaghetti with marinara sauce and I got egg noodles and ketchup. I'm an average nobody.
  1. I dont think its the variable player On the outputChatBox i placed, i get: worldGrid before: table: 06294738 player: userdata: 00000A93 worldGrid after: table: 024BA560 player: userdata: 00000A93 But with your idea i used: setTimer(function() self:updatePlayerZone(player) end, 4000, 1) and it worked. Thank you!
  2. I was making a new script with classes for mta, and i need to set a timer inside a method like this. function WorldGrid:updatePlayerZone(player) -- DOING NON RELEVANT SHI T HERE outputChatBox("worldGrid: " .. tostring(worldGrid) .. " player: " .. tostring(player)) setTimer(self:updatePlayerZone, 4000, 1, player) end end This couldnt even compile, because self:updatePlayerZone is not recognized as a function. So.. i checked setTimer mta wiki page. it says: theFunction: The function you wish the timer to call. (Notice: Do not use a 'local' function, it must be global!) So, i need to call a global function on setTimer. I tryed out this: function updatePlayerZoneWrapper(worldGrid, player) outputChatBox("worldGrid " .. tostring(worldGrid) .. " player: " .. tostring(player)) worldGrid:updatePlayerZone(player) end function WorldGrid:updatePlayerZone(player) outputChatBox("worldGrid before: " .. tostring(self) .. " player before: " .. tostring(player) setTimer(updatePlayerZoneWrapper, 4000, 1, self, player) end end But it didnt work neither.. I get: Attempt to call method 'updatePlayerZone' (a nil value) I continued reading setTimer wiki page, and i found this: arguments: Any arguments you wish to pass to the function can be listed after the timesToExecute argument. Note that any tables you want to pass will get cloned, whereas metatables and functions/function references in that passed table will get lost. Also changes you make in the original table before the function gets called won't get transferred. So, im coming to you guys, hoping you have a possible solution for this. Thanks for your time