Jump to content

csiguusz

Members
  • Posts

    500
  • Joined

  • Last visited

Posts posted by csiguusz

  1. Yes, every player can have his own table with his own datas of any kind.

    local data = {} 
      
    addEventHandler ( "onPlayerJoin", root, 
        function () 
            data [ source ] = {} 
        end ) 
      
    function setThings ( player ) 
        data[ player ].vehicle = createVehicle ( ... ) 
        data[ player ].timer1 = setTimer ( ... ) 
        data[ player ].timer2 = setTimer ( ...) 
        data[ player ].likes = "Trains" 
     end 
      
    addEventHandler ( "onPlayerQuit", root, 
        function () 
            data [ source ] = nil -- don't forget to clear a player's data after quitting to save memory and even kill his timers if needed 
        end )  
    

  2. Store the timers in a table for example.

    local timers = {} 
      
    function doSomething ( player ) 
        if isTimer ( timers[ player ] ) then 
            killTimer ( timers[ player ] ) 
        end 
      
        timers[ player ] = setTimer ( ... ) 
    end 
    

  3. Ha esetleg nem a legfrissebb admin lenne fönt szerveren, innen letöltheted a legfrissebb resource csomagot, aből frissítheted az admint, hogy biztos legyen, hogy nem a szkripttel van a gond: https://mirror.multitheftauto.com/mtasa/resources/

    És ha nem azzal van a gond akkor az ACL problémán kívűl más nem jut eszembe. Ellenőrizd, hogy a Console ACL csoportjában ott van-e a "command.unmute". Ha nem találod a hibát beteheted ide is az acl.xml-ed, megnézem én is vagy akár privátban is küldheted, ha nem akarod, hogy mindenki lássa.

  4. Ez is valami. Most nem vagyok gépnél, de később ránézek mi okozhat ilyen hibát.

    Edit:

    Megnéztem, az a hibaüzenet azért elég ritka esetekben állhat elő (Például ha valaki bejelentkezik, megnyitja a panelt, kijelentkezik, majd megpróbál csinálni valamit ). De az unmute-nak mennie kéne alapból. Az ACL-ben nem állítgattál dolgokat? A Console-nak megvannak a jogai?

    A next map-os dologhoz meg: hozzá kell adni a "Moderator" csoportot is a race modhoz, hogy neki is engedélyezve legyen az. A race meta.xml-jében vagy admin panel, resources fül, listából race-t kikeres, settings és ott van valami olyasmi, hogy admingroups. Na oda kell hozzáírni a Moderatort.

  5. Lehetne, hogy nem ilyen színnel írsz? Bántja a szememet.

    Alap adminpanelt használsz? Érdemes nézni a hibaüzeneteket, mikor unmute-olnia kéne. (/debugscript 3). Lehet ACL probléma pl., tehát hogy a szkriptnek nincs joga az unmute-hoz.

    Ugyanígy érdemes megnézni, hogy van-e hibaüzenet a Nex Map gombra való kattintáskor és akkor lenne mi alapján elindulni.

  6. Pedig csak a warpPedIntoVehicle függvénnyel lehet betenni egy pedet egy autóba... :)

    Itt egy egyszerű szerveroldali példa, hogy működik az. A /ped parancsra letesz egy pedet és ha beszállsz egy kocsiba melléd rakja, ha kiszállsz kiszedi.

    local ped 
    local owner 
      
    function create ( player ) 
        if not ped then 
            local x, y, z = getElementPosition ( player ) 
            owner = player 
            ped = createPed ( 123, x + 3, y, z ) 
             
            addEventHandler ( "onVehicleEnter", root, 
                function ( p ) 
                    if p == owner then 
                        warpPedIntoVehicle ( ped, source, 1 ) 
                    end 
                end)             
            addEventHandler ( "onVehicleExit", root,  
                function ( p ) 
                    if p == owner then 
                        removePedFromVehicle ( ped ) 
                    end 
                end) 
        end 
    end 
      
    addCommandHandler ( "ped", create ) 
    

  7. Mine would work perfectly except for that extra output, but I've corrected that. Yours wouldn't work at all. So there are different between mistakes, but I admit, that I also made a small one. :)

    Oh, and there wouldn't be any extra number at the output, since the number of the arguments isn't an indexed part of the table but it has a name 'n', and table.concat concatenate only indexed values.

  8. Have you tried it? ;)

    arg == { ... } 
    

    Edit:

    I've read after, just for you. I forgot that the hidden variable 'arg' has an extra value, wich is the number of the arguments passed to the function. So using that maybe wasn't a good idea, there might be an extra number at the output.

  9. Try this:

    function writetoID( player, command, id, ... ) 
        local plName = getElementByID ( 'ID' .. tostring(id) ) 
        if plName == nil then 
            outputChatBox ("??? ?????? ??? ???? ID.", player ) 
        else 
            local myName = tostring(getPlayerName(plName)) 
            local r,g,b = getPlayerNametagColor(plName) 
            local rn = string.format("#%02X%02X%02X", r,g,b) 
            local text = table.concat ( { ... }, " " ) 
            source = player 
            sendMSG( rn..''..myName..'#ffffff, ' ..text, 0 ) 
        end 
    end 
    addCommandHandler( 'n', writetoID ) 
    

    Edit:

    @tosfera: that won't work, text is not a table but a string, and every word is passed as a different argument to the handler function of the command, to catch all these arguments, you have to use '...' (three dots).

  10. And if I use,

    myTable={[1]=true} 
    

    then when i call myTable[1], It should return 'true' then it will be something like

    function someThing() 
    if true then -- as myTable[1] value is true. 
    .... 
    end  
    end 
    

    It is so confusing!

    What is confusing about it? myTable[1] will return the value of myTable at index 1. If it is 'true', then it will return true. But tables can be changed easly!

    For example, if you don't want to allow players to use the same skinf you could use something like this:

    local skins = {} 
      
    function setSkin ( player, skinID ) 
        if skins [ skinID ] then 
            outputChatBox ( "This skin is already in use!" ) 
        else 
            skins [ getElementModel ( player ) ] = false -- mark old skin as unused 
            skins [ skinID ] = true -- mark new skin as used 
            setElementModel ( player, skinID ) 
        end 
    end 
    -- note: this is just an example, not a really useful and perfect script 
      
    

    And you can extend it by adding options to it by using tables. A hardcoded "if true then" can't be changed by a script but a table value can be (or even manually by editing the file), so this is the difference between "if true then" and "if myTable[1] then"

    local skins = {} 
    local options = { 
        [ "skinChange" ] = false 
    } 
      
    function setSkin ( player, skinID ) 
        if options.skinChange then -- or options["skinChange"], but using . (dot) is a bit more efficient 
            if skins [ skinID ] then 
                outputChatBox ( "This skin is already in use!", player ) 
            else 
                skins [ getElementModel ( player ) ] = false -- mark old skin as unused 
                skins [ skinID ] = true -- mark new skin as used 
                setElementModel ( player, skinID ) 
            end 
        else 
            outputChatBox ( "Sorry, changing skin is not allowed!", player ) 
        end 
    end 
    -- note: this is just an example, not a really useful and perfect script 
    

  11. name1 = "Sam ß Winchester" --==> Wrong! 
    name2 = "Sam% Wichester"    --==> Wrong! 
    name3 = "Sám Wínchestér" --==> Wrong! 
    name4 = "Sam Winchester"    --==> Ok! 
    name4 = "Robert J Thommas"    --==> Ok! 
      
    function isValid ( name ) 
        name = name:upper () 
        for char in name:gmatch ( "." ) do 
            local code = char:byte () 
            if (code < 65 or code > 90) and code ~= 32 then 
                return false 
            end 
        end 
        return true 
    end 
      
    outputChatBox ( tostring ( isValid ( name1 ) ) ) 
    outputChatBox ( tostring ( isValid ( name2 ) ) ) 
    outputChatBox ( tostring ( isValid ( name3 ) ) ) 
    outputChatBox ( tostring ( isValid ( name4 ) ) ) 
    

  12. myTable = {} is the same as myTable = nil. The garbage collector at the next cycle will clear the memory used by the table in both cases. The only difference is that if you used nil, and want to use the variable again as a table you have to declare it again like myTable = {}.

×
×
  • Create New...