Jump to content

ds1-e

Scripting Moderators
  • Posts

    636
  • Joined

  • Days Won

    8

Everything posted by ds1-e

  1. If you are about not downloading them for players you can use: <script src="script.lua" type="client" cache="false"/> In meta.xml
  2. IIYAMA post is in this topic. He explained well when to use it. And about how i did that. Use int loop instead - which is faster, + use this function when drawing a crosshair, should fix most of problems.
  3. No, i've fixed it by myself, but i wouldn't share it here. You still have function which will do the job. But it's possible to make it better, and work nearly all the time. Or you can use IIYAMA example. I'll probably do the same, when i'll rewrite my gamemode.
  4. It's client. But don't forget to change ids of objects in condition. And this function doesn't work all time, so you would need to improve it a bit, and make things by yourself.
  5. It's in first post. But: function toggleWeaponsVisibility(key, keyState) if getPedWeaponSlot(getLocalPlayer()) == 6 then local alpha = 255 if keyState == "down" then alpha = 0 elseif keyState == "up" then alpha = 255 end local objects = getElementsByType("object", getRootElement(), true) for i = 1, #objects do if isElementAttachedToBone(objects[i]) and getElementModel(objects[i]) == 2763 or getElementModel(objects[i]) == 1820 or getElementModel(objects[i]) == 2708 or getElementModel(objects[i]) == 15036 then -- change id of models here setElementAlpha(objects[i], alpha) end end end end bindKey("aim_weapon", "both", toggleWeaponsVisibility) You need to change ids of objects.
  6. local dffFile = fileOpen("files/"..file_dff) local dffData = fileRead(dffFile, fileGetSize(dffFile)) dffData = base64Decode(teaDecode(dffData, file_key)) fileClose(dffFile) local txdFile = fileOpen("files/"..file_txd) local txdData = fileRead(txdFile, fileGetSize(txdFile)) txdData = base64Decode(teaDecode(txdData, file_key)) fileClose(txdFile) And later after that loading. Importing TXD and replacing DFF. local dff = engineLoadDFF(dffData) -- in case of incorrect key, shows warning here local txd = engineLoadTXD(txdData) -- and here. (bad path) So is there any way to avoid this? I know that it's only warning, but i want to keep debugscript 3 without errors/warnings.
  7. Hey. I need to send timer details from client-side to server-side. (Need to save it, and then load if player join again.) What should i do? 1. There's a way to send triggerServerEvent within onClientPlayerQuit? I've have tested it, but seems like this wouldn't work. 2. Sync timer in client and server side? Probably not best way so far, but i am not sure. 3. Or there's other, better way?
  8. Hey. I was doing some stuff with encoding .dff and .txd files. Nearly everything works, i wanna avoid those warnings in script, if decoding failed. (incorrect key) client.lua:83: Bad file path @ 'engineLoadDFF' [Ž°É‡"·:YÖîa´OúŚôaR] client.lua:84: Bad file path @ 'engineLoadTXD' [ĄEk] Probably i miss somewhere additional condition, but i am not sure.
  9. ds1-e

    Shader problem.

    bump. Still wanna get to work last one shader. texture gTexture0 < string textureState="0,Texture"; >; How i should apply shader value for it? I don't have any idea, how i could do it. This is from mta-helper.fx: //------------------------------------------------------------------------------------------ // textureState (partial) - String value should be a texture number followed by 'Texture' //------------------------------------------------------------------------------------------ texture gTexture0 < string textureState="0,Texture"; >; texture gTexture1 < string textureState="1,Texture"; >; texture gTexture2 < string textureState="2,Texture"; >; texture gTexture3 < string textureState="3,Texture"; >;
  10. Thank you. In case i would need to get vehicle which is related with this colshape it should be like this? local parent = getElementParent(vehicle) -- returns colshape userdata local child = getElementChild(parent, 0) -- returns vehicle userdata?
  11. Hey, as title says. Is there any good equivalent to the thing above? I would need to get colshape userdata - colshape attached to vehicle. elementData would be easiest way, but i am not happy to use it. I'm looking for good alternative. I prefer to use tables + manual sync instead. It's not a problem to get this when player hit colshape, the real problem begins when i need to get this when player is inside of car. This is temporary solution, which imo isn't good. -- server side example addCommandHandler("data", function(plr, command) local vehicle = getPedOccupiedVehicle(plr) if not vehicle then outputChatBox("You need to be in vehicle to get data.", plr) return end local parent = getElementAttachedTo(vehicle) outputChatBox(tostring(parent), plr) end) I was thinking about setElementParent/getElementParent. And i found this topic. Just want to know if this function can do the work.
  12. - Create 2 tables, client-side + server-side. - Save ped animation in both tables, server-side when creating a ped, and client-side using trigger(Latent)ClientEvent. - For client-side it will work only for players that are online so... You would need to send server-side table to latejoiner onPlayerLogin. - Use onClientElementStreamIn to apply this "fix". - Use onClientElementDestroy/onElementDestroy to clear data from tables. (in case of destroying peds) This is part of code which i've done sometime ago, of course it can be done better, and I used elementdata, which is probably don't needed because you can use "ped element" instead of it (userdata). -- client local deadPlayersCacheClient = { block = {}, animation = {}, } function OnElementClientStreamIn() if getElementType(source) == "ped" then local parent = getElementData(source, "core:parent") if parent then if deadPlayersCacheClient.block[parent] and deadPlayersCacheClient.animation[parent] then setPedAnimation(source, deadPlayersCacheClient.block[parent], deadPlayersCacheClient.animation[parent], -1, false, true, false, true) end end end end addEventHandler("onClientElementStreamIn", getRootElement(), OnElementClientStreamIn)
  13. I would like to do it with this way, however how can i sort items later, in this order how they are placed in table? I can't use ipairs, because it loop with numbers, and pairs loop doesn't sort.
  14. Hey, probably i'm a bit stuck with it. So as I mentioned before, in other topic related to tables, i decided to give up with elementData's and create temporary data system within tables + sqlite/mysql. (tables for keep data in-game, and sqlite/mysql to save it after player disconnect). Everything goes well until now. I thought about creating something equivalent to getElementData, which will return false or item and itemcount. In example code: -- part of code cut from gui inv local row = guiGridListAddRow(gridlistItems["inventory"]) guiGridListSetItemText(gridlistItems["inventory"], row, gridlistItems["inventory_colum"], "Secondary Weapon", true, false) for i, item in ipairs(inventoryItems["Secondary Weapon"]) do if getElementData(getLocalPlayer(), item[1]) and getElementData(getLocalPlayer(), item[1]) >= 1 then local row = guiGridListAddRow(gridlistItems["inventory"]) guiGridListSetItemText(gridlistItems["inventory"], row, gridlistItems["inventory_colum"], item[1], false, false) guiGridListSetItemText(gridlistItems["inventory"], row, gridlistItems["inventory_colum_amount"], getElementData(getLocalPlayer(), item[1]), false, false) if getElementData(getLocalPlayer(), "currentweapon_2") and item[1] == getElementData(getLocalPlayer(), "currentweapon_2") then guiGridListSetItemColor(gridlistItems["inventory"], row, gridlistItems["inventory_colum"], 0, 255, 0) guiGridListSetItemColor(gridlistItems["inventory"], row, gridlistItems["inventory_colum_amount"], 0, 255, 0) end end end But i don't really know how can i start with it. Functions like getPlayerItems, getItemsFromElement etc.
  15. Hey, is there anyway to manipulate camera after player death? Because standard death camera doesn't looks well. Change how it looks/focus on some place etc.
  16. ds1-e

    Is it possible?

    https://wiki.multitheftauto.com/wiki/Resource:Voice
  17. ds1-e

    Warp player to

    Want to teleport players to you? If so then: addCommandHandler("easr", function(cmd, player) local players = getElementsByType("player") local posX, posY, posZ = getElementPosition(player) for i, v in pairs(players) do setElementPosition(v, posX + math.random(5, 10), posY, posZ) end end)
  18. ds1-e

    Shader problem.

    Didn't worked. debugscript says it needs a texture, but got shader. Anyway thanks for trying to help, i already solved it. @XaskeL
  19. ds1-e

    Shader problem.

    Looks like solved. If someone else would have same problem use: dxUpdateScreenSource(screenSource, true) -- second argument should be true After applying shader with dxDrawImage.
×
×
  • Create New...