Jump to content

Tails

Members
  • Posts

    740
  • Joined

  • Days Won

    16

Everything posted by Tails

  1. local screenW, screenH = guiGetScreenSize() local countdown function initTimer() if not isTimer(countdown) then -- make sure you can only start it once countdown = setTimer(countdownFin, 5000, 1) end end addCommandHandler("asd", initTimer, false, false) function countdownFin() removeEventHandler("onClientRender", root, eventszamlalas) end function eventszamlalas() local x = getTimerDetails(countdown) local timeLeft = math.ceil(x/1000) dxDrawLine((screenW * 0.4111) - 1, (screenH * 0.1244) - 1, (screenW * 0.4111) - 1, screenH * 0.1589, tocolor(254, 254, 254, 255), 1, false) dxDrawLine(screenW * 0.6118, (screenH * 0.1244) - 1, (screenW * 0.4111) - 1, (screenH * 0.1244) - 1, tocolor(254, 254, 254, 255), 1, false) dxDrawLine((screenW * 0.4111) - 1, screenH * 0.1589, screenW * 0.6118, screenH * 0.1589, tocolor(254, 254, 254, 255), 1, false) dxDrawLine(screenW * 0.6118, screenH * 0.1589, screenW * 0.6118, (screenH * 0.1244) - 1, tocolor(254, 254, 254, 255), 1, false) dxDrawRectangle(screenW * 0.4111, screenH * 0.1244, screenW * 0.2007, screenH * 0.0344, tocolor(0, 0, 0, 161), false) dxDrawText("Az event elkezdődött! Vége: "..convertSecondsToMinutes(timeLeft), screenW * 0.4118, screenH * 0.1244, screenW * 0.6118, screenH * 0.1589, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) end function convertSecondsToMinutes(sec) local temp = sec/60 local temp2 = (math.floor(temp)) local temp3 = sec-(temp2*60) if string.len(temp3) < 2 then temp3 = "0"..tostring(temp3) end return tostring(temp2)..":"..tostring(temp3) end Does now. Try it
  2. @Necktrox Getting connected, authorized and everything. Everything's set up correctly but the bot's not joining my discord channel. Am I missing something?
  3. Did you use setTimer() ? If so you can just do local secs = getTimerDetails(theTimer)/1000 https://wiki.multitheftauto.com/wiki/GetTimerDetails
  4. Tails

    cancelEvent

    addEventHandler ( "onClientChatMessage", root, function ( text ) if string.find(text, "login:") then cancelEvent() end end) Are you trying to block a message from being outputted from the default login system or from a script? I'm not sure if you can but normally the above example should work.
  5. It looks good but personally I think it's annoying to have to switch back and forth between the different tabs every time. I prefer to see the warnings and errors in one place at the same time. Some suggestions... Add a tab that shows any type of message Combine identical messages to avoid spam
  6. You have to set its interior. For example: setElementInterior(sound, 1)
  7. Thanks @Apocalypso! Lots of bugs I hear =[ While we don't currently have time to work on this project we definitely appreciate you reporting these bugs! I've had a new version laying around for quite a while, unsure if I'll finish it anytime soon but I will make sure these bugs will have been completely fixed when I finish it. Thanks again!
  8. I hope this is what the OP is looking for function getTopScores() local scores = {} for plr, v in pairs(exampleTable) do table.insert(scores, {name = getPlayerName(plr), kills = v.kills} end table.sort(scores, function(a, b) return a.kill > b.kill end) return scores end local scores = getTopScores() outputChatBox("Top scorer is "..scores[1].name.." with "..scores[1].kills.." kills!") It creates a list with the names and kills of each player in your table then sorts it by the kills. Then you can output the first one in the list or all of them put them in a grid list or something. To avoid that you should just create a new table. Hope this helps everyone
  9. Tails

    eventhandler

    @3laa33 I think he wants it toggled. Your example will throw an error because it's trying to remove a handler that doesn't yet exist.
  10. Tails

    eventhandler

    No, yours is just the opposite. You want a bool that says IsPanelVisible, if it is then remove the handler. We know the panel is not visible at the start so we do local isContactOpened = false then onClick we check, is it opened? if it's not then we add the handler to show the panel and vice versa. Nice try though
  11. Tails

    eventhandler

    local isContactOpened = false addEventHandler("onClientClick", root, function(key, state, cx, cy) if key == "left" and state == "down" then if isCursorInBox(screenW * 0.4729, screenH * 0.3130, screenW * 0.0953, screenH * 0.0269) then if isContactOpened then removeEventHandler("onClientRender",getRootElement(),contactBTN) isContactOpened = false else addEventHandler("onClientRender",getRootElement(),contactBTN) isContactOpened = true end end end end) You're welcome.
  12. Yeah, I just replaced the positions table with the sorted one, and then removed the first position. If you want to reuse the positions you could instead of removing the position, add use new variable that stores the current position index. Then every time you hit a marker you add 1 to it till you get to the end then you reset it.
  13. Oops an error. It was too late to edit it. for i=1, #sorted do positions[i] = v.pos end -- should be for i=1, #sorted do positions[i] = sorted[i].pos end
  14. Try this (untested) function getPosNearPlr(plr) local sorted = {} local x, y, z = getElementPosition(plr) for i, v in ipairs(positions) do local d = getDistanceBetweenPoints3D(x, y, z, v[1], v[2], v[3]) sorted[i] = {pos = v, dist = d} end table.sort(sorted, function(a, b) return a.dist < b.dist end) for i=1, #sorted do positions[i] = v.pos end table.remove(positions, 1) return sorted[1].pos end local pos = getPosNearPlr(localPlayer)
  15. Tell us exactly what you're trying to do. We need more information. It looks like you're trying to place a marker at the nearest position to the player? I can write you an example but it might not be what you want.
  16. Tails

    dxDrawImage

    You need to render it on screen for every frame with this event: addEventHandler("onClientRender", root, function() dxDrawImage (x/2, y/2, 500, 500, "assets/death.png") end)
  17. Tails

    Complie

    He's trying to compile his code... not share it with the world.
  18. Tails

    God mode

    https://wiki.multitheftauto.com/wiki/Damage_Types
  19. You don't need an expert scriptor for a simple freeroam with simple fun scripts. Just spend some time looking at other scripts and create your own. It's really easy. Check out this wiki page: https://wiki.multitheftauto.com/wiki/Scripting_Introduction If you have any scripting related questions, feel free to post them here.
  20. Tails

    Grid List Help

    Because what you're doing is, for every row loop through all the rows in the gridlist and set the table value to each of them. what you want to do is do it all in a single loop and maybe redo your table. Maybe something like this: local vehs = { {model = 411, mod = 4, price = 12000}, -- 1 {model = 411, mod = 4, price = 12000}, -- 2 etc.. } for i, v in pairs (vehs) do local row = guiGridListAddRow ( GUIEditor.gridlist[1], getVehicleNameFromModel(v.model), v.mod, v.price) guiGridListSetItemData ( GUIEditor.gridlist[1], row, 1, v.model) end Also in 1.5.2 or so, they introduced an alternative easier way to set the text of a row for each column, the syntax is like this: int guiGridListAddRow ( element gridList, int/string itemText1, int/string itemText2, ... ) where itemText1 is for column 1 and itemText2 for column 2 and so on.
  21. A small example code would be nice. I don't see any way why guiStaticImageLoadImage won't work. Instead of destroying and recreating the gui try toggle their visiblity: guiSetVisible(element, not guiGetVisible(element))
  22. @Fist, there's also this one: https://community.multitheftauto.com/index.php?p=resources&s=details&id=12141 which removes the light from every street light and this one's kind of cool if you were looking for something like that too: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11139
  23. Cool. I just noticed a made a minor mistake in the draw although you probably won't use it since you're already drawing the list. It should be: addEventHandler("onClientRender", root, function() local y = 0 for i=1,#sorted do y = i > 1 and y + 10 or y dxDrawText("Name: "..sorted[i].name.." Money: "..sorted[i].money, 142, 370 + y, 610, 405, tocolor(34, 220, 60, 255), 1.25, "default", "left", "top", false, false, false, false, false) end end)
×
×
  • Create New...