Jump to content

iwalidza

Members
  • Posts

    155
  • Joined

Everything posted by iwalidza

  1. addEventHandler("onClientResourceStart", resourceRoot, function() setDiscordState("Loading...") end) Wiki example
  2. Hello about your resource you use this functions and events onClientGUIClick -- use to check what gui click getElementType -- check if the source clicked is check box that is check box type "gui-checkbox" guiCheckBoxGetSelected -- to check if the check box is on or off fileExists -- to check if file save infos that is exists or no fileCreate -- to create file that will have the client user name and password fileWrite -- write the infos in the file toJSON -- to make the infos write with json fileClose -- don't forge to close the file -- now you need to check when login panel start if client is have remember me then turn it on again and use next function fileExists -- to check if file save infos that is exists or no fileOpen -- to open the file fileGetSize -- to get the file read size fileRead -- read the file fileClose -- don't forge to close the file fromJSON -- that to get json data guiSetText -- now you can set the username and password edit box text
  3. fuelConsumption = 0.004 fuelTable = {} function vehMove() for i,v in ipairs(getElementsByType("vehicle")) do x,y,z = getElementPosition(v) if fuelTable[v] then distance = getDistanceBetweenPoints3D(x,y,z,fuelTable[v][2],fuelTable[v][3],fuelTable[v][4]) enginePlus = 0 if getVehicleEngineState(v) then enginePlus = 0.08 end newFuel = fuelTable[v][1] - (fuelConsumption*(distance+enginePlus)) fuelTable[v] = {newFuel,x,y,z} setElementData(v, "fuel", fuelTable[v][1]) else if getElementData(v, "fuel") then fuelTable[v] = {getElementData(v, "fuel"), x, y, z} else fuelTable[v] = {100, x, y, z} end end if getElementData(v, "fuel") <= 0 then setVehicleEngineState(v, false) end end end setTimer(vehMove, 1000, 0)
  4. Yeah i use it and its perfect, thank for help all.
  5. I found these great tutorials that may clarify the idea of oop for many programmers and I want to share them with you, good luck.
  6. Unable to load mods\deathmatch\modules\bcrypt.dll (126) why is that. i just have that error any one can help me?
  7. I have an inventory system it has stack system like one slot can get just 10 apples like if i write command to give player item and i want give player like 36 apples and he have 4 apples in him inventory then him inventory he be like that 10 10 10 10 10 how i can do it
  8. iwalidza

    share data

    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
  9. how i can get ground position with this in server side
  10. -- client side function getGroundPos (x,y) local is_hit, hitX, hitY, hitZ = processLineOfSight( x,y, 5000, x,y, -30, true, false, false, true, true, false, false, false, nil, false, false ) if not hitZ then return 0 end return hitZ end function serverGroundPos(x,y) z = getGroundPos (x,y) end addEvent('getGroundPos',true) addEventHandler('getGroundPos',root,serverGroundPos) -- server side function getGroundPos (player,x,y) triggerClientEvent(player,'getGroundPos',player,x,y) end function returnGroundPos (z) return z end addEvent('returnGroundPos',true) addEventHandler('returnGroundPos',root,returnGroundPos) and in exported script self.z = main:getGroundPos(source,self.x,self.y) self.z return nil
  11. i make new getGroundPosition() its in client side how i can return the value in server side and make export function for it
  12. slot not change if (self.getSlotInfo[4]) then print('move') invMoveSlots(draginv, dragslot, self, self.getSlotInfo[4]) end nothing out
  13. bad usage @ addEventHandler onClientRender with this function is already handled
  14. function Inventory:constructor(type, slots, startX, startY, iconSize, padding, isOpen, color) self.type = type or 'player' self.items = {} self.slots = slots or DEFAULT_Slots self.startX = startX or 0 self.startY = startY or 0 self.iconSize = iconSize or DEFAULT_iconSize self.padding = padding or DEFAULT_padding self.isOpen = isOpen self.color = color or DEFAULT_Color self.fDraw = bind(self.draw, self) self.fDrag = bind(self.drag, self) self.fSlot = bind(self.drawSlot, self) if self.isOpen then self:registerEvent("onClientRender", root, self.fDraw) self:registerEvent("onClientClick", root, self.fDrag) end end function Inventory:drawSlot (slot,count) local mousePosition = Vector2(getCursorPosition()) self.mouseX = (mousePosition.x * screen.x) - (self.iconSize / 2) self.mouseY = (mousePosition.y * screen.y) - (self.iconSize / 2) if not self.getSlotInfo[4] then return end dxDrawImage(self.mouseX,self.mouseY,self.iconSize,self.iconSize,"image/items/"..tonumber(self.items[self.getSlotInfo[4]][1])..".png") local countWidht = dxGetTextWidth(self.items[self.getSlotInfo[4]][2],1,"default-bold") dxDrawText(self.items[self.getSlotInfo[4]][2] ,(self.mouseX + (self.iconSize)) - countWidht,(self.mouseY + (self.iconSize - 20) ),0,0,tocolor(255,255,255),1,"default-bold",'left','top',false,false,true) dxDrawRectangle(self.mouseX,self.mouseY,self.iconSize,self.iconSize,tocolor(10,10,10,50)) end
  15. out error bad use addEventHandler('onClientRender',root,self.fSlot)
  16. function Inventory:moveSlots(slot1,slot2) if not slot1 and not slot2 then return end local selectedSlot1 = self.items[slot1] local selectedSlot2 = self.items[slot2] self.items[slot1] = selectedSlot2 self.items[slot2] = selectedSlot1 end
  17. function Inventory:getSlot (x,y) for i = 1, self.slots do local t = i - 1 local xOffset = self.startX + (t*(self.iconSize + self.padding)) local yOffset = self.startY + (math.floor(t/6)*(self.iconSize + self.padding)) xOffset = xOffset - math.floor(t/6)*(6*(self.iconSize + self.padding)) if isInBox(x,y,xOffset,xOffset + self.iconSize,yOffset,yOffset + self.iconSize) then return self.type,xOffset,yOffset,i end end return nil,nil,nil,nil end
  18. like if i click in item and not take my finger out i can drag the item to other slot
  19. function Inventory:drawSlot (slot,count) local mousePosition = Vector2(getCursorPosition()) self.mouseX = (mousePosition.x * screen.x) - (self.iconSize / 2) self.mouseY = (mousePosition.y * screen.y) - (self.iconSize / 2) if not self.getSlotInfo[4] then return end dxDrawImage(self.mouseX,self.mouseY,self.iconSize,self.iconSize,"image/items/"..tonumber(self.items[self.getSlotInfo[4]][1])..".png") local countWidht = dxGetTextWidth(self.items[self.getSlotInfo[4]][2],1,"default-bold") dxDrawText(self.items[self.getSlotInfo[4]][2] ,(self.mouseX + (self.iconSize)) - countWidht,(self.mouseY + (self.iconSize - 20) ),0,0,tocolor(255,255,255),1,"default-bold",'left','top',false,false,true) dxDrawRectangle(self.mouseX,self.mouseY,self.iconSize,self.iconSize,tocolor(10,10,10,50)) end function Inventory:drag(button,state,mouseX,mouseY) if button == 'left' then if state == 'down' then self.getSlotInfo = {self:getSlot(mouseX,mouseY)} firsSlot = self.getSlotInfo[4] addEventHandler('onClientRender',root,self.fSlot) end if state == 'up' then self.getSlotInfo = {self:getSlot(mouseX,mouseY)} print(self.getSlotInfo[4]) self:moveSlots(firsSlot,self.getSlotInfo[4]) removeEventHandler('onClientRender',root,self.fSlot) end end end i can make it better? and work good . that not work @The_GTA what i want : i want if player still clicking in the slot he can drag him and change slot of item
  20. i now it how i can do it i want check if player is still clicking i use on client click its do that
  21. how i can chack if player mouse still click
  22. its work good but with down one just return false beltInventory not work why? playerInventroy = Inventory:new('player',24,((screen.x / 2) - ((DEFAULT_iconSize - DEFAULT_padding) * 3)),screen.y - ((DEFAULT_iconSize + (DEFAULT_padding * 2)) * 5),nil,nil,false) clothInventory = Inventory:new('cloth',6,(0 + (DEFAULT_padding * 13)) ,screen.y - ((DEFAULT_iconSize + DEFAULT_padding) * 3.37),nil,nil,false) beltInventory = Inventory:new('belt',6,((screen.x / 2) - ((DEFAULT_iconSize - DEFAULT_padding) * 3)),screen.y - (DEFAULT_iconSize + DEFAULT_padding),nil,nil,true) function Inventory:getSlot (x,y) print(self.type) for i = 1, self.slots do local t = i - 1 local xOffset = self.startX + (t*(self.iconSize + self.padding)) local yOffset = self.startY + (math.floor(t/6)*(self.iconSize + self.padding)) xOffset = xOffset - math.floor(t/6)*(6*(self.iconSize + self.padding)) if isInBox(x,y,xOffset,xOffset + self.iconSize,yOffset,yOffset + self.iconSize) then return i end end return false end its return just cloth and player why? @The_GTAi fix it and how i can get the inventory player click like if click in playerInventory its return playerInventory or clothInventory
  23. i have the problem with calculate function Inventory:getSlot (x,y) for i = 1, self.slots do local t = i - 1 local xOffset = self.startX + (t*(self.iconSize + self.padding)) local yOffset = self.startY + (math.floor(t/6)*(self.iconSize + self.padding)) xOffset = xOffset - math.floor(t/6)*(6*(self.iconSize + self.padding)) if isInBox(x,y,xOffset,xOffset + self.iconSize,yOffset,yOffset + self.iconSize) then slot = i return slot end end end its return " " " " "slotid"
  24. what the best idea to get slot from mouse click?
×
×
  • Create New...