-
Posts
6,089 -
Joined
-
Last visited
-
Days Won
216
Everything posted by IIYAMA
-
You go from your code. To the Minigame code And back to Your code But currently your target player, is not passed in to the minigame. See: exports.s_minigames:startMinigame("balance", "healSuccess", "healFailed", 1, 10000) There is no sourcePlayer included in to the export. Which means it is not available there and also not available to where you want to re-use that specific player. So what you need to figure out is the syntax of this export function and if it allows you to add your own data to it. If not, then you need to modify it, so that it does: Yes We Can.
-
A lot more than exports yes. Events are global. But that doesn't mean they are bad. They can be very useful for `events`. But if you can use exports, those can handle really a lot of data. If you observe those closely, you could even write your own event scope based on exports. The main issues lie with: Propagation (while triggering) Like you do this: setElementPosition(root, 0,0,0) This will move every possible element to 0,0,0. Players, vehicles, objects, peds, elements without physics. And for triggerServerClient event, no it probably doesn't send multiple messages (I hope lol). But it does go over every element. This might give the lowest impact. Not sure if propagation will help if there are no children, but at least it will not search for children. local element = createElement("triggerElements", "resource-" .. getResourceName(getThisResource())) setElementCallPropagationEnabled ( element, false) With the amount of listeners. The longer this list the longer it takes. (depending on the context)
-
This is a loop, it goes trough all items, in this case all players. And can be stopped with the keyword break or return. What if you add another export function, for the call : (The only strange thing about it is that in the orginal code the slot id is not being used. Could itemsTable be a meta table?) function hasItemAndData1(sourceElement, itemId, data1) if itemsTable[sourceElement] then for k, v in pairs(itemsTable[sourceElement]) do if v.itemId == itemId and v.data1 == data1 then return v end end end return false end
-
Are you telling me that there is no function for? Maybe search a little bit more? local ownerId = tonumber(getElementDatabaseId(player)) local ownerType = getElementType(player) -- "player" if ownerId then end query should look a bit like this. SELECT data1 FROM items WHERE itemId = 43 AND ownerId = ? AND ownerType = ? LIMIT 1
-
No. The bug is caused, because you are only storing the phonenumber. But not using it when checking if the number is matching. Where in this code do you see that value is used? function hasItem(sourceElement, itemId) if itemsTable[sourceElement] then for k, v in pairs(itemsTable[sourceElement]) do if v.itemId == itemId then return v end end end return false end I do not see it. Only matching the itemid, which is not the value. Is there perhaps this function: getItemValue ?
-
exports.s_inventory:hasItem(v, 43, number) function hasItem(sourceElement, itemId) The number is not being used. How does the giveItem looks like? One thing that could work is: exports.s_inventory:giveItem(playerSource, "phoneNumber-" .. tostring(tonumber(phoneID)), 1) if v and number and exports.s_inventory:hasItem(v, "phoneNumber-" .. tostring(tonumber(number))) then
-
This goes wrong. It seems like Jeff has an item with the selected number. Make sure to check the syntax of this function, the function itself and his data in the database.
-
Add local in front of it, it should be scoped. local targetPlayer = callMember(number) With other words the callMember function does not work correctly. Go debug it! It is not an MTA function, so you will have to search for it in your files.
-
Is the callMember function not broken then? Or is the number incorrect? Debug this! This loop makes no sense. What if there are accidentally two phones with the same number? for k, v in ipairs(checkID) do Limit the query "SELECT * FROM phones WHERE number = ? LIMIT 1" And get only the first result: if #checkID == 1 then local v = checkID[1]
-
Send the message to the root. Which includes all players.(currently ingame) triggerClientEvent(root, "showMenu",
-
That is line 5 for us. If table is higher than 0? OR If table item count is higher than 0? if #result > 0 then
-
You will need triggerClientEvent for that. exports only work on the same client/server-side. Server (resource 1) triggerClientEvent (source, "fill in eventName", source, itemValue) Client (resource 1) It is important to place the addEvent on the resource that is triggering, this reduces errors: "event isn't added" addEvent("fill in eventName", true) Client (resource 2) addEventHandler("fill in eventName", localPlayer, showPhoneFunction, false)
-
localPlayer doesn't exist on serverside. It only exist on your own MTA san application, which is clientside. You need to define which player is going to receive the message on serverside. You wrote two times lang1. You forgot to write a fallback when no language is selected. local language = getElementData(source,"language") if not language or language == lang1 then outputChatBox("#FFFFFF "..nickA.. " #00CC40killed #FFFFFF ["..kills.."] #00CC40players!", source,255,0,0,true) elseif language == lang2 then outputChatBox("#FFFFFF "..nickA.. " #00CC40zabil #FFFFFF ["..kills.."] #00CC40hračov na CW!", source,255,0,0,true) end
-
You are already using elementdata, in the most possible global way. So the selected language is also available there.
-
Is it just me being blind or are you making a call from serverside to clientside? (Which is not allowed)
-
Debug the export list and see if the resource can be found. iprint(exports["s_phone"]) Else as I said before, use the call function. That one has never failed for me without a logic error.
-
You could save it in to an XML file > clientside There is a resource that does that automatic for you: https://community.multitheftauto.com/index.php?p=resources&s=details&id=16187 Including a wiki guide: https://wiki.multitheftauto.com/wiki/XmlSaveData No need for saving such data in to a database, as the user wants to have this info when he joins and not when he logins.
-
dbPrepareString does not apply changes to the database. The most logic reason I can think of for the dbPrepareString databaseConnection argument, are the string escape rules. But that is also where my knowledge ends. A database has a query queue, so if your timing is correct on Lua, the timing on the database is also correct.
-
I only gave you the concept of how traffic resource is doing that. You think you wouldn't find an enchanted version of that same code in the traffic resource? I am pretty sure there is, which is where you could start your search + understanding the code.
-
setVehicleHandling(vehicle, "engineAcceleration", handling.engineAcceleration + 0.4) setVehicleHandling(vehicle, "maxVelocity", handling.maxVelocity + 19)
-
Take a look at this function: https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPointAndSegment2D This function allows you to calculate the shortest distance between a line and a point. If you did that for every line between the notes, you would be able to figure out which one is the closest to your ped or car.
-
Too scared to show your code? The people that do not show their code, are often using code that is not theirs and they are very well aware of that. Not sure if that is the case with you, but it is absolutely ? ! ? ! ? ! ? to make sure that nobody can help you anyway!
-
You know that you already send it right? (That is if you did save that information) Then you do not have to ask it again, which means no extra bandwidth. MTA messages are always in the correct order delivered because of the TCP data transfer protocol. And they will always be delivered, except when the player timed out and get kicked out of the server. If that has happened then you forgot to register which actions are currently going on in your server and also forgot to send that information to the new joined player.
- 7 replies
-
- 1
-
-
- element data
- synchronization
-
(and 1 more)
Tagged with:
-
There is no best way. Just be aware of the large amount of downsides of elementdata. Elementdata is nice for some functionalities, but do not use it when you have a scenario where it's features are not being used. Tables are pure for storing data on a player his computer. This data type only exist within a specific resource. It is very fast and clean. And cleans itself after the resource has stopped. Elementdata is a feature, that allows you to bind data on to an element. This data is available on all resources as it has left the Lua environment. Because the data leaves the Lua environment, it is not deleted when the resource stops. It is only deleted when the element is destroyed or when it is manually removed. By default this data is also shared with the server and all other players. Great! (if you want that) > Note: it can also quickly take over a large part of the network bandwidth when over using it. (results in Lag) But luckily it is possible to not share it with the server and the other players. bool setElementData ( element theElement, string key, var value [, bool synchronize = true ] ) Turn that OFF, by set it to false. Be aware: by default it is ON. Another benefit as well as a disadvantage is that element data has it's own event: https://wiki.multitheftauto.com/wiki/OnElementDataChange https://wiki.multitheftauto.com/wiki/OnClientElementDataChange Which gets triggered when the data changes. It is a nice feature, but it also uses a lot of performance. My recommendation Do only pick elementdata when you specific need to bind data to an element to SHARE it with another resource or other players. Do not over use elementdata. Be aware that elementdata is not data stored in your resource, but bound to your elements. Use tables everywhere you do no have to rely of elementdata features. Most of the time a triggerServerEvent is enough to share data with the server. Elementdata is a wild card.
-
Fade the camera to black. https://wiki.multitheftauto.com/wiki/FadeCamera Move the player out of the area. 0, 0, -10 https://wiki.multitheftauto.com/wiki/SetElementPosition And if the resource you use allows it, a dead player is a good default. (Be aware that you might have to modify the resource killmessages, to not show any death messages when a player despawns) https://wiki.multitheftauto.com/wiki/KillPed De-attach the camera to another position. Recommend far away from the player. 0, 0, 10000 This will make sure no unwanted player events will be triggered. https://wiki.multitheftauto.com/wiki/SetCameraMatrix
- 1 reply
-
- 1
-
