-
Posts
6,097 -
Joined
-
Last visited
-
Days Won
218
Everything posted by IIYAMA
-
if passenger and passenger ~= thePlayer then Stack overflows are mostly happening when you created an infinity loop of function calls. A player leaves the vehicle triggering the event, which will remove a player, which will trigger the event, which will remove a player, which will trigger the event, which will remove a player, which will trigger the event, which will remove a player... ? Note: The player is still inside of the vehicle when the event is triggered.
-
Ha @Hugos I am currently a bit busy with stuff, I will reply when I have time. (~1.5 day) If you do not want to wait for help, there are two tutorials you can follow: The first one is about events: (which also includes triggerServerEvent's) And the second one is about some code that can help you making communication easier between serverside and clientside.
-
You subtract an absolute values from the player his resolution, before applying the multiplier. (sx_-1910) * xm That is not a logic calculation. At least follow the tutorial: local devScreenX = 1440 local devScreenY = 900 local screenX, screenY = guiGetScreenSize() local scaleValue = screenY / devScreenY This is more or less how I do it and keep things clean. (untested) local box = { startX = screenX * 0.25, startY = screenY * 0.25, width = screenX * 0.5, height = 500 * scaleValue } box.endX = box.startX + box.width box.endY = box.startY + box.height dxDrawRectangle ( box.startX, box.startY, box.width, box.height, tocolor(0,0,0) ) dxDrawText("SuperFun - Szórakozó szerver", box.startX + 10 * scaleValue, box.startY, box.endY - 100 * scaleValue, box.startY + 50 * scaleValue, tocolor(255,255,255,255), 1.00 --[[* scaleValue]], font2, "left", "center")
-
<min_mta_version server="1.5.2-9.07903" client="1.5.2-9.07903" /> Make sure that something like this is adding between the <meta> -here- </meta> tags. More info can be found here: https://wiki.multitheftauto.com/wiki/Meta.xml
-
I did send you a tutorial in my last reply, so I assume you did read it and applied it to you code? This one. Well show me what you did.
-
It is nothing magic. Just a value you use to multiply another value, so it gets bigger, smaller or unchanged. local bananas = 100 local multiplier = 0.5 -- = 50% bananas = bananas * multiplier print(bananas) -- 50 bananas
-
Absolute values like 290px and 240px do not scale, without a multiplier. There is a tutorial for scaling DX (+useful for other user interfaces).
-
Why not thinking about reduction and faking continuous effects? Instead of trying to solve the issue at the moment you already created too much data? If you are dealing with too much data, the latent trigger event can reduce impact on clients. It is send when the network is free. (+ you need to merge all data in to 1 triggerEvent) https://wiki.multitheftauto.com/wiki/TriggerLatentClientEvent Forcing 100ms is more or less killing your network. Better to check the status of the latent event, before sending the next payload of data. https://wiki.multitheftauto.com/wiki/GetLatentEventStatus If you want to have some advice for reduction and faking. I need to know a lot more about the context of the data and a lot of the details (conditions).
- 7 replies
-
- 1
-
-
- element data
- synchronization
-
(and 1 more)
Tagged with:
-
Nope it doesn't unfortunately. But that doesn't mean you can't fake it. And save some network data. local elementList = {vehicle, vehicle} triggerClientEvent(root, "triggerEventForElementList", resourceRoot, elementList, "theEvent", "argument1") addEvent("triggerEventForElementList", true) addEventHandler("triggerEventForElementList", resourceRoot, function (elementList, theEvent, ...) for i = 1, #elementList do triggerEvent(theEvent, elementList[i], ...) end end, false)
-
How about you start with using the code I gave you? And change it to something that could work for you? -- test data local weapon = 31 local ammo = 3000 --- local item1 = {type = "weapon" , weapon = weapon, ammo = ammo} saveItemInVehicleTrunk (vehicle, item1) local item2 = {type = "weapon" , weapon = 38, ammo = 9999} -- minigun saveItemInVehicleTrunk (vehicle, item2) local items = getItemsInVehicleTrunk (vehicle) for i=1, #items do local item = items[i] if item.type == "weapon" then iprint("weapon id:", item.weapon, ", ammo:", item.ammo) end end
-
1. You can get the colshape of a marker. https://wiki.multitheftauto.com/wiki/GetElementColShape 2. Get the elements of a specific type and check if there are none. https://wiki.multitheftauto.com/wiki/GetElementsWithinColShape local colshape = getElementColShape ( marker ) local players = getElementsWithinColShape ( colshape, "player" ) local vehicles = getElementsWithinColShape ( colshape, "vehicle" ) if #vehicles == 0 and #players == 0 then end Note: you might also need to check if the elements are not in the same dimension + interior, if you make use of those.
-
Where in the script are you storing the weapons in the vehicle?
-
It is a php interface from MTA. It can help you to make an access point for (local) http requests. If you want to communicate with MTA, the http protocol is more or less your only option. If you think this is confusing, then please read: https://www.geeksforgeeks.org/get-post-requests-using-python/ It explains you a little bit about http and how to use that in python. Not familiar with the php language on the MTA side of things? There are multiple sockets available, just not specific python. https://wiki.multitheftauto.com/wiki/Resource_Web_Access This is what you are going to need at the end: MTA < SOCKET < (protocol http) < Python
-
One thing you might have to take in to consideration is that the resource might take too long to save a large buffer. Especially when onResourceStop is triggered. The resource wants to stop, but it can't because too much is going on. Don't end up with a too large buffer, because the server might want to kill the resource process. (warning: resource xxx takes too long to stop...) Shouldn't be required > Just to be safe, add a flush feature which will write the buffer in to the db, which you can use before making a attempt to stop the resource. Then you are at least prepared for...
-
Sure there is any chance of fail. For example an application or server crash. But atleast you know that it didn't happen because your database was too busy writing every single update to the storage.
-
Serverside is running on the server. Application (in case of a local server): Program Files (x86)\MTA San Andreas 1.5\server Clientside is running on clients/players. Application: Program Files (x86)\MTA San Andreas 1.5\Multi Theft Auto.exe Those are two very different applications. And between those two applications there is something called ping, = connection delay. Even a local server has a little bit of ping, even though it is displayed as 0. Your code does not wait for ping, it just runs until it finished all the instructions you gave it. If you want to let those two sides communicate with each other you need to use triggerEvent. See examples on these pages: From clientside to serverside: (examples included) https://wiki.multitheftauto.com/wiki/TriggerServerEvent From serverside to clientside: (examples included) https://wiki.multitheftauto.com/wiki/TriggerClientEvent Enchantment You can also use an enchantment, which I created for people that have trouble with communication between serverside and clientside. Installation Clientside addEventHandler("onClientResourceStart", resourceRoot, function () callServer( "getTitlesTable", function (TitlesTable_) -- < This is the callback function TitlesTable = TitlesTable_ end ) end) Clientside if TitlesTable then for i, k in ipairs(TitlesTable) do dxDrawRelativeRectangle(598, 219+i*30, 296, 30, isMouseInPosition((598/resolutionX )*sWidth,((219+i*30)/resolutionY )*sHeight, (219/resolutionX )*sWidth, (32/resolutionY )*sHeight) and tocolor(255, 255, 255, 158) or tocolor(0, 0, 0, 158)) dxDrawRelativeText(k[1], 701, 200+i*30, 785+40, 239+(i+1)*30, tocolor(255, 255, 255, 255), 0.40, dxfont5_bebas_font, "left", "center") end end Serverside - no changes - Documentation can be found here.
-
How about you save it first inside of your memory? You can always upgrade it to SQL/MySQL later. Start with something as simple as this. local vehicleTrunkItems = {} function saveItemInVehicleTrunk (vehicle, item) local trunk = vehicleTrunkItems[vehicle] if not trunk then trunk = {} vehicleTrunkItems[vehicle] = trunk end trunk[#trunk + 1] = item end function getItemsInVehicleTrunk (vehicle) return vehicleTrunkItems[vehicle] or false end Define all functions you need, till it more or less works as you want.
-
You can also attach the eventHandler to the parent GUI, if you have at least one GUI parent. local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "window", true ) local button = {} function click () if source ~= myWindow then if source == button[1] then elseif source == button[2] then end end end button[1] = guiCreateButton( 0.3, 0.1, 0.2, 0.1, "button 1!", true, myWindow ) -- 1 button[2] = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "button 2!", true, myWindow ) -- 2 addEventHandler("onClientGUIClick", myWindow, click, true) -- true = propagation enabled
-
For both resources. A https://wiki.multitheftauto.com/wiki/TriggerEvent Set the base element to resourceRoot. B https://wiki.multitheftauto.com/wiki/AddEventHandler Set the attachedTo element to resourceRoot as well. And they will not interfere with each other, even when the event name is the same.
- 1 reply
-
- 1
-
-
Are we talking about 1 resource or multiple ones? Because resource A can't disable the cursor for resource B. GUI's do not have any influence on the cursor function.
-
No, only serverside with: https://wiki.multitheftauto.com/wiki/OnPlayerDamage Or clientside with: https://wiki.multitheftauto.com/wiki/OnClientPlayerDamage Or https://wiki.multitheftauto.com/wiki/OnClientPlayerWeaponFire + https://wiki.multitheftauto.com/wiki/ProcessLineOfSight
-
The very reason for the error is unclear. Because the issue is happening somewhere else. This is how you can get rid of the error, for this function only. function destroyLine ( line ) if contentMessages[line] then -- is there a `line` to destroy? for k,part in ipairs(contentMessages[line]) do destroyWidget(part) end contentMessages[line] = {} return true -- success < not required, but it might help you in the future solve the real issue. end return false -- something is wrong? end
-
You can use teaEncode, there are a wide range of plug-ins available for your web applications to decode it. Another option is for you to send it (internal) to a node application and transfer it from there across https.
-
That is not why I recommend using the browser. Sure a linter can tell you if it is broken or not. But it doesn't tell you anything about the object types. Breaking your JSON is annoying, but that doesn't happen as often as having your format being ruined by accidentally creating a mixed table. Your browser will tell you for each object if you are dealing with an array or an object. When it is ruined, you are not being able access your arrays formats as easy any more. Those must be strictly maintained. _________________________ About your main issue. How about you write a validator? validator = { { key = "money", func = function (value) return type(value) == "number" end }, { key = "name", func = function (value) return type(value) == "string" end }, }
