Jump to content

csiguusz

Members
  • Posts

    500
  • Joined

  • Last visited

Posts posted by csiguusz

  1. A loop?

    local markers = { 
        createMarker ( ... ), 
        createMarker ( ... ), 
        createMarker ( ... ) 
    } 
      
    for i, v in ipairs ( markers ) do 
        setElementParent ( v, ele ) 
    end 
    

  2. 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. 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).

  4. table.remove uses table index, so instead of 'vehicle8' you would need to use '3'.

    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 
    

  5. 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) 
    

  6. 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.

  7. 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.

  8. 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 ) 
    

  9. Yes, you can. Here is a simple example:

    addCommandHandler ( "online", 
        function () 
            for i, v in ipairs ( getElementsByType ( "player" ) ) do 
                outputChatBox ( getPlayerName ( v ) ) 
            end 
        end ) 
    

  10. --automatikusan hozzárendel egy táblát a generált globális táblákhoz, teszteletlen, de elvileg működnie kell 
    ( esetleg a metódusokat exportolni kell és az exportokra hivatkozni a táblákban, de ha valaki ezeket figyelembe véve írja az egész kódot, akkor no problemo ) 
    setmetatable (_G,{ __newindex = function ( self, i, v ) 
    if type ( v ) == "table" then 
    rawset ( _G,i,v._meta and setmetatable(v,exports.gmeta:get(v._meta) or v ) 
    else 
    rawset(_G,i,v) 
    end 
    end 
    

    az if kinézhet úgy is, hogy az első fele a class funkcióit keresi (class inheritance indices), míg a második az object-ek számára keres az osztályon belül. (class root index)

    remélem értelmesen magyaráztam

    ha nem az se baj

    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.

  11. É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.

  12. 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") 
    

  13. 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) 
    

  14. 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) 
    

  15. 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...