-
Posts
696 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Dzsozi (h03)
-
Try this: addEventHandler('onClientResourceStart', resourceRoot, function() local texture = dxCreateTexture("img/radar_map.jpg") if (texture) then dxSetTextureEdge(texture, 'border', tocolor(WaterColor[1], WaterColor[2], WaterColor[3], 255)) -- replace WaterColor[1] (and so on) with the water color of the map, use paint or photoshop and pipette tool to get the rgb numbers of the section end end ) ... dxDrawImage(X - worldW/2, mH/5 + (Y - worldH/2), worldW, worldH, texture, camZ, (x/(6000/worldW)), -(y/(6000/worldH)), tocolor(255, 255, 255, 255))
-
addEventHandler('onClientResourceStart', resourceRoot, function() if (texture) then -- should be the texture name of the map dxSetTextureEdge(texture, 'border', tocolor(WaterColor[1], WaterColor[2], WaterColor[3], 255)) -- replace WaterColor[1] (and so on) with the water color of the map, use paint or photoshop and pipette tool to get the rgb numbers of the section end end )
-
One more thing I can't fix. I don't have every vehicle in the table, how can I make a function inside these two functions (getVehicleCustomName and getVehicleBrand) to check if the given vehicle is inside a table or not, and if it is not then return the default name of the vehicle and for the brand return it to an empty string. Hope you understand what I mean. So for example I have the stallion inside the table, under the Imponte brand and it's name is Dukes, but I don't have the bravura inside the table. I am trying to make a hud display when I enter a vehicle the custom name and the brand of the vehicle is being displayed, but if I enter a vehicle that is not inside the table I would like to get the default vehicle name of the vehicle and for the brand, if there is no brand for the vehicle an empty string like "". Here's my current script with the export functions: function getVehicleBrand(vehicle) for k,v in pairs(vehicleTable) do for i=1,#v do if v[i].modelID ~= nil then if tonumber(vehicle) then if v[i].modelID == tonumber(vehicle) then return k end elseif tostring(vehicle) then if getVehicleNameFromModel(v[i].modelID) == tostring(vehicle) or tostring(v[i].vehicleName) == tostring(vehicle) then return k end else return "" end else return "" end end end end function getVehicleCustomName(vehicle) for k,v in pairs(vehicleTable) do for i=1,#v do if v[i].modelID ~= nil then if tonumber(vehicle) then if v[i].modelID == tonumber(vehicle) then return v[i].vehicleName end elseif tostring(vehicle) then if getVehicleNameFromModel(v[i].modelID) == tostring(vehicle) or tostring(v[i].vehicleName) == tostring(vehicle) then return v[i].vehicleName end else return getVehicleNameFromModel(vehicle) end else return getVehicleNameFromModel(vehicle) end end end end
-
Thank you, I managed to do it! This script works well, I get the custom name of the model and the brand from the table, but regarding the performance, is this "correct"? Or is there any better way to do this? function getVehicleBrand(vehicle) for k,v in pairs(vehicleTable) do for i=1,#v do if not tonumber(vehicle) and not tostring(vehicle) then if v[i].modelID == getElementModel(vehicle) then return tostring(k) end elseif tonumber(vehicle) then if v[i].modelID == tonumber(vehicle) then return tostring(k) end elseif tostring(vehicle) then if getVehicleNameFromModel(v[i].modelID) == tostring(vehicle) or tostring(v[i].vehicleName) == tostring(vehicle) then return tostring(k) end else return false end end end end function getVehicleCustomName(vehicle) for k,v in pairs(vehicleTable) do for i=1,#v do if not tonumber(vehicle) and not tostring(vehicle) then if v[i].modelID == getElementModel(vehicle) then return tostring(v[i].vehicleName) end elseif tonumber(vehicle) then if v[i].modelID == tonumber(vehicle) then return tostring(v[i].vehicleName) end elseif tostring(vehicle) then if getVehicleNameFromModel(v[i].modelID) == tostring(vehicle) or tostring(v[i].vehicleName) == tostring(vehicle) then return tostring(v[i].vehicleName) end else return false end end end end outputChatBox(getVehicleBrand("Stallion") .. ", " .. getVehicleCustomName(439))
-
Help please.
-
Are you sure that you want to bind hminus function to every key?
-
Thank you for your quick answer, you helped me alot right now! I would like to ask for help with one more thing. How can I do that function I was talking about? So for example I have a function like getVehicleBrand(vehicle) and how can I return the brand of the given vehicle? And the same with the vehicle name? How can I return the custom vehicle name of a given vehicle?
-
Hi! I would like to do a little script for my server, where I can give custom names and a new thing, brands for vehicles, and within this script I would like to replace vehicle mods as well, if there is any. The problem is that I don't know how to get the things inside a table that is inside a table. Let me show my script to you and you will understand: vehicleTable = { ["Maibatsu"] = { {vehicleName="Penumbra", fileName="mods/penumbra", modelID=436}, }, ["Benefactor"] = { {vehicleName="Schwartzer", fileName="mods/schwartzer", modelID=445}, }, } Here is the table for brands. Inside the vehicleTable I have created a new table for the vehicles with the brands. What I would like to do is replace the vehicle models (model ids are given) but I don't know how to get this variable, how to loop that, how to call back that, I don't know how to say or what it is called, here's what I tried, but it's not working: function loadMods() for index, mod in pairs(vehicleTable) do txd = engineLoadTXD ( vehicleTable[index].fileName .. ".txd" ) engineImportTXD ( txd, vehicleTable[index].modelID ) dff = engineLoadDFF ( vehicleTable[index].fileName .. ".dff", vehicleTable[index].modelID ) engineReplaceModel ( dff, vehicleTable[index].modelID ) end end addEventHandler("onClientResourceStart",resourceRoot, function () loadMods() end) Yes, these are in two different scripts and yes, they are in the same resource, and the script with the table is marked as a "shared" type, so there is no problem with that, I just don't know how to get the filename and the modelid variables inside a table which is inside a table. Also, how can I make an export function for getting the custom vehicle name and brand of the vehicle? EDIT: I get this error in debugscript: replaceC.lua:3 attempt to concatenate field 'fileName' (a nil value) I don't know what does that mean.
-
Why don't you just recall the function where it applies the shaders? So for example: function lalala() if(#shadersTab > 0)then for i,shaderr in ipairs(shadersTab)do applyShaders() end end end function applyShaders() -- this is the function where you replace the textures end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource())) -- or whatever is here If I understand you - and what you are trying to do - correctly, that's what you are trying to do.
-
I understand that I can replace textures with different ones at the same time more than once, and I cannot do that with models, but I would like to just give it a try and try out the custom added weapons from the dayz mod now. If it doesn't work how I want it to work, then I will try to do it like you said, but I'm just interested about the DayZ method, so I can learn and try it.
-
But I would like to do it in a way like the DayZ gamemode has it, since it is just replacing the models and handles the functions, there is no need to create objects, play around with positions. I am also afraid of objects because I think they wouldn't be steady if I move my camera so fast.
-
I looked up the DayZ open source files and I found that it is made using setElementData to players, but I can't find how is it being handled, where is it set. I just found the part where the weapons are being replaced and I would like to try doing it that way. Could somebody help me where I can find the handling of this element data? Which lua file? I found these: https://github.com/mtadayz/MTADayZ/blob/master/DayZ/tables/table_general.lua https://github.com/mtadayz/MTADayZ/blob/master/DayZ/models/weaponswitch.lua
-
Haha, thank you!!
-
Thanks! That's what I did as well, I originally created it for VC, if you are interested I have the Vice City district names, positions and sizes already made in the table. You might have to change positions tho.
-
With this script you are able to create your custom districts in MTA:SA, this is useful for almost "anything" (custom maps with your own districts, gang zones (which might require a little editing), protect zones, etc.)! You can create your own districts in the districtC.lua file, an example is given. Export functions: - getDistrictName(element) Get the custom district name of an element (works client and server side) - onElementDistrictChange This is a custom event, the source of this event is the element that changed district (currently working only client-side) PARAMETERS: districtName - An integer representing the name of the current custom district Note that the event works on client-side, but it is possible to do it on server-side if it's needed. !! The source of the onElementDistrictChange event is the element that changed the district, could be a vehicle, a ped, a player, anything that is an element. !! An example script for using the event and getting the district name is given in the exampleC.lua file, check that for usage and the example command. Future versions MIGHT contain: - Server-sided onElementDistrictChange event - A command to add a district manually Special thanks to for helping with the script to: Tails, pa3ck If you have any question just write a comment! Feel free to edit, but please, keep the credits. DOWNLOAD: https://community.multitheftauto.com/index.php?p=resources&s=details&id=13834 Images: /getpos - If currently NOT in a custom district /getpos - If currently in a custom district Entering a custom district
-
It works now, thank you! I also had to make some changes in the test resource: function test2(districtName) outputChatBox(getPlayerName(getLocalPlayer()).." entered "..districtName) end addEventHandler("onDistrictChange", getRootElement(), test2) If anybody is interested here's the full script: local district = {} local districts = { -- x, y, width, height, name -- insert your custom districts here { 0, 0, 100, 100, "Example District Name", 255, 225, 255 }, -- last three variables are the color of the radar area } function createDistricts() for k, v in ipairs(districts) do --createRadarArea(v[1], v[2], v[3], v[4], v[6], v[7], v[8], 75) -- to make the districts visible on the radar, use setDevelopmentMode(true) and /showcol 1 command to see the colshapes in the real world with a wireframe around it table.insert(district, {createColCuboid(v[1], v[2], -50, v[3]/1.5, v[4]/1.5, 1000)}) end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), createDistricts) addEvent("onDistrictChange", true) function districtChangeEvent(hitElement) if hitElement and isElement(hitElement) then for i=1,#district do if district[i][1] == source then triggerEvent("onDistrictChange", hitElement, districts[i][5]) end end end end addEventHandler("onClientColShapeHit", root, districtChangeEvent) function getDistrictName(element) if isElement(element) then for i=1,#district do if isElementWithinColShape(element,district[i][1]) then return districts[i][5] end end return "" end end And the meta: <meta> <script src="districtC.lua" type="client" /> <export function="getDistrictName" type="client"/> <export function="onDistrictChange" type="client"/> </meta>
-
It is still not working for some reason.
-
It's still not working.
-
I'm not sure what am I missing or what I did wrong, but I don't get any output. Here are the export functions: addEvent("onDistrictChange", true) function districtChangeEvent(hitElement) for i=1,#district do if district[i] == source then triggerEvent("onDistrictChange", hitElement, source) end end end addEventHandler("onClientColShapeHit", root, districtChangeEvent) --addEventHandler("onDistrictChange", root, districtChangeEvent) The meta file: <script src="zoneC.lua" type="client" /> <export function="getDistrictName" type="client"/> <export function="onDistrictChange" type="client"/> and the other resource with the test function: function test(districtName) outputChatBox(getPlayerName(source).." entered "..districtName) end addEventHandler("onDistrictChange", root, test) I changed the source to hitElement and districts[5] to source, since the source of the onClientColShapeHit event is the colshape and the element is the first argument. I don't know if it is right, I even tried with your version but it was not working either. What could be the problem?
-
I would like to ask for help with one more thing... I was trying to do an event which detects if the district of the element was changed, so I could output the change in the chatbox from other resources or make a dxDrawText with fading when a player goes from Vice Point to Downtown for example, like the default zone name hud does, but I can't manage to get it to work, and I don't get any errors in the debugscript. Is this even possible? I was trying with something like this function getDistrictName(element) if isElement(element) then for i=1,#district do if isElementWithinColShape(element,district[i][1]) then return districts[i][5] end end return "" end end addEvent("onDistrictChange", true) function districtChangeEvent() for i=1,#district do if district[i] == source then triggerEvent("onDistrictChange", root) end end end addEventHandler("onClientColShapeHit", root, districtChangeEvent) ---------------------------- -- and in another resource ---------------------------- function test() outputChatBox(tostring(exports.vice_core:getDistrictName(getLocalPlayer()))) end addEventHandler("onDistrictChange", root, test) I don't know if I done it right or not, probably not if it is not working.
-
Thank you very much for your help!
-
So how I could make an export function for getting the current district/zone name of an element I would like to get the zone name of?
-
Why do I have to do that manually and also, why do I have to get the element coords? I can use isElementWithinColShape then.
-
I would like to ask just one more thing. How can I get the district name of a specified element? So I can get that from other resources with an export function, for example display it on the radar or get the district name of a vehicle for a mission. I guess somehow with isElementWithinColShape, but I am not sure how exactly.
