Jump to content

Hydra

Members
  • Posts

    340
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by Hydra

  1. 5 hours ago, lilwayn said:

    Hello @alex17" thanks for replying back.

    I've fixed that problem, but i'm facing another issue. I wanna know how to trigger a variable from server to client, i tried alot but i couldnt make it working. is there any solution for that?

    1. Create a new .lua file
    2. Open meta and type <script src="yourfile.lua" type="shared" />

    It will look like this
    Shared File:
     

    my_var = "test"

    Server File:

    addCommandHandler("s", function(p, c)
        outputChatBox(my_var, root, 255, 255, 255, true)
    end)

    Client File:

    addCommandHandler("c", function()
        outputChatBox(my_var)
    end)

    I hope this is what you mean 😅

  2. On 16/09/2023 at 12:27, Sr.black said:

    Please Help me to fix the script dont working 

    the script destroy vehicles stuck in water after 4 seconds but dont working can you fix it please?

    client:

    function onVehicleStuckInWater(vehicle)
      local delay = 4 -- in seconds
      timer.start(delay, function()
        destroyVehicle(vehicle)
      end)
    end

     

    server:

    local vehiclesInWater = {}

    function onVehicleEnterWater(vehicle)
      vehiclesInWater[vehicle] = true
    end

    function onVehicleLeaveWater(vehicle)
      vehiclesInWater[vehicle] = nil
    end

    function onTick()
      for vehicle, _ in ipairs(vehiclesInWater) do
        local z = getVehicleZ(vehicle)
        if z < -1.5 then
          triggerClientEvent("onVehicleStuckInWater", getVehiclePlayer(vehicle), vehicle)
        end
      end
    end

     

    you forgot to use addEvent for your function to work when you want to trigger it
     

    Client
     

    function onVehicleStuckInWater(vehicle)
      local delay = 4 -- in seconds
      timer.start(delay, function()
        destroyVehicle(vehicle)
      end)
    end
    addEvent("onVehicleStuckInWater", true)
    addEventHandler("onVehicleStuckInWater", root, onVehicleStuckInWater)

     

  3. Weather & Time events

    --// Client
    
    addDebugHook("postFunction", function(_, _, _, _, _, weatherType)
        triggerEvent("onClientWeatherChange", resourceRoot, weatherType)
    end, {"setWeather"})
    
    
    
    addDebugHook("postFunction", function(_, _, _, _, _, timeHour, timeMinute)
         triggerEvent("onClientTimeChange", resourceRoot, timeHour, timeMinute)
    end, {"setTime"})
    
    --// Server
    
    addDebugHook("postFunction", function(_, _, _, _, _, weatherType)
        triggerEvent("onWeatherChange", resourceRoot, weatherType)
    end, {"setWeather"})
    
    
    
    addDebugHook("postFunction", function(_, _, _, _, _, timeHour, timeMinute)
         triggerEvent("onTimeChange", resourceRoot, timeHour, timeMinute)
    end, {"setTime"})

    EXAMPLES (CLIENT & SERVER):

    function TimeOnWeatherChange()
       outputChatBox("Weather changed (SERVER)", root, 255, 255, 0, true)
    end
    addEvent("onWeatherChange")
    addEventHandler("onWeatherChange", root, TimeOnWeatherChange)
    
    
    
    function TimeCheck()
       outputChatBox("Time changed (SERVER)", root, 255, 255, 0, true)
    end
    addEvent("onTimeChange")
    addEventHandler("onTimeChange", root, TimeCheck)
    
    
    function CTimeOnWeatherChange()
       outputChatBox("Weather changed (CLIENT)")
    end
    addEvent("onClientWeatherChange")
    addEventHandler("onClientWeatherChange", root, CTimeOnWeatherChange)
    
    
    
    function CTimeCheck()
       outputChatBox("Time changed (CLIENT)")
    end
    addEvent("onClientTimeChange")
    addEventHandler("onClientTimeChange", root, CTimeCheck)

    NOTE: Aceste eventuri merg doar daca folositi functiile (setTime & setWeather)

  4. Daca am avea mai multe layere la setSkyGradient am putea face cerul cum e pe GTA V. Din pacate avem doar top & bottom rgb, oricum cred ca este posibil cu un obiect custom si shader pe el cu o textura.

  5. local myMarker = createMarker(...)
    
    addEventHandler("onClientMarkerHit", myMarker, function(hit, dim)
        local vehicle = getPedOccupiedVehicle(localPlayer)
        if hit == localPlayer or hit == vehicle then
           if vehicle then
              setElementPosition(vehicle, x, y, z)
              setElementPosition(localPlayer, x, y, z)
           else
              setElementPosition(localPlayer, x, y, z)
           end
        end
    end)

     

  6. 16 hours ago, FlorinSzasz said:

    Hi, i want to translate some pages from wiki to Romanian language so we can have functions and events translated to our language. And i was saving a page and i got this:

    This user is currently blocked. The latest block log entry is provided below for reference:

    17:16, 16 March 2023 Abuse filter talk contribs blocked FlorinSzasz talk contribs with an expiration time of indefinite (account creation disabled, cannot edit own talk page) (Automatically blocked by abuse filter. Description of matched rule: Spam bot detection)

    I want to know where i was wrong or where i did something wrong?

     

    Seems like you did something wrong
     

    Quote

    (Automatically blocked by abuse filter. Description of matched rule: Spam bot detection)

     

  7. Patesc asta de fiecare data cand ma apuc de un proiect, incep in forta si dupa mi se ia chefu dar tot ajung pana la capat sa termin ce imi propun :)

  8. Nu gasesc o categorie adecvata pentru a posta link-urile acestea dar cea mai buna optiune ar fi aici:
    https://wiki.multitheftauto.com/wiki/RO/Main_Page - (Tradus in Romana, posibil sa fie mici greseli)
    https://wiki.multitheftauto.com/index.php?title=RO/Cum_Poti_Ajuta (Tradus in Romana, posibil sa fie mici greseli)
    https://wiki.multitheftauto.com/wiki/RO/createPed - (Tradus in Romana)

    https://wiki.multitheftauto.com/wiki/RO/getPedAmmoInClip - (Tradus in Romana)

    https://wiki.multitheftauto.com/wiki/RO/getPedArmor - (Tradus in Romana)

    O sa incerc sa traduc cat mai multe :)

    • Like 2
  9. From what I understand, you want the balance of the money in the bank to be displayed in your HUD, right? Well, you will have to use setElementData and getElementData to see what amount you have in the bank

    Example:
     

    addEventHandler("onClientRender", root, function()
        local bankMoney = getElementData(localPlayer, "bankMoney") or 0
        dxDrawText("Bank Blance: "..bankMoney.."", 100, 200, 30, 30, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top")
    end)
    
    --// I'm pretty sure you have an element data in your bank system, try to put it like on this example

     

  10. Or if you have multiple objects in client-side, you can use this variant (not tested)
     

    --// Client
    
    local myObj1 = createObject(18450, 0, 0, 2)
    local myObj2 = createObject(18450, 100, 200, 20)
    
    function DestroyObject(theObject)
       local theObject = theObject or false
       if theObject ~= false then
          if getElementType(theObject) == "object" then
             destroyElement(theObject)
          end
       end
    end
    addEvent("DestroyObject", true)
    addEventHandler("DestroyObject", root, DestroyObject)
    
    
    --// Server
    
    
    function DeleteClientObjects(thePlayer, cmd, objName)
       if objName then
          triggerClientEvent(root, "DestroyObject", root, objName)
       end
    end
    addCommandHandler("delobject", DeleteClientObjects)
    
    
    --// Command Example
    
    /delobject myObj1   (it will destroy the myObj1 from client-side)

     

  11. unii stiu ca lucram la acest proiect de tip nfs, din pacate am pierdut toate resursele din cauza unui reboot la laptop 😕

    Insa ca sa nu las oamenii care au intrat pe serverul de discord si au reactionat la fiecare actualizare dezamagiti ca nu mi-am tinut promisiunea, am inceput un proiect de tip RPG in stilul la GTA:V Online

    Discord: https://discord.gg/XcPJeahDQE

    Preview:

    https://streamable.com/sicxrf

    https://cdn.discordapp.com/attachments/1149262003370729503/1149696935326920734/gta_sa_2023-09-08_16-20-52-791.mp4

    https://cdn.discordapp.com/attachments/1149262003370729503/1149696936413233312/gta_sa_2023-09-08_16-22-12-699.mp4

    • Like 2
  12. 10 hours ago, Molvine said:

    Hello! I tried to do something similar, but even without animation, the code came out hard to read. I'm sure it's not optimal, but at least it works.

    Sorry, but my knowledge is hardly enough to create an animation. But I can try if you still need it! :)


    Video: 


    Code:

    local image = dxCreateTexture(":nfsmw/assets/icon.png")
    local selected = 1
    local count = 5
    local elementOffset = 10*scaleValue --padding between items in a menu list
    
    local w, h = 100*scaleValue, 100*scaleValue
    local offsetX, offsetY = 550*scaleValue, 50*scaleValue
    local x, y = getScreenStartPositionFromBox(w, h, offsetX, offsetY, "right", "bottom")
    
    function render()
    	local selectedPos = x
    	for i=1, count do
    		local difference = i-selected --get the difference between the selected element and the rendered element
    		local differenceCopy = difference
    
    
    		if difference < 0 then differenceCopy = -difference end
    		local height = h - (differenceCopy*20*scaleValue) --here we decrease the size as we move away from the selected element
    		local width = w - (differenceCopy*20*scaleValue)
    
    		local offset = 0
    		local step = 1
    		if difference < 0 then step = -step end
    		if difference ~= 0 then
    			for k=0, difference, step do --the loop calculates the offset using the width for each element. I didn't come up with a formula how to calculate it without a loop
    				offset = offset + (20*scaleValue)*k
    			end
    		end
    		if difference > 0 then offset = offset - 20*scaleValue*differenceCopy end --if the element is further than the selected one, then we decrease the offset by one point. without it, elements after the selected one have an offset one point less than required
    
    		local xImage = selectedPos + (w*difference) - offset + 10*scaleValue*difference --the actual position of the x-axis of the element
    		local yImage = y+(h-height)/2 --the actual y-axis position of the element
    
    		local alpha = 255 - 100*(differenceCopy) --transparency decreases with distance from the selected element
    		if alpha < 0 then alpha = 0 end
    
    		dxDrawImage(xImage, yImage, width, height, image, _, _, tocolor(255,255,255,alpha)) --element rendering
    	end
    end
    
    function startRender()
    	addEventHandler("onClientRender", root, render)
    end
    startRender()
    
    function selectElementInMenu(key, keyState, turn) --element select function
    	if turn == "right" then
    		if selected >= count then
    			selected = count
    			return
    		end
    		selected = selected + 1
    	elseif turn == "left" then
    		if selected <= 1 then
    			selected = 1
    			return
    		end
    		selected = selected - 1
    	end
    end
    bindKey("o", "up", moveMenu, "right")
    bindKey("i", "up", moveMenu, "left")

    Thank you so much!

×
×
  • Create New...