..:D&G:.. Posted February 27, 2015 Share Posted February 27, 2015 Hello guys, I got some problems with an interaction system. On my other server it works perfectly, but on my main server it doesn't. I want to get the interior and dimension of an element which is self.col local cFunc = {}; -- Local Functions local cSetting = {}; -- Local Settings Interaction_System = {}; Interaction_System.__index = Interaction_System; function Interaction_System:New(...) local obj = setmetatable({}, {__index = self}); if obj.Constructor then obj:Constructor(...); end return obj; end function Interaction_System:Render() local x, y, z = getElementPosition(localPlayer) local int, dim = getElementInterior(localPlayer), getElementDimension(localPlayer) if(int ~= getElementInterior(self.col)) then setElementInterior(self.col, int) end if(dim ~= getElementDimension(self.col)) then setElementDimension(self.col, dim) end setElementPosition(self.col, x, y, z); end function Interaction_System:HitCol(hitElement) if(isPedInVehicle(localPlayer) == false) then local lastdis = math.huge; for index, ele in pairs(getElementsWithinColShape(self.col)) do if(self.allowedInteraction[getElementType(ele)] == true) and (getElementData(ele, "SLOTMACHINE:LEVER")) then local x, y, z = getElementPosition(localPlayer) local x2, y2, z2 = getElementPosition(ele) if(getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) < lastdis) then lastdis = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) hitElement = ele end end end if(isElement(hitElement)) then self.interactElement = hitElement; end end end function Interaction_System:LeaveCol(hitElement) self.interactElement = nil; end function Interaction_System:Toggle() if(isElement(self.interactElement)) then if(getElementData(self.interactElement, "SLOTMACHINE:LEVER") == true) then triggerServerEvent("onSlotmachineStartPlayer", self.interactElement, localPlayer) end end end function Interaction_System:Constructor(...) self.renderFunc = function() self:Render() end; self.colHitFunc = function(...) self:HitCol(...) end; self.colLeaveFunc = function(...) self:LeaveCol(...) end; self.toggleFunc = function(...) self:Toggle() end; self.allowedInteraction = { ["object"] = true, ["vehicle"] = true, } self.interactElement = nil; -- Instanzen self.col = createColSphere(0, 0, 0, 4); addEventHandler("onClientRender", getRootElement(), self.renderFunc) addEventHandler("onClientColShapeHit", self.col, self.colHitFunc) addEventHandler("onClientColShapeLeave", self.col, self.colLeaveFunc) bindKey("h", "down", self.toggleFunc) outputDebugString("[CALLING] Interaction_System: Constructor"); end -- EVENT HANDLER -- local interaction_system = Interaction_System:New() Any ideas? I don't get why it works on a server but not on the other.. Link to comment
Addlibs Posted February 28, 2015 Share Posted February 28, 2015 What is the actual problem? What isn't working? Any /debugscript 3 errors? Link to comment
..:D&G:.. Posted February 28, 2015 Author Share Posted February 28, 2015 As I already said, getElementDimension/Interior doesn't get "self.col" as an element, it says that element expected at argument 1... Link to comment
Addlibs Posted February 28, 2015 Share Posted February 28, 2015 I'm not good at metatables and custom OOP, so I cannot really help, but I think this might be the problem: Is self defined within the self.renderFunc on line 66? Line 66: self.renderFunc = function() self:Render() end; --is self defined within this function? Link to comment
..:D&G:.. Posted February 28, 2015 Author Share Posted February 28, 2015 This is the function with the render, and the function that gives all the errors: function Interaction_System:Render() local x, y, z = getElementPosition(localPlayer) local int, dim = getElementInterior(localPlayer), getElementDimension(localPlayer) if(int ~= getElementInterior(self.col)) then setElementInterior(self.col, int) end if(dim ~= getElementDimension(self.col)) then setElementDimension(self.col, dim) end setElementPosition(self.col, x, y, z); end It is defined a bit more down, in another function. I am saying this again, it worked on my second server but not on my first. Is there any way that another script could intersect with this one and make it stop working? 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