Jump to content

Patrick

Moderators
  • Posts

    1,143
  • Joined

  • Last visited

  • Days Won

    42

Everything posted by Patrick

  1. I made an algorithm for you. It looks working good. (I'm sure there is a better solution. But this is also a viable solution.) function calculateRows(text, font, fontSize, rectangeWidth) local line_text = "" local line_count = 1 for word in text:gmatch("%S+") do local temp_line_text = line_text .. " " .. word local temp_line_width = dxGetTextWidth(temp_line_text, fontSize, font) if temp_line_width >= rectangeWidth then line_text = word line_count = line_count + 1 else line_text = temp_line_text end end return line_count end local font = "default" local size = 1 local rectangeWidth = 200 local text = "akosdk sadpdfksdfw eporksdopf sdkopfks dopfkopewkop fksdopmgfdio opfgsdopfk sdopfks dopkfowerop mkopdfmdopgmop mwropfmsdopfmsdop gmiterogmopsefm, opsdmfop meoprgm sdfopgm" local fontHeight = dxGetFontHeight(size, font) local height = calculateRows(text, font, size, rectangeWidth) * fontHeight addEventHandler("onClientRender", root, function() dxDrawText(text, 500,200,500+rectangeWidth,200+height, tocolor(255,255,255,255), size, font, "left", "top", false, true) dxDrawRectangle(500,200,rectangeWidth,height,tocolor(0,0,0,150)) end)
  2. Idea: If you have a string, like this: "This is a test string, what more than 1 row." If this string's lenght is 100px and the dxDrawRectangle's lenght is 50px, you can calculate how many rows need to the string. rows = 100 / 50 So, now you know how many rows need. This is 2. After it, you can get your font height, with dxGetFontHeight. Example: this is 30px. So the full height is: height = rows * 30
  3. Because its shows only streamed objects. What near to you. Hungarian: Azért mert csak annyit változtatott rajta, hogy a betöltött objecteket sorolja. Szóval ahol megnyitod a térképet és ott a közeledben lévőek.
  4. I did not know that. Thanks the info. So that is faster? local trashcans = {} function createTashcan(x,y,z) local object = createObject(trashcanObjectID, x,y,z) table.insert(trashcans, object) end for _, object in ipairs(trashcans) do -- same code end
  5. When you create trashcan, insert the object element to an table. And loop that table. local trashcans = {} function createTashcan(x,y,z) local object = createObject(trashcanObjectID, x,y,z) trashcans[object] = true; end for object in pairs(trashcans) do -- same code end Hungarian: Ha létrehozol egy kukát, akkor add hozzá a táblához ahonnan vissza tudod kérni, mert te jelenleg minden egyes lerakott objectet felsorolsz minden másodpercben ezért laggoltat. Viszont ha a saját tábládból sorolod csak, akkor ott nincs tele felesleges objectekkel, csak ami kell.
  6. Try that: local spawnPoints = { {416, 2066.1, 1396, 10.9, 0, 0, 127}, {416, -678.5, 977.4, 12.1, 0, 0, 127}, } local supplyVehicle = false local supplyVehicle_blip = false local supplyCollecter = false local safeZone = false function enterToSupplyVehicle(player, seat) if seat == 0 then outputChatBox("You have collected the supplies! Get to the safezone!", player, 0, 255, 0) supplyCollecter = player safeZone = createMarker(-687.2, 956.5, 12.1, "corona", 4, 255, 0, 255, 255, player) addEventHandler("onMarkerHit", safeZone, hitSafeZoneMarker) addEventHandler("onVehicleStartExit", supplyVehicle, exitFromSupplyVehicle) end end function exitFromSupplyVehicle(player) outputChatBox("Woah :O you need dem supplies! Get da :O back in da car hoe.", player, 0, 255, 0) resetAll() end function hitSafeZoneMarker(player) outputChatBox("Supplies have been delivered. New supplies spawn in 5 minutes.", root, 0, 255, 0) resetAll() setTimer(createDrops, 300000, 1) end function resetAll() removeEventHandler("onVehicleEnter", supplyVehicle, enterToSupplyVehicle) removeEventHandler("onVehicleStartExit", supplyVehicle, exitFromSupplyVehicle) removeEventHandler("onMarkerHit", safeZone, hitSafeZoneMarker) destroyElement(safeZone) destroyElement(supplyVehicle_blip) destroyElement(supplyVehicle) supplyCollecter = false end function createDrops() if not isElement(supplyVehicle) then local randomPoint = math.random(1, #spawnPoints) supplyVehicle = createVehicle(spawnPoints[randomPoint][1], spawnPoints[randomPoint][2], spawnPoints[randomPoint][3], spawnPoints[randomPoint][4], spawnPoints[randomPoint][5], spawnPoints[randomPoint][6], spawnPoints[randomPoint][7]) supplyVehicle_blip = createBlipAttachedTo(supplyVehicle, 0) outputChatBox("Supply Drop Spawned! Go capture it and return it to the safezone.", root, 0, 255, 0) addEventHandler("onVehicleEnter", supplyVehicle, enterToSupplyVehicle) end end createDrops()
  7. dxDrawRectangle dxDrawImage dxDrawText event: https://wiki.multitheftauto.com/wiki/OnClientRender event: https://wiki.multitheftauto.com/wiki/OnClientClick useful: https://wiki.multitheftauto.com/wiki/IsMouseInPosition
  8. Every body part is an object and the script only change this objects, what attached to player's body.
  9. The 'onResourceStart' call when any resource started. Delete this event and simply call the function, without event. local spawnPoints = { { 416, 2066.1, 1396, 10.9, 0, 0, 127 }, { 416, -678.5, 977.4, 12.1, 0, 0, 127 } } function createDrops() local random2 = math.random(1, #spawnPoints) supplyveh1 = createVehicle ( spawnPoints[random2][1], spawnPoints[random2][2], spawnPoints[random2][3], spawnPoints[random2][4], spawnPoints[random2][5], spawnPoints[random2][6], spawnPoints[random2][7]) suppliez = createBlipAttachedTo( supplyveh1, 0 ) outputChatBox("Supply Drop Spawned! Go capture it and return it to the safezone.", server, 0, 255, 0) end createDrops() addEventHandler("onVehicleEnter", root, function(thePlayer) if getPedOccupiedVehicle ( thePlayer ) == supplyveh1 then outputChatBox("You have collected the supplies! Get to the safezone!", root, 0, 255, 0) safeZone = createMarker ( -687.2, 956.5, 12.1, "corona", 4, 255, 0, 255, 255, thePlayer ) addEventHandler("onMarkerHit", safeZone, function() destroyElement(safeZone) destroyElement(supplyveh1) destroyElement(suppliez) outputChatBox("Supplies have been delivered. New supplies spawn in 5 minutes.", server, 0, 255, 0) setTimer(createDrops, 300000, 1) end) end end) addEventHandler("onVehicleStartExit", root, function(thePlayer) if getPedOccupiedVehicle ( thePlayer ) == supplyveh1 then outputChatBox("Woah :O you need dem supplies! Get da :O back in da car hoe.", root, 0, 255, 0) destroyElement(safeZone) end end)
  10. Patrick

    Gui Editbox

    Create the editbox outside of the screen, and if you click on the background of the editbox (dxDrawRectangle zone), select the editbox what you created outside of the screen. Hungarian: Hozd létre az editboxot képernyőn kívül, és ha az editbox dxDrawRectangle hátterére kattint, akkor jelöld ki a gui editboxot, amit létrehoztál képernyőn kívül. -- This example creates an edit box and sets the input focus so the player does not have to click before typing: local editBox = guiCreateEdit( 1.1, 0, 0.1, 0.1, "", true ) guiBringToFront( editBox ) guiEditSetCaretIndex( editBox, 1 )
  11. Ye, because this is in that script. How you spawn the vehicle?
  12. You do not specify the vehicle ID anywhere. (Write down what you want exactly. If have 2 Infernus spawned and all passengers get out from one infernus, then blow up both?)
  13. Patrick

    Help Ha

    setElementVisibleTo() or createMarker 10th argument.
  14. Patrick

    Help Ha

    Delete 'local' before elements. (Because is it local, you can only use in 'inicio5' function) local markerElement1 = createRandomMarker(createMarkerLocations1) local markerElement2 = createRandomMarker(createMarkerLocations2) local markerElement3 = createRandomMarker(createMarkerLocations3) local markerElement4 = createRandomMarker(createMarkerLocations4) local markerElement5 = createRandomMarker(createMarkerLocations5) -- TO markerElement1 = createRandomMarker(createMarkerLocations1) markerElement2 = createRandomMarker(createMarkerLocations2) markerElement3 = createRandomMarker(createMarkerLocations3) markerElement4 = createRandomMarker(createMarkerLocations4) markerElement5 = createRandomMarker(createMarkerLocations5)
  15. -- table with custom indexed rows createMarkerLocations1 = { [1] = {228, 1877, 18 -1, "cylinder", 4, 0 ,255 ,0, 255}, [2] = {228, 1891, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, [3] = {226, 1904, 18 -1, "cylinder", 4, 255, 255, 0, 170}, [4] = {212, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, [5] = {198, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations2 = { [1] = {228, 1877, 18 -1, "cylinder", 4, 0 ,255 ,0, 255}, [2] = {228, 1891, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, [3] = {226, 1904, 18 -1, "cylinder", 4, 255, 255, 0, 170}, [4] = {212, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, [5] = {198, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations3 = { [1] = {228, 1877, 18 -1, "cylinder", 4, 0 ,255 ,0, 255}, [2] = {228, 1891, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, [3] = {226, 1904, 18 -1, "cylinder", 4, 255, 255, 0, 170}, [4] = {212, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, [5] = {198, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations4 = { [1] = {228, 1877, 18 -1, "cylinder", 4, 0 ,255 ,0, 255}, [2] = {228, 1891, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, [3] = {226, 1904, 18 -1, "cylinder", 4, 255, 255, 0, 170}, [4] = {212, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, [5] = {198, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations5 = { [1] = {228, 1877, 18 -1, "cylinder", 4, 0 ,255 ,0, 255}, [2] = {228, 1891, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, [3] = {226, 1904, 18 -1, "cylinder", 4, 255, 255, 0, 170}, [4] = {212, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, [5] = {198, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170}, } function getTableSize(t) local l = 0 for _ in pairs(t) do l = l + 1 end return l end function createRandomMarker(table) local tableSize = getTableSize(table) local randomRow = math.random(1,tableSize) local count = 1 for index, data in pairs(table) do if count == randomRow then return createMarker(data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9]) break end count = count + 1 end return false end local markerElement1 = createRandomMarker(createMarkerLocations1) -- create marker from table: createMarkerLocations1 local markerElement2 = createRandomMarker(createMarkerLocations2) -- create marker from table: createMarkerLocations2 local markerElement3 = createRandomMarker(createMarkerLocations3) -- create marker from table: createMarkerLocations3 local markerElement4 = createRandomMarker(createMarkerLocations4) -- create marker from table: createMarkerLocations4 local markerElement5 = createRandomMarker(createMarkerLocations5) -- create marker from table: createMarkerLocations5 But this is easier and better: -- table without custom indexed rows createMarkerLocations1 = { {228, 1877, 18 -1, "cylinder", 4, 0 ,255 ,0, 255}, {228, 1891, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, {226, 1904, 18 -1, "cylinder", 4, 255, 255, 0, 170}, {212, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, {198, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations2 = { {228, 1877, 18 -1, "cylinder", 4, 0 ,255 ,0, 255}, {228, 1891, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, {226, 1904, 18 -1, "cylinder", 4, 255, 255, 0, 170}, {212, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, {198, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations3 = { {228, 1877, 18 -1, "cylinder", 4, 0 ,255 ,0, 255}, {228, 1891, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, {226, 1904, 18 -1, "cylinder", 4, 255, 255, 0, 170}, {212, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, {198, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations4 = { {228, 1877, 18 -1, "cylinder", 4, 0 ,255 ,0, 255}, {228, 1891, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, {226, 1904, 18 -1, "cylinder", 4, 255, 255, 0, 170}, {212, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, {198, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations5 = { {228, 1877, 18 -1, "cylinder", 4, 0 ,255 ,0, 255}, {228, 1891, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, {226, 1904, 18 -1, "cylinder", 4, 255, 255, 0, 170}, {212, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170 }, {198, 1912, 18 -1, "cylinder", 4, 255, 255, 0, 170}, } function createRandomMarker(table) local randomRow = math.random(1,#table) return createMarker(table[randomRow][1], table[randomRow][2], table[randomRow][3], table[randomRow][4], table[randomRow][5], table[randomRow][6], table[randomRow][7], table[randomRow][8], table[randomRow][9]) end local markerElement1 = createRandomMarker(createMarkerLocations1) -- create marker from table: createMarkerLocations1 local markerElement2 = createRandomMarker(createMarkerLocations2) -- create marker from table: createMarkerLocations2 local markerElement3 = createRandomMarker(createMarkerLocations3) -- create marker from table: createMarkerLocations3 local markerElement4 = createRandomMarker(createMarkerLocations4) -- create marker from table: createMarkerLocations4 local markerElement5 = createRandomMarker(createMarkerLocations5) -- create marker from table: createMarkerLocations5
  16. loadstring("your code here as a string")()
  17. if getPlayerWantedLevel(playerElement) > 0 then -- code end
  18. It may be good to start: https://community.multitheftauto.com/index.php?p=resources&s=details&id=12699
  19. Patrick

    error account

    Your 'passwordVerify' function is not exists, but it's not enough information. Show me your script.
  20. -- client side function openShopFunction ( message ) outputChatBox ( "SHOP: "..message ) shopmenu = guiCreateWindow ( 100, 200, 300, 300,"panel", false ) buttonX = guiCreateButton ( 100, 200, 25, 25,"X", false, shopmenu ) addEventHandler ( "onClientGUIClick", buttonX, function() outputChatBox ( "SHOP: you're close" ) destroyElement(shopmenu) end ) end addEvent("openShopOnClientSide", true) addEventHandler("openShopOnClientSide", root, openShopFunction) -- server side local menu = createMarker(-2385.5, -748.7, 133.1, "cylinder", 3, 255, 0, 0) function openShop(hitElement, matchingDimension) triggerClientEvent(hitElement, "openShopOnClientSide", hitElement, "Your HIT.") end addEventHandler("onMarkerHit", menu, openShop)
  21. Do without OOP. gate = createObject(1337, 712.61853, 659.00409, 9.94867) addEventHandler('onClientClick', root, function(_,_,_,_,wx,wy,wz) setElementPosition(gate, wx,wy,wz) end)
×
×
  • Create New...