-
Posts
1,141 -
Joined
-
Last visited
-
Days Won
42
Everything posted by Patrick
-
https://wiki.multitheftauto.com/index.php?title=Meta.xml Add line to meta in freeroam: <min_mta_version server="1.5.6-9.16362" client="1.5.6-9.16362" /> And, run the upgrade command in console:
-
https://wiki.multitheftauto.com/wiki/OnClientGUIClick https://wiki.multitheftauto.com/wiki/TriggerServerEvent https://wiki.multitheftauto.com/wiki/TakePlayerMoney Create an event what attached to `GUI.button[1]`, when client click on this button, its call the function. Then trigger a server sided function with localPlayer's element, whats takes the money. Help: https://forum.multitheftauto.com/topic/121619-Lua-for-absolute-beginners
-
This is a solution too, if you make a colshape around the center of the music's place.
-
Hali. Elkerülte a figyelmem a legutóbb, hogy renderTargetben vagy, mert dxDrawImageSection-t használsz. (elég a dxDrawImage) így viszont, hogy renderTargetben vagy, nem kell korlátozni a (min-maxos cucc) blip max távolságát. (kivettem) A findRotationnál pont fordítva kell a különbséget nézni, hogy egyszerűbb legyen számolni. getPointFromDistanceRotation-nál pedig mivel renderTarget-ben vagy, annak a közepét kell megadni, azon belül. for k,v in pairs(getElementsByType('blip')) do local blipPosX,blipPosY = getElementPosition(v) local rotationBetween = findRotation(blipPosX,blipPosY,playerX,playerY) local distanceBetween_GAME = getDistanceBetweenPoints2D (playerX,playerY,blipPosX,blipPosY) local distanceBetween_PIXELS = distanceBetween_GAME * (3072/6000) local blipScreenX,blipScreenY = getPointFromDistanceRotation(w,h,distanceBetween_PIXELS,rotationBetween-r) dxDrawText ( blipScreenX .. ' , '.. blipScreenY , bw/2,bh/2,bw/2,bh/2 ,tocolor(255,255,255,255)) dxDrawImage(blipScreenX- 10, blipScreenY - 10, 20, 20, 'player.png'); end
-
onClientResourceStart call the function once, when resource started. If in this time, `localPlayer` is not inside the zone, the music don't start. You have two options: - Place down looped 3D sound. - Check player's position in every second, and start sound if inside the zone (and music isn't playing) or stop sound if outside the zone (and music plays)
-
FUNCTION addCommandHandler guiCreateWindow guiCreateButton createMarker addEvent triggerServerEvent triggerClientEvent EVENT onMarkerHit onClientGUIClick HELP https://forum.multitheftauto.com/topic/121619-Lua-for-absolute-beginners/
-
why, what's happening?
- 10 replies
-
In this topic only English is allowed, but you can find a hungarian topic too.
- 10 replies
-
Almoost. for k,v in pairs(getElementsByType('blip')) do local blipPosX,blipPosY = getElementPosition(v) local blipX,blipY = getMapCord(v) local rotationBetween = findRotation(playerX,playerY,blipPosX,blipPosY) local distanceBetween_GAME = getDistanceBetweenPoints2D (playerX,playerY,blipPosX,blipPosY) local distanceBetween_PIXELS = distanceBetween_GAME * (3072/6000) -- distance * (map image size / game world size) -- in this case, now we use getPointFromDistanceRotation to calculate pixels, and not ingame coordinates local blipScreenX,blipScreenY = getPointFromDistanceRotation(x+s/2,x+s/2,distanceBetween_PIXELS,rotationBetween) blipScreenX = math.max(x, math.min(x+s, blipScreenX)) blipScreenY = math.max(y, math.min(y+s, blipScreenY)) dxDrawImage(blipScreenX- 10, blipScreenY - 10, 20, 20, 'player.png'); -- I don't have blip images yet end Something like this, but it's a bit difficult to say exactly without testing it... (btw are you hungarian? If yes, I can tell you in hungarian, in more detail)
- 10 replies
-
- 1
-
Try to debug it for yourself, here is some help: https://wiki.multitheftauto.com/wiki/HU/Meta.xml https://wiki.multitheftauto.com/index.php?title=Debugging https://forum.multitheftauto.com/topic/121619-Lua-for-absolute-beginners/
-
Then, you need the rot difference between localPlayer and blip: findRotation And the distance between localPlayer and blip: getDistanceBetweenPoints2D When you get it, convert game distance to screen pixel distance. Then, you can calculate the blip position, from the center of the map: getPointFromDistanceRotation And finally, you need to limit the blip x and y coords, to stay inside the map rectangle. blipScreenX = math.max(MAP_RECTANGLE_START_X, math.min(MAP_RECTANGLE_END_X, blipScreenX)) blipScreenY = math.max(MAP_RECTANGLE_START_Y, math.min(MAP_RECTANGLE_END_Y, blipScreenX))
- 10 replies
-
You need to rotate the blip too, around center of the map. You can change the rotation point. https://wiki.multitheftauto.com/wiki/DxDrawImage
- 10 replies
-
Here you can find everything, what need: https://wiki.multitheftauto.com/wiki/EngineApplyShaderToWorldTexture
-
addEventHandler("onClientGUIClick", extra1, example, false) Az event létrehozása jó, de nem a megfelelő funckcióhoz "csatoltad". Nincs olyan funkciód, hogy example. (vagy nem másoldtad be) Valamint az aFunkcio nevű funkció sem kapja meg első argumentként a játékos elementjét. Plusz a setVehicleVariant egy szerver oldali funkció, szóval nem használhatod kliens oldalon. Úgy kell ezt megcsinálnod, hogy: kliens oldalon gombnyomás => meghív egy kliens oldali funkciót => ez a kliens oldali triggerel egy szerver oldali funckciót a játékos elementjével (localPlayer) => és az a szerver oldali funkció megkeresi a játékos kocsiját, majd módosítja a variánst (plusz ha kódot másolsz be akkor a kód beillesztés lehetőséget választ, ne az idézést)
-
Hungarian: A 470 nem egy 'vehicle' típus, hanem egy szám (int) Az első változónak egy jármű elementet vár, de azt elsőnek meg kell szerezni valahonnan. Az a kérdés, hogy mikor akarod megváltoztatni a variánst: - Egyből a jármű létrehozás után? - Akkor a createVehicle funckcióból kapod meg a jármű elementjét - Járműben ülve, valamilyen paranccsal? - Akkor a parancsot beíró játékosnak a kocsiját kell lekérdezni. Például, ha a második esetet nézzük, akkor valami ilyesmi: -- SERVER SIDE function aFunkcio(jatekos) -- ha egy paranccsal hívunk meg egy funckciót, akkor tudjuk, hogy első argumentként megkapja a játékos elementjét, aki beírta a parancsot local kocsija = getPedOccupiedVehicle(jatekos) -- lekérdezzük a parancsot beíró játékos kocsiját if isElement(kocsija) then -- getPedOccupiedVehicle vagy a jármű elementjét adja vissza, vagy false értéket. (megnézzük, hogy elementet adott-e vissza és ha igen, akkor módosítjuk a variánst) setVehicleVariant(kocsija, 2, 2) end end addCommandHandler("valami", aFunkcio)
-
You can find everything about it on wiki, with example. https://wiki.multitheftauto.com/wiki/SetVehicleVariant
-
Not completely. Your code runs once when you start the resource. But, every ~0.5-1th seconds you should check how fast the car. setTimer function getElementSpeed(theElement, unit) -- Check arguments for errors assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")") local elementType = getElementType(theElement) assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile", "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")") assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)") -- Default to m/s if no unit specified and 'ignore' argument type if the string contains a number unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit)) -- Setup our multiplier to convert the velocity to the specified unit local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456) -- Return the speed by calculating the length of the velocity vector, after converting the velocity to the specified unit return (Vector3(getElementVelocity(theElement)) * mult).length end local vehicle = createVehicle(596, 2392.09009, -1729.73193, 13.38281, 0, 0, 90) local ped = createPed(281, 2400, -1735, 13.38281) setVehicleSirensOn(vehicle, true) warpPedIntoVehicle(ped, vehicle) setPedControlState(ped, "accelerate", true) setTimer(function() if (getElementSpeed(vehicle, 1) > 29) then setPedControlState(ped, "brake_reverse", true) else setPedControlState(ped, "brake_reverse", false) end end, 500, 0) -- check every 0.5s
-
Nope. https://wiki.multitheftauto.com/wiki/GetElementSpeed function getElementSpeed(theElement, unit) -- Check arguments for errors assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")") local elementType = getElementType(theElement) assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile", "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")") assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)") -- Default to m/s if no unit specified and 'ignore' argument type if the string contains a number unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit)) -- Setup our multiplier to convert the velocity to the specified unit local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456) -- Return the speed by calculating the length of the velocity vector, after converting the velocity to the specified unit return (Vector3(getElementVelocity(theElement)) * mult).length end local vehicle = createVehicle(596, 2392.09009, -1729.73193, 13.38281, 0, 0, 90) local ped = createPed(281, 2400, -1735, 13.38281) local ownSpeed = getElementSpeed(vehicle, 1) setVehicleSirensOn(vehicle, true) warpPedIntoVehicle(ped, vehicle) setPedControlState(ped, "accelerate", true) if (ownSpeed > 29) then setPedControlState(ped, "brake_reverse", true) end Like this
-
Because getElementSpeed is an 'useful' function. You need to paste the function's source into your code.
-
https://wiki.multitheftauto.com/wiki/SetPedControlState setPedControlState(ped, "accelerate", true)
-
Because the vehicle is not an object. ?
-
logging in mta with data from registration in the mybb forum
Patrick replied to NoviceWithManyProblems's topic in Scripting
You can find the hashing function in /inc/functions_user.php (create_password) -
-- CLIENT SIDE addCommandHandler("hide", function() local vehicle = getPedOccupiedVehicle(localPlayer) if not vehicle then return outputChatBox("ERROR: You have to sit in a vehicle!") end setVehicleComponentVisible(vehicle, "bump_front_dummy", false) setVehicleComponentVisible(vehicle, "bump_rear_dummy", false) outputChatBox("SUCCESS: Bumpers are hided!") end)