-
Posts
51 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Mkl
-
Hello, you are not connected to the database. Find in the code the dbConnect function and set your credentials. https://wiki.multitheftauto.com/wiki/DbConnect
-
Hi, onClientPlayerVehicleEnter first paramater is theVehicle element you entered addEventHandler("onClientPlayerVehicleEnter", localPlayer, function(theVehicle) You can get the model id of this vehicle using getElementModel(theVehicle) and check if the vehicule you entered is a valid model It is faster to use a table with key as id of the vehicle and set a boolean true as value because it allows you to check by calling the table with the id of vehicule you entered as key instead of checking with a loop. validModels = { [124] = true, [126] = true, -- etc } addEventHandler("onClientPlayerVehicleEnter", localPlayer, function(theVehicle) local id = getElementModel(theVehicle) if (validModels[id]) then -- your stuff end end) Cya,
- 1 reply
-
- 1
-
Hi, Would not the attached players follow the vehicle when switching dimension or interior if player is set as children of the vehicle. I'm not sure if it works, could be worth to try. Maybe attachElements is already setting element as children ... -- NOT TESTED function attachPlayerToVehicle(player, vehicle) if not getElementType(player) == "player" then return end if not getElementType(vehicle) == "vehicle" then return end attachElements(player, vehicle) setElementParent(player, vehicle) end edit : I tried with runcode, attached myself to a vehicle, set myself children to this vehicle, set a different interior and dimension to the vehicle and I was following it. I tried also wihout setting myself as children and I was not following. You whole code can only be a short function You could also override attachElements to handle any case by default. Have a nice day
-
hi, https://wiki.multitheftauto.com/wiki/OnClientVehicleDamage If this event is canceled, the vehicle health won't be reduced. Physical damage to the vehicle will remain.
-
https://wiki.multitheftauto.com/wiki/Lua_compilation_API#Examples
-
Hi, maybe with https://wiki.multitheftauto.com/wiki/AttachElements
-
HI, If I understand well you want to create a new column "team" and update it when a player change his team. The idea that come to my mind is to create a custom event "onPlayerChangeTeam" by overriding the setPlayerTeam function. addEvent("onPlayerChangeTeam", false) _setPlayerTeam = setPlayerTeam -- we save the original function -- override setPlayerTeam = function(thePlayer, theTeam) _setPlayerTeam(thePlayer, theTeam) triggerEvent("onPlayerChangeTeam", thePlayer, theTeam) -- a new event "onPlayerChangeTeam" end addEventHandler("onPlayerChangeTeam", root, function(theTeam) -- function to update the column setElementData(source,"status", "theTeam") end) Untested code But it depends on what you are trying to do. This idea is that, when the setPlayerTeam function is used in your code, the scoreboard is updated but I maybe missunderstand what you want Cya,
- 1 reply
-
- 1
-
Hi I noticed that : - The vehicle starts to be on fire below 250 / 1000 - When it's flipped it takes 1100 of damage during the explosion I don't see any event about detecting the vehicle on fire but you can still detect it like this : addEventHandler("onClientVehicleEnter", root, function() local vehicle = source setTimer(function() if getElementHealth(vehicle) < 250 then print("onFire") killTimer(sourceTimer) end end, 500, 0) end)
-
Hi, I don't think getTime().hour is correct, check the wiki https://wiki.multitheftauto.com/wiki/GetTime
-
Hi -- theElement: the element that entered the colshape. -- The source of this event is the colshape that was hit. function take(theElement, matchingDimension) if not (theElement == localPlayer) then -- Checks whether the entering element is the local player return end if not (isPedInVehicle(localPlayer) then -- Checks if local player is not in a vehicle return end -- your colshape stuff if getElementData(source, "take") == "+" then -- source = colshape local veh = getPedOccupiedVehicle(localPlayer) local model = getElementModel(veh) if model == 485 then triggerEvent("notiAdd", localPlayer, "success", "Done") else triggerEvent("notiAdd", localPlayer, "error", "Error") end end end addEventHandler("onClientColShapeHit", root, take)
- 1 reply
-
- 1
-
Happy birthday MTA ! I'm more than happy to share my little story. I think I've started playing MTA SA Race in 2007. I enjoyed a lot creating and playing Race maps and Destruction Derby maps. I played on several servers (like Betaflied DD if some of you remember). I remember the launch of MTA DM (where we played in loop Hay and Fallout ?). Then and because of MTA Race, I kept playing principally Race mode on several servers. During the last 4 years I tried out to develop my own scripts and it became a real hobby for me, the community forum and the discord server helped me a lot, I also started to enjoy helping others about script and modeling stuff. I hope this game and his community will stand again for many years. ?
- 78 replies
-
- awesomeness
- multi theft auto
- (and 6 more)
-
Hi, by using playSound inside onClientGUIClick event handler for this specific button. You'll have add your music to the resource and then find the part where this GUI window is scripted to add playSound function inside the existing event handler.
-
Hi, there is a function to turn on / off the engine https://wiki.multitheftauto.com/wiki/SetVehicleEngineState
-
can't wait Merry christmas and happy new year everyone ?
-
Usp, I meant the first (return) type mistake ?
-
Hello I would say it depends on preference, I personnaly like the second way (using return). It makes not too many scopes and looks to me a good way to dissociate clearly validation of received arguments before executing the function. Some tips / observations about your code : 1 _ To check string length you can directly use # ( instead of string.len() ) for example : if (not #string > 0) then 2 _ Looks like a tool to give money. If you try to check money range, why don't you convert the string to a int/number ( using tonumber() ) and then doing necessary checks (if you need to check minimum / maximum range). 3 _ I don't understand string.len(AmountKey) ~= 16 which means if your string has not 16 char it return the error.
-
It coule be a shared type function, try with type="shared".
-
Hi, Error comes from that addEvenHandler is not closed. Also, there is no attached function. addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld) if (button == "right") and (state == "up") then --- script end end) -- end of function and ")" close addEventHandler Then, you have multiple other problems : there is functions with wrong name and other syntax problems that will not make your script works like : - getDistanceBetweenPoints3D() and his arguments wrongly writed, I guess it should be getDistanceBetweenPoints3D(x, y, z, pX, pY, pZ) (clicked position to player position). Plus, you could directly use worldX, worldY and worldZ rather than getting position of clickedWorld (clickElement in your script). https://wiki.multitheftauto.com/wiki/OnClientClick
-
Hi, acces denied error means you have to give ACL rights to the resource : open ACL.xml, add <object name="resource.vehicle-manager"></object> in Admin ACL group (or use Admin resource to do it). Second error is about exported function of "mysql" resource not being recognized. Does this resource exist on your server ?
-
predefined variable localPlayer doesn't exist serverside. You can direclty set the name as first argument, It'll send to root element by default, and so every players children. bool triggerClientEvent ( [ table/element sendTo = getRootElement(), ] string name, element sourceElement [, arguments... ] ) Set the sourceElement (3rd parameter), I suggest resourceRoot (the present resource). triggerClientEvent("eventName", resourceRoot) You can aim specific players by passing a table as first parameter (or loop). By the way be careful with your addEventHandler("onResourceStart", ...). Set getRootElement() (same as root predefined variable) will have for result to trigger the function everytime a resource is starting. You should rather use resourceRoot (for the actual resource). addEventHandler("onResourceStart", resourceRoot, createMinigunWeapon)
-
Hi, we need to see more code context (the whole function, attached event or command and where you create peds) Would be great if you can use code blocks, thanks. For now all I can say is that ped1, ped2, ped3 variables are nil maybe due to your setTimer.
-
It is updateState(value, total, radius), like updateState(50, 100, 250) should give half a circle. It could be edited to remove radius param in our case. This is the way I update the svg : local function setProgress(value) local svgXML = svgGetDocumentXML(mySvg) -- get xml local path = xmlNodeGetChildren(svgXML, 1) -- get path node (second node, following first example I gave) xmlNodeSetAttribute(path, "d", updateState(value, 100, 250)) -- editing the attribute svgSetDocumentXML(mySvg, svgXML) -- saving end You could imagine a command to test it like : local function startDemo() local value = 0 setTimer(function() value = value + 1 setProgress(value) end, 10, 100) end addCommandHandler("demo", startDemo) A little animation 0 to 100 % of the circle progress.
-
Like a percentage progress ? Yes it's possible. You have to update the SVG using svgGetDocumentXML and svgSetDocumentXML (check example on the wiki). I found a way to draw the circle regarding percentage progress with this function : local function updateState(value, total, R) local center local alpha = 360 / total * value local a = (90 - alpha) * math.pi / 180 local x = 300 + R * math.cos(a) local y = 300 - R * math.sin(a) local path if (total == value) then path = "M300,"..(300 - R).." A"..R..","..R..",0,1,1,299.99,"..(300 - R) else if (alpha > 180) then center = 1 else center = 0 end path = "M300,"..(300 - R).." A"..R..","..R..",0,"..center..",1,"..x..","..y end return path end source : https://stackoverflow.com/questions/5230148/create-svg-progress-circle
-
Hi, If I understand you are trying to create a circle path with a gradient ? I don't have an example to do it with DX functions and shaders but I figured out it's possible with SVG so I share it : <svg viewBox="0 0 600 600" xmlns="http://www.w3.org/2000/svg"> <defs> <linearGradient id="gradient"> <stop offset="5%" stop-color="#FF0000" /> <stop offset="95%" stop-color="#00FF00" /> </linearGradient> </defs> <path id="progress" fill="none" stroke="url(#gradient)" d="M300,50 A250,250,0,1,1,299.99,50" stroke-width="20" /> </svg> You can check this example via simulator : https://www.svgviewer.dev/ I'm not sure I helped you. Good evening
-
Weird idea, why do you want to do this ?