hackermagus
-
Posts
25 -
Joined
-
Last visited
Posts posted by hackermagus
-
-
6 minutes ago, stPatrick said:
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
Okay, I don't get any error message but the vehicle is currently go faster then 30 km/h.
I try
setPedControlState(ped, "accelerate", false)
But it's not help.
-
12 minutes ago, stPatrick said:
Because getElementSpeed is an 'useful' function.
You need to paste the function's source into your code.
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) addEventHandler("onClientResourceStart", root, function () local ownSpeed = getElementSpeed(vehicle, 1) end)
Like this? This not work to
-
Hi
I made a script
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
And when I start the game in debugscript 3 it says "attempt to call global 'getElementSpeed' (a nil value)'"
-
1 minute ago, stPatrick said:
It's working thank you!
-
2 minutes ago, stPatrick said:
Because the vehicle is not an object.
Ohh...
And how can I do to make the vehicle move?
-
I made a script
local vehicle = createVehicle(596, 2392.09009, -1729.73193, 13.38281, 0, 0, 90) local ped = createPed(281, 2400, -1735, 13.38281) warpPedIntoVehicle(ped, vehicle) moveObject(vehicle, 30000, 2229.23389, -1729.73193, 13.38281)
And as you can see, I want the vehicle to move on posX 2229.23389 in 30 seconds, but it not working. It creates the vehicle, the ped, insert the ped into the vehicle, but it not moving.
-
3 minutes ago, Avival said:
@hackermagus You have other function called MarketHit?
No
-
https://drive.google.com/file/d/1ZBAJXL5H_o2Xfc15ggXSTOAFAZHr4UPD/view?usp=sharing
I made a video to show my problem and I'm not the best at english so I dont know to write it..
But (video) the red marker is knows when I go in that in chat box there are shown my text but I want to show when I go into the yellow marker. The red marker is from a script and this script types is map. I made a script to the yellow marker:
local myMarker = createMarker(1675.8000488281, -1004.5, 23.10000038147, 'cylinder', 1, 191, 148, 0, 255) -- create myMarker function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler local elementType = getElementType( hitElement ) -- get the hit element's type outputChatBox( "ASdasdasdasdasdasdasdasd" ) -- attach the element's type with the text, and output it end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) -- attach onMarkerHit event to MarkerHit function
And I know the createMarker position is the yellow marker position not the red one.
I hope you understand what i write xd
Thanks for helping
-
I made a script
function drawPanel() dxDrawRectangle(406.0,277.0,650.0,235.0,tocolor(0,0,0,175),false) dxDrawLine(447.0,318.0,1005.0,318.0,tocolor(255,255,255,255),1.0,false) dxDrawText("Rádió",456.0,285.0,642.0,319.0,tocolor(0,0,0,255),1.0,"pricedown","left","top",false,false,false) dxDrawText("Rádió",451.0,289.0,637.0,323.0,tocolor(255,255,0,170),1.0,"pricedown","left","top",false,false,false) end function openandclose() if removeEventHandler("onClientRender", root, drawPanel) then removEventHandler("onClientRender", root, drawPanel) guiSetVisible(prev, false) guiSetVisible(nxt, false) else addEventHandler("onClientRender", root, drawPanel) guiSetVisible(prev, true) guiSetVisible(nxt, true) end end bindKey("r","down",openandclose) prev = guiCreateButton(453, 335, 35, 35, "<", false) guiSetFont (prev, "default-bold-small") nxt = guiCreateButton(999, 335, 35, 35, ">", false) guiSetFont (nxt, "default-bold-small")
And the buttons show up everytime if the visible or not..
The debugscript 3 says: "Attempt to call global'removeEventHandler' (a nil value)"
How to solve that?
-
3 minutes ago, xFabel said:
so easy just make other function
here we go
function openandclose()if removeEventHandler("onClientRender", root, yournamefunctiondx) then removEventHandler("onClientRender", root, yournamefunctiondx) else addEventHandler("onClientRender", root, yournamefunctiondx) end endbindKey("r","down",openandclose)
just change the name argument 3 in
removeEventHandleraddEventHandler
good luck
It worked too!!
Thank you
-
13 minutes ago, xFabel said:
because u put bindKey over a function this means that argument 3 is not defined
u need to put it under function or do it like that
bindKey("r","down", function () end end)
It's worked thank you!
And how can I do when the panel not showed up and I press "r" it showing up and when it's showed up and I press "r" it not showing up
-
Hy all'
I made this script
bindKey ( "r", "down", dxWindow ) function dxWindow() dxDrawRectangle(406.0,277.0,650.0,235.0,tocolor(0,0,0,175),false) dxDrawLine(447.0,318.0,1005.0,318.0,tocolor(255,255,255,255),1.0,false) dxDrawText("Rádió",456.0,285.0,642.0,319.0,tocolor(0,0,0,255),1.0,"pricedown","left","top",false,false,false) dxDrawText("Rádió",451.0,289.0,637.0,323.0,tocolor(255,255,0,170),1.0,"pricedown","left","top",false,false,false) dxDrawText("Parancsok:",453.0,335.0,637.0,323.0,tocolor(255,255,255,170),1.0,"default-bold","left","top",false,false,false) dxDrawText("/vs - Visszaszámláló indítása",478.0,350.0,637.0,323.0,tocolor(255,255,255,170),1.0,"default-bold","left","top",false,false,false) dxDrawText("/enableauto - Autómatikus bejelentkezés engedélyezése (amennyiben van már regisztrált fiókod)",478.0,365.0,637.0,323.0,tocolor(255,255,255,170),1.0,"default-bold","left","top",false,false,false) dxDrawText("/disableauto - Autómatikus bejelentkezés letiltása (amennyiben van már regisztrált fiókod)",478.0,380.0,637.0,323.0,tocolor(255,255,255,170),1.0,"default-bold","left","top",false,false,false) dxDrawText("Gombok:",453.0,395.0,637.0,323.0,tocolor(255,255,255,170),1.0,"default-bold","left","top",false,false,false) dxDrawText("F1 - Freeroam menü",478.0,410.0,637.0,323.0,tocolor(255,255,255,170),1.0,"default-bold","left","top",false,false,false) dxDrawText("F2 - Teleportok",478.0,425.0,637.0,323.0,tocolor(255,255,255,170),1.0,"default-bold","left","top",false,false,false) dxDrawText("F5 - Telefon",478.0,440.0,637.0,323.0,tocolor(255,255,255,170),1.0,"default-bold","left","top",false,false,false) dxDrawText("F6 - Segítség",478.0,455.0,637.0,323.0,tocolor(255,255,255,170),1.0,"default-bold","left","top",false,false,false) dxDrawText("F11 - Térkép",478.0,470.0,637.0,323.0,tocolor(255,255,255,170),1.0,"default-bold","left","top",false,false,false) dxDrawText("K - Tempomat",478.0,485.0,637.0,323.0,tocolor(255,255,255,170),1.0,"default-bold","left","top",false,false,false) dxDrawText("Az F6 - tal zarhatod be",650.0,655.0,200.0,200.0,"pricedown","left","top",false,false,false) end
And it's not working..
I turn on the debugscript 3 and it says "Bad argument @ 'bindKey' [Expected function at argument 3 got nil]"
How can I solve that?
-
If I spawn a vehicle thats ok and I know to spawn another. But when l want to spawn like 5 thats not possible because I only know to spawn 2 vehicles. How can I solve that?
-
15 minutes ago, ReZurrecti0n said:
Line 2, after "cylinder" you put 2.0 instead of just 2 as the size, that might be your issue
Not working..
-
When I hit a marker I want to Display "GG" in the chat.
I have got a resource which is a garage system that will have a marker. I write this code:
Marker = createMarker(1702.7998046875, -1079.2001953125, 22.89999961853, "cylinder", 2, 0, 0, 255) local myMarker = createMarker(1702.7998046875, -1079.2001953125, 22.89999961853, 'cylinder', 2.0, 0, 0, 255, 150) function MarkerHit( Element, matchingDimension ) triggerClientEvent ( "onMarkerHit", getRootElement()) outputChatBox("GG") end addEventHandler( "onMarkerHit", Marker, MarkerHit )
And when I go to the marker I created, nothing happened. But when I go to the garage system marker, that works. And the marker position in this code is not the same as the garage system marker.
Please help!!
-
9 minutes ago, HassoN said:
Yeah I meant without a space in the name itself not between restart and the name.
So you restarted it and the marker did not appear? Uhmm try to change type="map" to type="script" in your meta, maybe because it is a map so your Lua file is not introduced?
Simple. Nothing happens..
-
4 minutes ago, HassoN said:
Open your console and type restart map name (without space)
Map name: 2019-08-16-4
When I type restart 2019-08-16-4 then it says map 2019-08-16-4 restarted
But when I type restart2019-08-16-4 (Without space) it will nothing happens
-
19 minutes ago, HassoN said:
Everything seems fine to me. What's the exact issue? Does the marker get created in the first place? Or is it only that if you enter nothing happens? Type /debugscript 3 then restart the resource and tell me if you face any error messages
The marker is not created. I don't know to restart the resource because it's not a resource, it's a map. And when I restart in the console the map is restart, i got black screen, but I know to move, and open panels and there is no any problems
-
Just now, HassoN said:
Show me your meta file.
<meta> <script src="teleport.Lua" type="client"></script> <info gamemodes="play" type="map" version="1.0.0"></info> <map src="2019-08-16-4.map" dimension="0"></map> <settings> <setting name="#maxplayers" value="[ 128 ]"></setting> <setting name="#useLODs" value="[ false ]"></setting> <setting name="#gamespeed" value="[ 1 ]"></setting> <setting name="#minplayers" value="[ 0 ]"></setting> <setting name="#gravity" value="[ 0.0080000004 ]"></setting> <setting name="#waveheight" value="[ 0 ]"></setting> <setting name="#locked_time" value="[ false ]"></setting> <setting name="#weather" value="[ 0 ]"></setting> <setting name="#time" value="12:0"></setting> </settings> <script src="mapEditorScriptingExtension_s.Lua" type="server"></script> <script src="mapEditorScriptingExtension_c.Lua" type="client" validate="false"></script> </meta>
-
8 hours ago, HassoN said:
You add the script to the map folder? What do you mean by that? You must create a .Lua file and introduce it to the meta in order to get it to work.
Also at your timer, you are using 1 as a time interval while the minimum is 50.
Sorry I'm not so good at english but I do that.
-
Hi , I want to make a teleport like when I go to a marker that teleports me to another position. I make a script, but it!s not workig. I add the script to the meta file, I add the cript to the map folder, I load the map but it!s not working. Please help
local marker1 = createMarker(-2295.099609375, 1866.2998046875, 1.8999999761581 "arrow", 3.5, 255, 255, 255, 255) function teleport1(player) if player == localPlayer then setElementPosition(player, -2344.0385742188, 2398.6096191406, 8.5596084594727) setPedRotation (player, 90) setElementFrozen(player, false) setTimer(setElementFrozen, 1, 1, player, false) end end addEventHandler("onClientMarkerHit", marker1, teleport1)
-
Hi, My Name is Attila and I want to make a server. I make the map in the editor but I dont know how to insert to the server. Does everyone help me? Thanks
-
I want a garage syystem like when I'm type /save car in the chat this will be saves my car with the handling, color, etc.. And when I type /get car there is a panel where I select cars that I saved. The car name in the panel is the real car name. Does everyone do make me a full script? Thanks a lot! And sorry for my english, I'm from hungary but I hope you understand what I'm writing to here.
-
getElementSpeed not working
in Scripting
Posted
Like a for loop?