Jump to content

csiguusz

Members
  • Posts

    500
  • Joined

  • Last visited

Everything posted by csiguusz

  1. csiguusz

    Markers

    A loop? local markers = { createMarker ( ... ), createMarker ( ... ), createMarker ( ... ) } for i, v in ipairs ( markers ) do setElementParent ( v, ele ) end
  2. csiguusz

    Markers

    Read the wiki page. What you make with that function won't be a real entity in the world, it will youst behave like an element. Eg.: local marker1, marker2 = createMarker ( ... ), createMarker ( ... ) local ele = createElement ( "markers" ) setElementParent ( marker1, ele ) setElementParent ( marker2, ele ) addEventHandler ( "onMarkerHit", ele, function () outputChatBox ( "hit" ) end ) Edit: Great! You are welcome.
  3. csiguusz

    Markers

    Create a dummy element with createElement and set this elemenet as parent of your markers with setElementParent. Then define your onMarkerHit event handler attached to the dummy element.
  4. OOP is an acronym of Object Oriented Programming, wich is a programming paradigm and not a language. Freeroam was also written in lua as every other scripts. It has a kind of gui "engine" wich builds the windows from the data given in a table. You have to add te abillity to fad in/out windows to this engine to make what you want (gui.lua file).
  5. But if you don't know the index of the value you want to remove, then loop through the table to find it. (note: if you use "table" as a variable name it overwrites the global "table", so you can't use table.remove and other table functions.) for i, v in ipairs ( t ) do if v == vehicle8 then table.remove ( t, i ) end end
  6. You had a few mistakes. Try this: local sX, sY = guiGetScreenSize() function test2 () dxDrawRectangle(sX/4, sY/4, sX/8, sY/8, tocolor(0,255,0,255), false) showCursor(true) end addEventHandler("onClientRender", root, test2 ) function test ( button, state, x, y ) if (button == 'left' or button == 'right' or state == 'down') then local checkX = ( x > sX/4 and x < 2*sX/4-sX/8 ) local checkY = ( y > sY/4 and y < 2*sY/4-sY/8 ) if ( checkX and checkY ) then outputChatBox("true") end end end addEventHandler("onClientClick", root, test)
  7. The onPlayerWasted event handler isn't attached to the function wich you marked as "not working" and the first parameter passed to the handler function of onPlayerWasted is not a player (read it's wiki page). The source is a hidden variable, it musn't be in the parameter list. Both of these should give you an error message in debugscript so I suppose you haven't used it while debugging.
  8. Rossz hír, de várható volt sajnos az utóbbi idő (nem)történései alapján. Amit írtál már nem igazán az én területem, most maradok mta-nál, aztán majd lehet megnézem mit tudnék kihozni a eddigi kódból.
  9. So you want more names in a line? local charLimit = 50 -- maximum charachters in a line addCommandHandler ( "online", function () local line = {} local currLength = 0 for i, v in ipairs ( getElementsByType ( "player" ) ) do local name = getPlayerName ( v ) if currLength + #name > charLimit then outputChatBox ( table.concat ( line, ", " ) ) line = {} currLength = 0 end table.insert ( line, name ) currLength = currLength + #name end end )
  10. Yes, you can. Here is a simple example: addCommandHandler ( "online", function () for i, v in ipairs ( getElementsByType ( "player" ) ) do outputChatBox ( getPlayerName ( v ) ) end end )
  11. local onlinePlayers = {} for i, v in ipairs ( getElementsByType ( "player" ) ) do table.insert ( onlinePlayers, v ) end
  12. It would be more helpful if you didn't just say "it's not working" but say what is it doing instead (e.g what's the error message if there is one). By the way, there is no function called "SetCameraMatrix", use setCameraMatrix. And playerid is not defined, use getLocalPlayer. Edit: oh, and "GetCameraMatrix" is also wrong.
  13. local stats = { {69,22}, {70,23}, {71,24}, {72,25}, {73,26}, {74,27}, {75,28}, {76,29}, {77,30}, {78,31}, {79,34} }
  14. Ez jó ötlet, hasznos lehet, viszont a globális tár a modularitás szempontjából nem jó ötlet. Valahogy lokálisabban (exportált függvények használata nélkül) kéne megoldani resource-onként. Penlighthoz: ahogy mondod, tiszta lua "mindössze" az io, os, package library-ket és a require-t kéne valahogy helyettesíteni. De ha az működik, ami kell, akkor nincs gond. Az pedig miért is lenne jó, a második kódrészlet, amit írtál? Arra kérnék egy kis magyarázatot. A self például mindig t lesz, tehát az a feltétel sosem fog teljesülni. A self-nek akkor van értelme, ha van egy külön __index kezelő fügvény és azt tesszük a metatáblákba. Az angol szavakhoz: pár szó jelentésének azért nem árthat utánanézni, még tanulhat is az ember. Itt az inheritation-t öröklődésnek szokták hívni. Az invoke-nak nem tudom ebben az esetben mi a hivatalos magyar megfelelője (ha van egyáltalán) de akkkor legyen használ/bevon. A metametódus meg csúnyán hangzik, de a method az metódus magyarul.
  15. onPlayerJoin --event --then setCameraMatrix --for moving use the above function with this event: onClientPreRender
  16. "onClientKey" event is client-sided only and the account functions are only for server-side.
  17. Global functions defined in file1 can be used in file2 if file1 is loaded before file2 in the meta.xml.
  18. You can create just rows of text, it is called a label. What do you mean by useful funtions? Create the gridlist, add columns, add rows, set the texts.
  19. És akkor exportálni a függvényeket a másik resource-ból? Itt az oop-sek elég csúnyán néznének ki, ha egyáltalán lehetne exportálva használni őket. Line of sight check mire fog kelleni? Penlight meg mta-ban nem fog menni alapból, de nem tudom akarjuk-e ott használni. Végre! Dxgui! Azt szeretem. Elkezdtem korábban egyet csinálni, csak aztán nem folytattam, lehet majd nekiállok megint.
  20. Egészen szép a kód, ahogy így átfutottam! De majd azért lenne még pár kérdésem, javaslatom. Ehhez a scite-mta dologhoz: a globális környezet ( _G ) megváltoztatásával könnyen meg lehetne oldani, hogy ugyanaz a kód fusson mindkét helyen. Például minden kiírásnál csak outputChatBoxot vagy printet használni és lenne egy fájl, amit elsőnek kéne betölteni, ami ellenőrzi hogy most ez mta vagy nem ( már megvan az isMTA függvény ), aztán az alapján változtat a függvényeken. Pl.: function print_MTA ( ... ) for i, v in ipairs ( arg ) do outputChatBox ( tostring ( v ) ) end end function require_MTA ( filePath ) assert ( fileExists ( filePath ), filePath .. " not found!" ) -- itt még akár a meta.xml-t megnyitva a jó sorrendet is ellenőrizheti. end if isMTA () then _G.print = print_MTA _G.require = require_MTA end print("test")
  21. Then you have to brake it into lines by yourself. My solution: function linebreak ( t ) local line = "" local newTable = {} local i = 1 while i <= #t do while line:len () <= 120 and i <= #t do -- I'm not sure what is the character limit. You can try changing the value 120. line = line .. t[ i ] i = i + 1 end newTable[ #newTable + 1 ] = line line = "" end return newTable end local commandsTable = {} local commandsXML = xmlLoadFile("commands.xml") for index,node in pairs(xmlNodeGetChildren(commandsXML)) do if xmlNodeGetName(node) == "command" then checkSound(xmlNodeGetAttribute(node,"sound")) commandsTable[ #commandsTable + 1 ] = colorCode.." /"..xmlNodeGetAttribute(node,"commandName")..textColor end end commandsTable = linebreak ( commandsTable ) addCommandHandler("chatcommands", function(player) outputChatBox(colorCode.."# "..textColor.."Available chatcommands:",player,255,255,255,true) for i, v in ipairs ( commandsTable ) do outputChatBox ( v, player, 255, 255, 255, true ) end end)
  22. Read the commands into a table, and then output them from here, only one command for one outputChatBox. local commandsTable = {} local commandsXML = xmlLoadFile("commands.xml") for index,node in pairs(xmlNodeGetChildren(commandsXML)) do if xmlNodeGetName(node) == "command" then checkSound(xmlNodeGetAttribute(node,"sound")) commandsTable[ #commandsTable + 1 ] = colorCode.." /"..xmlNodeGetAttribute(node,"commandName")..textColor end end addCommandHandler("chatcommands", function(player) outputChatBox(colorCode.."# "..textColor.."Available chatcommands:",player,255,255,255,true) for i, v in ipairs ( commandsTable ) do outputChatBox ( v, player, 255, 255, 255, true ) end end)
  23. Annyit én se érek rá most mint korábban, de persze szinte minden nap ráérnék valamennyit foglalkozni a dologgal. (Igen, azért jóval gyorsabb mert az C-ben van megvalósítva. Sok alap lua függvényt meg lehetne írni luában is, csak semmi értelme, mivel szinte biztos, hogy sokkal lassabb lenne.) Itt a letölthető SDK a modulokhoz Mikrofonnal pedig egyszerűbb lenne, de akkor marad az írás.
×
×
  • Create New...