-
Posts
6,058 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
These brackets are used for hidden folders: [hidden folder] The resource name is the folder that contains DIRECTLY the meta.xml.
-
@Argom These are more or less the basic components for a not moving image, which can be enhanced with a moving image later on. (order matters): https://wiki.multitheftauto.com/wiki/DxCreateTexture function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end <function start> https://wiki.multitheftauto.com/wiki/GetLocalPlayer https://wiki.multitheftauto.com/wiki/GetPedOccupiedVehicle https://wiki.multitheftauto.com/wiki/GetElementMatrix x1, y1, z1 = getPositionFromElementOffset(vehicle, 0, 0, 0) x2, y2, z2 = getPositionFromElementOffset(vehicle, 3, 0, 0) https://wiki.multitheftauto.com/wiki/DxDrawMaterialLine3D <function end> https://wiki.multitheftauto.com/wiki/OnClientPreRender
-
If you want to create environments, OOP would be another way and maybe also use a meta table to inherit properties But I can understand that it might be a little bit complex, especially when you are doing it like this: showContentConstructor = { new = function (self) local newShowContent = {} setmetatable(newShowContent, self.metaTable) return newShowContent end, prototype = { -- initial properties text = "<please set text>", sayHI = function (self) return outputChatBox(self.text) end } } -- Set the meta table as lookup table when the information is not found in the instance table showContentConstructor.metaTable = {__index = showContentConstructor.prototype} -- create new instances showContent1 = showContentConstructor:new() showContent2 = showContentConstructor:new() showContent1:sayHI() showContent1.text = "test1" showContent1:sayHI() showContent2:sayHI() showContent2.text = "test2" showContent2:sayHI() Unfortunately there are no options without tables afaik, so you really need to be able to understand the basics of tables, if you want to build this. So I recommend doing it the way as in my previous reply, which should be easy to do.
-
A function name is just a variable. When creating a function with the same name, you will overwrite that variable/function. You can solve your problem with a table. Main file: showContent = {} setTimer(function () -- add a little delay so that the function can be added before calling it. showContent[1]() showContent[2]() showContent[3]() end, 100, 1) For each other file: local fileID = --[[...]] showContent[fileID] = function () sayHI() end
-
You can't give a player to another player. givePlayerMoney ( killer, source ) Some extra validation might be required, not only a player can kill another player. if ( killer ) and ( killer ~= source ) and getElementType(killer) == "player" and money > 0 then givePlayerMoney ( killer, money ) end
-
If that is the case, then your code didn't wait for the 2 events per model (txd + dff). That is the moment you can apply the model, not a millisecond before that.
-
Here: addEventHandler("onClientResourceStart", resourceRoot, function ( ) setTimer ( function ( ) refreshList ( ) local file = xmlLoadFile ( '@saving.xml', 'data' ) if file then for i, v in ipairs ( xmlNodeGetChildren( file ) ) do local name = tostring( xmlNodeGetAttribute( v, 'name' ) ) local enabled = toboolean( xmlNodeGetAttribute( v, 'enabled' ) ) if ( getModData(name) and tostring( enabled ):lower ( ) ~= "false" ) then --[[ here ]] end end end end, 500, 1 ) end ) (download + register the name) local immediatelyLoading = {} -- -- onClientResourceStart -- local _, _, dff, txd = getModData(name) dff = 'modlar/' .. dff txd = 'modlar/' .. txd -- set up status local loadingStatus = { value = 2, name = name, dff = dff, txd = txd } -- set up reference to status immediatelyLoading[dff] = loadingStatus immediatelyLoading[txd] = loadingStatus -- -- onClientFileDownloadComplete -- local loadingStatus = immediatelyLoading[file] local value = loadingStatus.value value = value - 1 loadingStatus.value = value if value == 0 then immediatelyLoading[loadingStatus.dff] = nil -- clear immediatelyLoading[loadingStatus.txd] = nil -- clear local name = immediatelyLoading.name -- load model end And also here: function onDownloadFinish (file, success) if ( source == resourceRoot ) then if ( success ) then refreshList() new("Your mod has been successfully downloaded ("..tostring(file)..")", 0, 255, 0) end end end addEventHandler ( "onClientFileDownloadComplete", getRootElement(), onDownloadFinish ) Using registration to load the mod immediately when both files are downloaded.
-
Because the files haven't been validated. Use the downloadFile function again to validate if the correct files are placed on the client his pc. Note: If the correct file is found, no re-download will be starting. After the event onClientDownloadComplete, for dff and txd you can start the replacement process.
-
dbQuery is used for retrieving information from the database. Even if you are only inserting data, there is still information returned about the success/failure state. dbPoll is used to collect that information (from the queryHandle). Since you didn't use that function on the queryHandle = the variable you named `zapisz` , there was no attempt to collect that information, so it was still waiting to be collected and therefore it gave you that warning. If you do not think you need that information, you can better use dbExec. That is just a one-way trip.
-
Should be fine. As long as you do not over do it. Note: The position X and Y can also be used for the weather.
-
There is also a useful function you can use. https://wiki.multitheftauto.com/wiki/CheckPassiveTimer Which represents DNL291's second way, but with it's own ecosystem.
-
A combination. - hit events is for starting the timer. - The timer is used to check if everybody is inside of the colshape meets all the criteria. Like if everybody is still alive or inside of a vehicle. For a basic script, bandwidth is only used when a player hits or leaves a colshape. You do not have control over that, since it is always working even if you do not add eventHandlers. But keep in mind that if you use that timer to synchronize the same information over and over, sure that can be bad.
-
Is freeroam start able? Since the stage resource wants these resources to be working before you can start it: freeroam realdriveby emerlights You can also delete this include xml tag from stage: <include resource="freeroam" /> Which allows you to start it, but first make sure freeroam can start since that is better idea.
-
Cool When creating your vehicles you can link the ID to the vehicle in a few ways. Either by table: No synchronization server/client Across resources if you use exports. More maintenance (if a vehicle gets deleted) local linkVehiclesToDataBase = { element_to_ID = {}, ID_to_element = {} } function setVehicleByDataBaseID (ID, vehicle) linkVehiclesToDataBase.ID_to_element[ID] = vehicle return true end function getVehicleByDataBaseID (ID) return linkVehiclesToDataBase.ID_to_element[ID] end function setDataBaseIDByVehicle (vehicle, ID) linkVehiclesToDataBase.element_to_ID[vehicle] = ID return true end function getDataBaseIDByVehicle (vehicle) return linkVehiclesToDataBase.element_to_ID[vehicle] end --------- local ID = --... local vehicle = createVehicle(--[[...]]) setDataBaseIDByVehicle (vehicle, ID) -- enables: getDataBaseIDByVehicle (vehicle) setVehicleByDataBaseID (ID, vehicle) -- enables: getVehicleByDataBaseID (ID) Or by ID: setElementID ( vehicle, "vehicle-database-ID:" .. ID) https://wiki.multitheftauto.com/wiki/SetElementID Less maintenance Synchronization server/client Across resources Problem that can occur: Double ID's created by other resources or ID overwrite by other resources. + https://wiki.multitheftauto.com/wiki/GetElementID https://wiki.multitheftauto.com/wiki/GetElementByID
-
You can loop through all vehicles and check if their plate is the same as the item in the database. But it is easier and more efficient to set an identifier when you create the vehicle. What is used as your database primary key per vehicle?
-
I am not sure why you want to pass the plate into that function. But the function requires a player, not a plate. Basically this would give you the closest vehicle from the player that executed the event: local vehicle = getNearestVehicle( client ) But if you also want to pass the plate as well, sure that is also possible. Adding a second argument: local vehicle = getNearestVehicle( client, vehicleplate ) And adding second parameter: function getNearestVehicle( player, vehicleplate ) Note: If you do this, you will have to do something within this function with the plate, else it has no functionality.
-
gridlist load data only if I restart the resource (thisdp's GUI)
IIYAMA replied to thund3rbird23's topic in Scripting
Did you actually select something from the list? (and is it still selected when you clicked the button?) -
gridlist load data only if I restart the resource (thisdp's GUI)
IIYAMA replied to thund3rbird23's topic in Scripting
So yes. Since you clicked on the button, which makes the button the source and not the gridlist. So that condition will never be true. Just change it to: if gridlist then -- or: if isElement(gridlist) then -- < if you do not trust anything Now you check if the gridlist is actually created. How does it feel to debug like this? Line for line until you know where and what the problem is. -
gridlist load data only if I restart the resource (thisdp's GUI)
IIYAMA replied to thund3rbird23's topic in Scripting
<A> Now debug each condition until you find the one that isn't met: iprint("function call") if button == "left" and state == "down" then iprint("correct mouse button") if source == gridlist then iprint("source is correct") local Selected = DGS:dgsGridListGetSelectedItem(gridlist) -- keep in mind that this variable starts with a capital S if Selected ~= -1 then iprint("did select something Selected") <B> You can also do it like this, debugging literally the condition, before doing the condition itself: (which takes more time to set-up, but gives also a lot more information) iprint("correct mouse button:", button == "left" and state == "down", ">input>", button, state) if button == "left" and state == "down" then iprint("source is correct:", source == gridlist, ">input>", source, gridlist) if source == gridlist then local Selected = DGS:dgsGridListGetSelectedItem(gridlist) -- keep in mind that this variable starts with a capital S iprint("Selected is correct:", Selected ~= -1, ">input>", Selected ) if Selected ~= -1 then Normally I start with <A>, finding out the location of the problem and then do <B> to figure out what is actually going on. (Edit, it seems like \[ B \] makes my text bold...) -
gridlist load data only if I restart the resource (thisdp's GUI)
IIYAMA replied to thund3rbird23's topic in Scripting
Any errors? Does the function SellBttn... gets called after clicking? (Just the function, not all the condition within) -
gridlist load data only if I restart the resource (thisdp's GUI)
IIYAMA replied to thund3rbird23's topic in Scripting
You will have to run this part, when the data is available: (line 7 until 11) local items = getElementData(localPlayer, "weaponmodel") column = DGS:dgsGridListAddColumn(gridlist, "Weapons", 0.5) for k, v in ipairs(items) do row = DGS:dgsGridListAddRow(gridlist, v[1]) DGS:dgsGridListSetItemText ( gridlist, row, column, v[1] ) end local items = getElementData(localPlayer, "weaponmodel") And if you only do this once, you probably do not need elementdata. addEvent("onLoadOwnWeapons", true) addEventHandler("onLoadOwnWeapons", localPlayer, function (items) column = DGS:dgsGridListAddColumn(gridlist, "Weapons", 0.5) -- < this line can be moved back to it's original spot. for k, v in ipairs(items) do row = DGS:dgsGridListAddRow(gridlist, v[1]) DGS:dgsGridListSetItemText ( gridlist, row, column, v[1] ) end end, false) -
gridlist load data only if I restart the resource (thisdp's GUI)
IIYAMA replied to thund3rbird23's topic in Scripting
When the event onLoadOwnWeapons is fired, your data is ready to be used. -
gridlist load data only if I restart the resource (thisdp's GUI)
IIYAMA replied to thund3rbird23's topic in Scripting
The second situation is obvious, because the data isn't available yet. The first and third are a little bit strange. Maybe it is for some unknown reason also related to the timing. Debug code: -- serverside -- BEFORE line 12 newTable.tickCount = getTickCount() -- verification -- line 12: setElementData(source, "weaponmodel", newTable) -- AFTER line 12 triggerClientEvent(client, "onLoadOwnWeapons", client, newTable) -- client addEvent("onLoadOwnWeapons", true) addEventHandler("onLoadOwnWeapons", localPlayer, function (items2) local items = getElementData(localPlayer, "weaponmodel") iprint("\n\nitems:", items, "\n items2:", items2, "\n\n") end, false) And compare those values. (+ screenshot) -
Yup, As the resource stated: Might be able to modify it, so that you reduce the camera updates to 1/3 of the total fps, but I am not sure if that looks nice since it is an inconsistent frame rate.