Jump to content

Mkl

Members
  • Posts

    32
  • Joined

  • Last visited

1 Follower

About Mkl

  • Birthday 06/06/1994

Details

  • Gang
    STF
  • Location
    Ten Green Bottles

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Mkl's Achievements

Rat

Rat (9/54)

10

Reputation

  1. predefined variable localPlayer doesn't exist serverside. You can direclty set the name as first argument, It'll send to root element by default, and so every players children. bool triggerClientEvent ( [ table/element sendTo = getRootElement(), ] string name, element sourceElement [, arguments... ] ) Set the sourceElement (3rd parameter), I suggest resourceRoot (the present resource). triggerClientEvent("eventName", resourceRoot) You can aim specific players by passing a table as first parameter (or loop). By the way be careful with your addEventHandler("onResourceStart", ...). Set getRootElement() (same as root predefined variable) will have for result to trigger the function everytime a resource is starting. You should rather use resourceRoot (for the actual resource). addEventHandler("onResourceStart", resourceRoot, createMinigunWeapon)
  2. Hi, we need to see more code context (the whole function, attached event or command and where you create peds) Would be great if you can use code blocks, thanks. For now all I can say is that ped1, ped2, ped3 variables are nil maybe due to your setTimer.
  3. It is updateState(value, total, radius), like updateState(50, 100, 250) should give half a circle. It could be edited to remove radius param in our case. This is the way I update the svg : local function setProgress(value) local svgXML = svgGetDocumentXML(mySvg) -- get xml local path = xmlNodeGetChildren(svgXML, 1) -- get path node (second node, following first example I gave) xmlNodeSetAttribute(path, "d", updateState(value, 100, 250)) -- editing the attribute svgSetDocumentXML(mySvg, svgXML) -- saving end You could imagine a command to test it like : local function startDemo() local value = 0 setTimer(function() value = value + 1 setProgress(value) end, 10, 100) end addCommandHandler("demo", startDemo) A little animation 0 to 100 % of the circle progress.
  4. Like a percentage progress ? Yes it's possible. You have to update the SVG using svgGetDocumentXML and svgSetDocumentXML (check example on the wiki). I found a way to draw the circle regarding percentage progress with this function : local function updateState(value, total, R) local center local alpha = 360 / total * value local a = (90 - alpha) * math.pi / 180 local x = 300 + R * math.cos(a) local y = 300 - R * math.sin(a) local path if (total == value) then path = "M300,"..(300 - R).." A"..R..","..R..",0,1,1,299.99,"..(300 - R) else if (alpha > 180) then center = 1 else center = 0 end path = "M300,"..(300 - R).." A"..R..","..R..",0,"..center..",1,"..x..","..y end return path end source : https://stackoverflow.com/questions/5230148/create-svg-progress-circle
  5. Hi, If I understand you are trying to create a circle path with a gradient ? I don't have an example to do it with DX functions and shaders but I figured out it's possible with SVG so I share it : <svg viewBox="0 0 600 600" xmlns="http://www.w3.org/2000/svg"> <defs> <linearGradient id="gradient"> <stop offset="5%" stop-color="#FF0000" /> <stop offset="95%" stop-color="#00FF00" /> </linearGradient> </defs> <path id="progress" fill="none" stroke="url(#gradient)" d="M300,50 A250,250,0,1,1,299.99,50" stroke-width="20" /> </svg> You can check this example via simulator : https://www.svgviewer.dev/ I'm not sure I helped you. Good evening
  6. Weird idea, why do you want to do this ?
  7. Mkl

    DGS

    Could be possible with properties, not sure. https://wiki.multitheftauto.com/wiki/Dgs-dxedit https://wiki.multitheftauto.com/wiki/Dgs-dxbutton
  8. Hi, Here is a fast test I did to create shade and stack effects, I don't really know if it's a proper way but it works : -- Some parametrable values local max_lines = 5 -- max lines (max stack) local timeToFade = 500 -- time to appear and disappear fade-effect (in ms) local timeToShow = 2000 -- time to plainly show the text local gap = 20 -- vertical gap between texts -- A variable to store texts local texts = {} function addText() -- in case we are in the column bottom, we don't reset the table until everything ended his display, -- including if we keep repeating the last one local is_last = true for _, v in ipairs(texts) do if not v.ended then is_last = false break end end -- nothing still displayed, we reset the table if is_last then texts = {} end -- if it's the last line, we stop the previous text if #texts == max_lines then removeEventHandler("onClientRender", root, texts[#texts].displayText) table.remove(texts, #texts) end -- New entry in the table, and local variable for short syntax texts[#texts + 1] = {} local text = texts[#texts] text.alpha = 0 -- alpha set to 0 text.firstCount = getTickCount() -- time reference text.state = 1 -- state use to situate the effect (1/2/3) (appearing/showing/vanishing) text.pos = #texts -- store his position -- function for onClientRenderEvent function text.displayText() if (text.state == 1) then -- showing fade effect text.count = getTickCount() - text.firstCount -- ratio between time and alpha value text.alpha = (text.count * 255) / timeToFade elseif (text.state == 2) then -- opac state text.alpha = 255 elseif (text.state == 3) then -- vanish fade effect text.count = timeToFade - (getTickCount() - text.firstCount) -- ratio between time and alpha value text.alpha = (text.count * 255) / timeToFade end text.y = 500 + (text.pos * gap) text.color = tocolor(255, 255, 255, text.alpha) dxDrawText("This is a test", 500, text.y, _, _, text.color) end addEventHandler("onClientRender", root, text.displayText) setTimer(function() -- first timer to opac state text.alpha = 255 text.state = 2 end, timeToFade, 1) setTimer(function() -- second timer to vanish fade effect text.state = 3 text.firstCount = getTickCount() end, timeToFade + timeToShow, 1) setTimer(function() -- last timer to the end removeEventHandler("onClientRender", root, text.displayText) text.ended = true -- bool to know this text finished to be displayed end, (timeToFade * 2) + timeToShow, 1) end addCommandHandler("somecmd", addText)
  9. Hi, I imagine you can begin that way : 1 - create a command associated to your function that'll do the job : -> addCommandHandler("foodtruck", theFunction) 2 - Inside your function, check if the player is in a vehicle -> getPedOccupiedVehicle ( thePlayer ) return vehicle element or isPlayerInVehicle(thePlayer) 3 - If the vehicle exist, check if the player has the driver seat -> getPedOccupiedVehicleSeat( thePlayer ) return int 0 for driver 4 - Then, take vehice's position-> getElementPosition(theVehicle) return 3 int x, y, z 5 - Finally, create a marker aside the vehicle by using vehicle's position -> like createMarker(x+5, y+5, z)
  10. Hi, could you use code blocks because it is unreadable. Like a tag in the nickname ? [TAG]Nickname ? You can check if the name of the player contains the tag by using string.find and then create markers.
  11. Would not be easier to use a Marker / onMarkerHit or a Colspahe / onColShapeHit ?
  12. Hi, I'm not sure to understand. Do you want, when a player starts a "lobby", a timeleft which stops the game when it reaches 0? If yes, why don't you use setTimer ? To display the time, I would have use getTickCount() instead of using getElementData everyframe. Check the second example of https://wiki.multitheftauto.com/wiki/GetTickCount that counts time, same logic can be used to create a timeleft to diplay.
  13. Should be function tpPlayerZ() Without source. You are overwriting the predefined source variable of the event with totalAmmo, first paramater of onPlayerWasted.
  14. I found out you can do something like this : addEventHandler("onClientPlayerDamage", root, function(attacker, damage) local health = getElementHealth(localPlayer) if (health - damage) < 1 then cancelEvent() setElementHealth(localPlayer, 1) -- your stuff (setElementFrozen() etc...) end end ) tested in-game. When the player recieves damage, if damage set health below 1, you cancel the event and you set 1 health point to the player. After this you can freeze him and set an animation. To really kill him, just need to use setElementHealth(localPlayer, 0).
  15. Hello, First I think you should use prefix local for health variable to make it working only in the scope of your function. I'm wondering if you could use onPlayerWasted instead, cancel the event (if it's cancellable) and set a custom animation ?
×
×
  • Create New...