Jump to content

undefined

Members
  • Posts

    500
  • Joined

  • Last visited

Posts posted by undefined

  1. function setSpeed(vehicle, velocity, vz) 
         local _,_,rz = getElementRotation(vehicle) 
         rz = rz - math.floor(math.fmod(rz, 90)) * 90 
      
         local rad = math.rad(90 - rz) 
         vx, vy = math.cos(rad) * velocity, math.sin(rad) * velocity 
      
         setElementVelocity(vehicle, vx, vy, vz or 0) 
    end 
    

    function backwards() 
         if isPedInVehicle (localPlayer) then 
              local veh = getPedOccupiedVehicle(localPlayer) 
              if getElementModel(veh) == 498 then 
                   toggleControl ( "brake_reverse", false ) 
                   local vx,vy,vz = getElementVelocity(veh) 
                   local speed = vx + vy 
                   setSpeed(veh, speed - 0.2, vz) 
              end 
         end 
    end 
    bindKey("s", "down", backwards) 
    

    Try it (not tested)

  2. gui["grid"] = guiCreateGridList(10, 45, 319, 155, false, gui["window"]) 
    guiGridListAddColumn(gui["grid"], "column 1", 0.43) 
    guiGridListAddColumn(gui["grid"], "column 2", 0.23) 
    guiGridListAddColumn(gui["grid"], "column 3", 0.23) 
      
    guiSetProperty(gui["grid"], "ColumnsSizable", "False") 
    guiSetProperty(gui["grid"], "ColumnsMovable", "False") 
    

    ColumnsSizable is work but ColumnsMovable is not work. Not give anything in debug. What is the problem? :roll:

  3. Try putting the toJSON in single quotes.
    local database = dbConnect("sqlite", "parchement.db") 
    dbExec(database, "CREATE TABLE IF NOT EXISTS parchement (account_name TEXT, parchement TEXT DEFAULT '"..toJSON({}).."')") 
    

    I'm honestly not sure if this will fix the problem though.

    Solved, thank you. :)

  4. local database = dbConnect("sqlite", "parchement.db") 
    dbExec(database, "CREATE TABLE IF NOT EXISTS parchement (account_name TEXT, parchement TEXT DEFAULT "..toJSON({})..")") 
    

    WARNING: system\save\save.lua:2: dbExec failed; (1) unrecognized token: "]"

    Where is the problem?

  5. swatpeds = { 
         { 
              ped = nil, 
              arguements = {285, 1572.2216796875, -1626.880859375, 13.3828125, 90}, -- model,x,y,z,rotation 
              weapon = { 
                   id = 31, 
                   ammo = 5000, 
                   setAsCurrent = true 
              }, 
              special_function = function(ped) 
                  -- eg. setPedHeadless(ped, false)  
                   -- TO DO 
              end 
         }, 
         { 
              ped = nil, 
              arguements = {285, 1544.6943359375, -1621.15234375, 13.55456161499, 90}, 
              weapon = { 
                   id = 31, 
                   ammo = 5000, 
                   setAsCurrent = true 
              }, 
              special_function = function(ped) 
                   -- eg. setPedHeadless(ped, true)  
                   -- TO DO 
              end 
         } 
    } 
      
    for i, data in ipairs(swatpeds) do 
         local ped = createPed(unpack(data.arguements)) 
         giveWeapon(ped, data.weapon.id, data.weapon.ammo, data.weapon.setAsCurrent) 
      
         if type(data.special_function) == "function" then 
              data.special_function(ped) 
         end 
      
         data.ped = ped 
    end 
    

    You can reach peds with:

    swatpeds[1].ped 
    swatpeds[2].ped 
    ... 
    

  6. local sounds = {} 
    addEventHandler("onClientVehicleEnter", root, function(thePlayer, seat) 
        if seat ~= 0 then return end 
        local vehicle = getPedOccupiedVehicle(thePlayer) 
        if getElementModel(vehicle) == 480 then 
            sounds[thePlayer] = playSound3D("files/engine.wav",0,0,0, true) 
            setSoundMaxDistance(sounds[thePlayer], 50) 
            setSoundVolume(sounds[thePlayer], 1) 
            attachElements(sounds[thePlayer], vehicle) 
        end 
    end) 
      
    addEventHandler("onClientVehicleExit", root, function(thePlayer, seat) 
        if isElement(sounds[thePlayer]) then 
            stopSound(sounds[thePlayer].sound) 
        end 
    end) 
    

    Server-side is needless. Because the event is already attached to root. Try it.

  7. Try it

    function wasted (player) 
            if not isElement(player) then return end 
            local x, y, z = -1284.8974609375, 452.08203125, 7.1875 
            local lvl = getElementData(player,"Level") 
            if (lvl >= 0) then 
            spawnPlayer (player, x, y, z ) 
            fadeCamera( player, true) 
            setCameraTarget( player, player) 
            end 
    end 
      
    addEventHandler ( "onPlayerWasted", root, function() 
         setTimer(wasted, 3000, 1, source) 
    end) 
    

  8. Try it.

    local bombs = {} 
      
    function attach(playerSource, commandName) 
          --if bombs[playerSource] then return end 
          local theVehicle = getPedOccupiedVehicle ( playerSource ) 
         if theVehicle then 
            
              local x,y,z = getElementPosition(theVehicle) 
              local rx,ry,rz = getVehicleRotation(theVehicle) 
            
              if not bombs[playerSource] then 
                   bombs[playerSource] = {} 
              end 
      
              bombs[playerSource].missle = createObject(3786,x,y,z,rx,ry,rz) 
              bombs[playerSource].occVehicle = theVehicle 
      
         attachElements(bombs[playerSource].missle,bombs[playerSource].occVehicle,0,0,-1.1,0,0,-90) 
         end 
    end 
      
      
    function detach(playerSource, commandName) 
         local p_tbl = bombs[playerSource] 
         if not p_tbl then return end 
      
         local theVehicle = getPedOccupiedVehicle ( playerSource ) 
         if theVehicle and theVehicle == p_tbl.occVehicle then 
            
              local x,y,z = getElementPosition(playerSource) 
              local rx,ry,rz = getVehicleRotation(theVehicle) 
              local vx,vy,vz = getElementVelocity(theVehicle) 
            
              detachElements(p_tbl.missle) 
              p_tbl.fallveh = createVehicle(602, x,y,z-2,180,0,rz) 
              setElementVelocity(p_tbl.fallveh,vx,vy,vz) 
              --setElementAlpha ( p_tbl.fallveh, 0 ) 
      
         attachElements(p_tbl.missle,p_tbl.fallveh,0,0,0,0,0,270) 
         end 
    end 
      
    addEventHandler("onVehicleDamage", root, function() 
         for player, tbl in pairs(bombs) do 
              if tbl.fallveh == source then 
                   if isElement(tbl.fallveh) then 
                        blowVehicle(tbl.fallveh) 
                   end 
                   bombs[player] = nil 
                   return 
              end 
         end 
    end) 
      
    addCommandHandler("a", attach) 
    addCommandHandler("d", detach) 
    

  9. GUIEditor.button[2] = guiCreateButton(10, 147, 77, 34, "Pistol\n300$:1 LVL", false, GUIEditor.window[1]) 
      
    addEventHandler("onClientGUIClick", guiRoot, function(button, state, absoluteX, absoluteY) 
         if source == GUIEditor.button[1] then 
              guiSetVisible(GUIEditor.window[1] , false) 
              showCursor(false) 
         elseif source ==  GUIEditor.button[2] then 
              guiSetEnabled(source, false) 
         end 
    end) 
    

  10. addEvent("onZombieSpawn", true) 
    function extrah() 
         if getElementData(source, "zombie") then -- not necessary 
              if getElementModel(source) == 162 then 
                   exports.extrahealth:setElementExtraHealth(source, 500) 
              end 
         end 
    end 
    addEventHandler("onZombieSpawn", root, extrah) 
    

  11. addEvent("onZombieSpawn", true) 
    function extrah() 
         if getElementData(source, "zombie") then -- not necessary 
              if getElementModel(source) == 162 then 
                   exports.extrahealth:setElementExtraHealth(source, 500) 
              end 
         end 
    end 
    addEventHandler("onZombieSpawn", root, extrah) 
    

×
×
  • Create New...