-
Posts
372 -
Joined
-
Last visited
-
Days Won
11
Posts posted by Hydra
-
-
-
4 hours ago, alex17" said:
addEventHandler("onClientKey", root, function(key) if key == "lctrl" or key == "mouse1" then cancelEvent() end end )
Shouldn't it be?
if key == "lctrl" and key == "mouse1" then cancelEvent() end
-
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
-
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
-
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
-
# 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
Discord: https://discord.gg/XcPJeahDQE- 1
- 2
-
function setCursorCenteredOnRectangle(x, y, width, height) if x and y and width and height then setCursorPosition(x + width/2, y + height/2) end end
Cu aceasta functie puteti seta cursoru in centrul unui rectangle(merge si pentru text cel mai probabil)
https://wiki.multitheftauto.com/wiki/SetCursorCenteredOnRectangle- 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
-
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)
endserver:
local vehiclesInWater = {}
function onVehicleEnterWater(vehicle)
vehiclesInWater[vehicle] = true
endfunction onVehicleLeaveWater(vehicle)
vehiclesInWater[vehicle] = nil
endfunction onTick()
for vehicle, _ in ipairs(vehiclesInWater) do
local z = getVehicleZ(vehicle)
if z < -1.5 then
triggerClientEvent("onVehicleStuckInWater", getVehiclePlayer(vehicle), vehicle)
end
end
endyou 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)
-
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)
-
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.
-
interesanta idee
-
shader sau obiect custom?
-
Speed Effect & Nitro Effect
Preview: https://streamable.com/89uc5l
- 1
-
Mai usor e fara _ la numele functiilor
function FindValueInTable
function FindValuePosInTable
- 1
-
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)
-
Post a code, we can help you without it!
I guess u need to put it like:
addEventHandler("onPlayerSpawn", root, function() -- trigger your onPlayerFirstSpawn event end)
- 1
-
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)
-
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
-
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
- 2
-
Car Selector (Alpha)
Preview: https://streamable.com/qqabrd- 1
-
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
-
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)
-
Sneak Peek #2
Aproape la fel ca in joc
- 1
- 1
[HELP] I don't know why this won't work
in Scripting
Posted
First of all, Do not post 3 topics about the same problem. Post one topic about your issues and wait for someone to help you