Jump to content

SDK

Members
  • Posts

    635
  • Joined

  • Last visited

Posts posted by SDK

  1. Some suggestions I came up with that would be a big improvement over the default debug console:

    + reload log on join so you can see what happened before you joined or what happens on /reconnect

    + view the debug of other clients

    + toggle to prevent spam like suggested earlier

  2. Tried something, not tested but hoping to give you a general idea.

    Arenas = {} 
    Arenas.selected = nil 
      
    -- ... 
      
    addEventHandler("onClientRender",root, function() 
        local isAnyArenaSelected = false 
         
        for i, arena in pairs(Arenas) do 
            local r, g, b = getColorFromString(getElementData(arena.Element, "color")) 
            arena.Color = tocolor(r, g, b, 255) 
      
            dxDrawRectangle ( arena.x, arena.y, arena.size, arena.height, arena.Color, true) 
             
            local mx, my = getCursorPosition() 
            hover = mouseCheck(mx, my, arena.x, arena.x+arena.size, arena.mouseY, arena.mouseY+arena.height) 
      
            if hover == true then 
                isAnyArenaSelected = true 
                if not Arenas.selected then 
                    -- preset animation when mouse is over arena 
                    selectArena(arena) 
                end 
            end 
        end 
         
        if not isAnyArenaSelected and Arenas.selected then 
            -- preset animation when mouse isn't over any arena and there is still one selected 
            selectArena( nil ) 
        end 
    end) 
      
    function selectArena(arena) 
        Arenas.selected = arena 
        -- this function prepares all new positions and sizes when an arena is (de)selected 
        for i, a in pairs(Arenas) do 
            if arena == nil then 
                -- no arena selected, move back to default size and position 
                arena.next_y = ... 
                arena.next_height = defaultArenaHeight 
            elseif a == arena then 
                -- this is the selected arena, maximum height 
                arena.next_y = ... 
                arena.next_height = MaxArenaHeight 
            else 
                -- this is an arena that needs to be minimized 
                arena.next_y = ... 
                arena.next_height = defaultArenaHeight * NumArenas - MaxArenaHeight 
            end 
        end 
    end 
      
    setTimer(function() 
        -- this timer moves y and height up to their next_ value 
        for i, arena in pairs(Arenas) do 
            if (arena.next_y and arena.y ~= arena.next_y) then 
                if arena.y < arena.next_y then 
                    arena.y += 1 
                else 
                    arena.y += -1 
                end 
            end 
            if (arena.next_height and arena.height ~= arena.next_height) then 
                if arena.height < arena.next_height then 
                    arena.height += 1 
                else 
                    arena.height += -1 
                end 
            end 
        end 
    end, 100, 0) 
    -- 100 can be used to change the animation speed 
      
    

    If you're still having trouble I would recommend adding one feature at the time to your script. Use GUI Images and use clicks (OnClientGUIClick) instead of hovering to keep it simple and have something that works. Afterwards you can modify that to use onClientMouseEnter/Leave for hover or back to dxDraw functions.

  3. Some small mistakes

    fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) 
    fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) 
    fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) 
      
    function lockfbi(player, seat, jacked) 
        if (source == fbi1 or source == fbi2 or source == fbi3) then 
            local skin = getElementModel (player) 
            if ( skin == 100 or skin == 255) then 
                 cancelEvent() 
                 outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) 
            end 
        end 
    end 
    addEventHandler ( "onVehicleStartEnter", getRootElement(), lockfbi ) 
    

  4. There's no real function for it yet, but there's an note here:

    https://wiki.multitheftauto.com/wiki/SetObjectStatic (replaced with setElementFrozen)

    Note2: Dynamic objects with a "destroyed" state are still destroyable. Use isElementOnScreen to detect, destroy, and recreate these objects.

    So you could use onClientRender and isElementOnScreen to recreate the broken objects. As an extra you could run a timer which recreates every object every 5 seconds, depending on how important the objects are.

  5. Yes, has been awhile since used sqlite im afraid :fadein:

    The first query was wrong:

    "CREATE TABLE tempTable AS SELECT DISTINCT * FROM originalTable" 
    "DROP TABLE originalTable" 
    "ALTER TABLE tempTable RENAME TO originalTable" 
    

    I tested it on a commandline and it worked, no duplicates.

  6. function killMe (thePlayer) 
        if (thePlayer) then 
            setTimer (killPed, 10000, 1, thePlayer) 
            outputChatBox("You will be killed in 10 seconds.", thePlayer, 255, 0, 0) 
        end 
    end 
    addCommandHandler ("kill", killMe) 
    

  7. while not setElementModel (localPlayer,newSkin) do newSkin = newSkin + 1 end 
    triggerServerEvent ("skin", localPlayer, newSkin) 
    

    This will first find a skin to the left/right, and then send it to the server

    Edit: ninja

  8. Another way is using SELECT DISTINCT, which only selects unique rows and skips the duplicates, to create a (fixed) new db.

    "SELECT DISTINCT * INTO newtable FROM oldtable" 
    

    Then drop (delete) the original table

    "DROP TABLE oldtable" 
    

    and rename the new table to the old one.

    "ALTER TABLE newtable RENAME TO oldtable" 
    

    (Found this after some googling, I'd expect it to work, but didn't test it so make sure you backup your database first)

  9. Because you changed the indexes of the table, the table should be formatted this way

    local musics = { 
            [1] = { 'David Guetta - Where Dem Girls At', 'http://199.167.195.194/wdga.mp3'}, 
            [2] = { 'Coldplay - Paradise', 'http://199.167.195.194/pd.mp3'}, 
            [3] =  
    ... 
    } 
      
    local themusic = musics[math.random(#musics)] 
    local file = themusic[2] 
    local title = themusic[1]  
    

  10. My code was meant to replace the setVehicleDamageProof line in the solution by solidsnake.

    But since your making a map, it's easier to do this:

    addEventHandler("onVehicleDamage", root, function() 
        cancelEvent() 
    end) 
    

    Root means all vehicles

  11. I've got experience with the race resource, so I already knew where to look.

    I searched the race script with n++'s "Search in files" feature for "setVehicleDamageProof". Found this in race\modes\base.lua:

    -------------------------------------- 
    -- For use when starting or respawing 
    -------------------------------------- 
      
    function RaceMode.playerUnfreeze(player, bDontFix) 
        if not isValidPlayer(player) then 
            return 
        end 
        toggleAllControls(player,true) 
        clientCall( player, "updateVehicleWeapons" ) 
        local vehicle = RaceMode.getPlayerVehicle(player) 
        if not bDontFix then 
            fixVehicle(vehicle) 
        end 
        setVehicleDamageProof(vehicle, false) 
        setVehicleEngineState(vehicle, true) 
        setElementFrozen(vehicle, false) 
      
        -- Remove things added for freeze only 
        Override.setCollideWorld( "ForVehicleJudder", vehicle, nil ) 
        Override.setCollideOthers( "ForVehicleSpawnFreeze", vehicle, nil ) 
        Override.setAlpha( "ForRespawnEffect", {player, vehicle}, nil ) 
        Override.flushAll() 
    end 
    

    And another question, how did you test or found out that race is overriding the function?

    (for my debugging methodes in the future)

    It's easier to debug without other (not important) resources running. Make sure your script works, then test it out with other resources.

    The best way to find out if/which resource is interfering, is to stop them all (or the one's you think will give you problems) so you know there's nothing wrong with your script. Then enable them one by one and test to find it.

  12. Try testing the script with the default freeroam mode, it could be that race is messing with it.

    (Also, one small improvement, but it won't change your problem)

    addEventHandler ( "onVehicleEnter", root, 
    function () 
        setVehicleDamageProof ( source, true ) 
        if ( isVehicleOnGround ( source ) ) then 
            outputChatBox (getVehicleName ( source ) .. " is on the ground and made GOD-like") 
        else 
            outputChatBox (getVehicleName ( source ) .. " is in the air and made GOD-like") 
        end 
    end) 
    

    Edit: I checked and race overrides your setVehicleDamageProof every time you get unfrozen after spawning, and there's no easy way to work around it.

    Better would be to cancel the onVehicleDamage event:

    addEventHandler("onVehicleDamage", source, function() 
        cancelEvent() 
    end) 
    

×
×
  • Create New...