iwalidza Posted February 6, 2022 Share Posted February 6, 2022 i want make farm server and its based in server side to show same object to all players now i want to make for every object in this farm system health bar. what best idea to share date from server to client ElementsPositions = { {156 ,-57}, {287 ,-57}, {256 ,-7}, {139, -86}, } types = { [1] = { [1] = { {3929,1}, {3930,1}, {3931,1}, {2936,1}, }, [2] = { {747,- 0.3}, {758,- 0.3}, {746,- 0.3}, {745,- 0.3}, }, [3] = { {1303,0.4}, {1304,0.4}, {1305,0.4}, } }, [2] = { [1] = { {655,0.3}, {660,0.3}, {708,0.3}, {657,0.3}, {673,-1}, }, }, [3] = { [1] = { {811,-0.1}, {818,0}, {809,0}, }, }, } main = exports.main local Resources = {} local Elements = {} Resources = inherit(Class) addEvent('reserveGroundPos', true) function Resources:constructor(type,x,y) self.type = math.random(1,#types) self.selectedType = math.random(1,#types[self.type]) self.x = x self.y = y self.health = 1000 self.Fcreate = bind(self.createResources, self) self:registerEvent("onPlayerResourceStart", root, self.Fcreate) end function Resources:createResources(loadedResource) if loadedResource ~= getThisResource() then return end if types[self.type] then if not getGroundPos(source,self.x,self.y) then return end addEventHandler('reserveGroundPos',root,function(z) self.z = z if self.object then return end self.randomeSelectType = math.random(1,#types[self.type][self.selectedType]) self.TypeSelected = types[self.type][self.selectedType][self.randomeSelectType] self.object = createObject(self.TypeSelected[1],self.x,self.y,self.z + self.TypeSelected[2]) setElementFrozen(self.object,true) setElementData(source,"object:x",self.x,"local") end) end end function randomSpawn () for i,v in ipairs(ElementsPositions) do Elements = Resources:new(1,v[1] ,v[2]) end end randomSpawn () function getGroundPos(player,x,y) return triggerClientEvent(player,"onGetGroundPos",player,x,y) end 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