Jump to content

Hydra

Members
  • Posts

    372
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Hydra

  1. 40 minutes ago, FlorinSzasz said:

    remove type client from there maybe that could be the problem (from client i mean)

    -> u only need this ->

    <file src="beep.mp3"/>

     

    There is nothing wrong in meta, you can put type for <file src> too

  2. 39 minutes ago, Mawmad said:

    Wow , Thanks a Lot Mate ! ❤️

     

    Sorry and it still doesn't work...

    Everything seems fine, I don't know what the problem is

    If you don't hear the sound, try to look for one for about 2-3 seconds maximum and in playSound("beep.mp3", false) put playSound("beep.mp3", true) so that the sound repeats. if this don't work idk then

  3. On 23/09/2023 at 02:17, Mawmad said:

    Hello

    I'm Working On a Parking Sensor For MTA:SA 

    Also I'm New To MTA And Scripting 

    My problem is that when I start the resource and move the car in reverse gear, there is no sound

    Parkings.lua

    -- parking sensor for mta:sa
    function isVehicleReversing(theVehicle)
        local theVehicle = getPedOccupiedVehicle ( thePlayer )
        local getMatrix = getElementMatrix (theVehicle)
        local getVelocity = Vector3 (getElementVelocity(theVehicle))
        local getVectorDirection = (getVelocity.x * getMatrix[2][1]) + (getVelocity.y * getMatrix[2][2]) + (getVelocity.z * getMatrix[2][3])
        if (getVectorDirection < 0) then
            return true
    function getDistanceBetweenElements(arg1, arg2)
    	local car = Vector3(getPedOccupiedVehicle( arg1 ))
    	local nearObject = Vector3(getNearestElement( arg2 ))
    	local distance = getDistanceBetweenPoints3D( car,nearObject )
    	if vehicle then 
    	local sound = playSound("beep.mp3")
    	setSoundVolume(sound, 0.5) 
    	setSoundProperties(sound, 48000.0, 128.00, distance, false)
    	return distance
    addEventHandler("onClientResourceStart", resourceRoot, isVehicleReversing, getDistanceBetweenElements) -- 

    meta.xml

    <meta>
        <script src="parkings.lua" type="client" />
        <file src="beep.mp3" type="client" />
    </meta>

    What is wrong with my script?

    There are a lot of problems with your script
    Try this:
     

    local alarm = nil
    
    bindKey("s", "down", function()
        local vehicle = getPedOccupiedVehicle(localPlayer)
    	if vehicle then
    	   if isVehicleReversing(vehicle) then
    	      local nearObject = getNearestElement(vehicle, "object", 15)
    		  if nearObject then
    		     if alarm == nil then
    			    alarm = playSound("beep.mp3", false)
    		     end
    		  end
    	   end
    	end
    end)
    
    
    
    function ForceSoundOff()
       local vehicle = getPedOccupiedVehicle(localPlayer)
       if not isVehicleReversing(vehicle) then
          if alarm ~= nil then
    	     stopSound(alarm)
    		 alarm = nil
    	  end
       end
    end
    addEventHandler("onClientRender", root, ForceSoundOff)
    
    
    function getNearestElement(player, type, distance)
    	local result = false
    	local dist = nil
    	if player and isElement(player) then
    		local elements = getElementsWithinRange(Vector3(getElementPosition(player)), distance, type, getElementInterior(player), getElementDimension(player))
    		for i = 1, #elements do
    			local element = elements[i]
    			if not dist then
    				result = element
    				dist = getDistanceBetweenPoints3D(Vector3(getElementPosition(player)), Vector3(getElementPosition(element)))
    			else
    				local newDist = getDistanceBetweenPoints3D(Vector3(getElementPosition(player)), Vector3(getElementPosition(element)))
    				if newDist <= dist then
    					result = element
    					dist = newDist
    				end
    			end
    		end
    	end
    	return result
    end
    
    function isVehicleReversing(theVehicle)
        local getMatrix = getElementMatrix (theVehicle)
        local getVelocity = Vector3 (getElementVelocity(theVehicle))
        local getVectorDirection = (getVelocity.x * getMatrix[2][1]) + (getVelocity.y * getMatrix[2][2]) + (getVelocity.z * getMatrix[2][3])
        if (getVectorDirection < 0) then
            return true
        end
        return false
    end

     

  4. # Project:V

    Project:V is a server based on the game mode from GTA:V Online. We are trying to bring every feature from GTA:V to this server to create something unique and long lasting. The server is still in progress but quite a lot of progress has been made, I won't post every update here and I'll let you go to our discord server to see what the server looks like at the moment

    Some screens:
    https://streamable.com/ghma0r
    https://streamable.com/vdffx6
    spacer.png
    spacer.png
    spacer.png



    Discord: https://discord.gg/XcPJeahDQE

    • Like 1
    • Thanks 2
  5. 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 😅

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

     

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

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

     

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

     

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

     

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

     

×
×
  • Create New...