Jump to content

IIYAMA

Moderators
  • Posts

    6,089
  • Joined

  • Last visited

  • Days Won

    216

Everything posted by IIYAMA

  1. You can't use triggerClientEvent to return values. Only MTA-Communication-Enchantment can do that with a callback, like this: And I am not even sure that you need to do that, you can already provide that information on your first triggerServerEvent. triggerServerEvent("GiveWeaponToPlayer", root, Ammo) addEvent("GiveWeaponToPlayer", true) addEventHandler("GiveWeaponToPlayer", root, function(Ammo_) local prl = client giveWeapon(prl, 22, Ammo_, true) end)
  2. Maybe, there is no information about console being available here: https://wiki.multitheftauto.com/wiki/ExecuteCommandHandler So I am not sure if that is supported. But if you want to try that, you need to provide the element console and not the string "console".
  3. Wiki doesn't indicates that the client version of the event can be cancelled. https://wiki.multitheftauto.com/wiki/OnClientPickupHit While on serverside there is an indication: Cancel effect If this event is canceled, the pickup does not disappear and the player does not receive its bonus. https://wiki.multitheftauto.com/wiki/OnPickupHit So you will have to create it on serverside. dano = {} local player = source -- ... dano[player] = true -- block dano[player] = nil -- unblock / clear if dano[player] then end
  4. Set it to 2000, not 10000.
  5. Afaik the max vehicle health is +/- 2000. (Initial health is 1000.)
  6. If you find it difficult to work with the event system, you can also try this out: Example:
  7. Basic example: (but doesn't work very well with multiple players, since serverside is 1 environment and clientside an environment per player) triggerServerEvent ( "setAmmo", resourceRoot, Ammo) addEvent("setAmmo", true) addEventHandler("setAmmo", resourceRoot, function (Ammo_) Ammo = Ammo_ end, false)
  8. Not likely, since that only will work when there is an admin online which you can use as executor. https://wiki.multitheftauto.com/wiki/Element/Console It is better to solve that at the source: local console = getElementChildren ( root, "console")[1] addCommandHandler ( "somecommand", function ( playerSource, commandName ) if console == playerSource or --[[ ACL check]] then end end) Option A local console = getElementChildren ( root, "console")[1] if console == playerSource then end Option B if getElementType(playerSource) == "console" then end
  9. I have uploaded an uncompiled version. Because compiled scripts are not healthy for developers. ?
  10. I have uploaded it to the community so that it is now better accessible for everybody. ? https://community.multitheftauto.com/index.php?p=resources&s=details&id=18170
  11. That is not it. hmmm Maybe: testLineAgainstWater https://wiki.multitheftauto.com/wiki/TestLineAgainstWater
  12. Either the anti cheat (DayZ) or a custom damage script (DayZ). Try to search for getPedOxygenLevel inside of all the scripts from DayZ. Or search for isElementInWater instead. And try to disable it there. With notepad++ you can search in directories instead of file by file. (But make sure to filter on .Lua files only, else you will also be searching inside of binary files like images and mods, which takes long...)
  13. Not sure to be honest. 4 should be fine. If you run out of VRAM, it could be possible for the rendertarget to fail. Not sure what kind of hardware you use. iprint(dxGetStatus ().VideoMemoryFreeForMTA) https://wiki.multitheftauto.com/wiki/DxGetStatus Also checking for an texture memory leak isn't a bad idea. iprint(#getElementsByType("texture")) -- should be showing the total textures from all resources
  14. As Bonsai said about creating it once. You currently have created a memory leak, which might play a role in this strange behaviour. A render target is an element, which is attached to the element tree, not just a value you can overwrite. In your case you might want to destroy it first, every time you display new top times (since your height is variable). if isElement(toptimesRT) then destroyElement(toptimesRT) end toptimesRT = dxCreateRenderTarget(sizeX,sizeY,true)
  15. It is not possible when the vehicle is damageproof, unless you use events that are fired before the damage, like onClientPlayerWeaponFire and onClientVehicleCollision.
  16. That condition you use inside of your loop is not very useful. All items have item text, even if they are empty. And your gridlist doesn't update, because you are not updating it with the right function. https://wiki.multitheftauto.com/wiki/GuiGridListSetItemText If you want to update just the label, that loop is not required. Make sure you save each sub table on to an item. Then you can get the selected item and get the data from it. https://wiki.multitheftauto.com/wiki/GuiGridListSetItemData https://wiki.multitheftauto.com/wiki/GuiGridListGetItemData
  17. This looks like it is a leaked resource. If it is not, send me a pm with the link to the source for verification. Source verified: https://github.com/ESX-Org/esx_vehicleshop
  18. It is not as if players can download every file from the server. If they could, they would be able to steal all your stuff. You need to serve the file first with a webserver. Read: https://wiki.multitheftauto.com/wiki/Resource_Web_Access <html src="sound.mp3" raw="true" />
  19. After you have set-up your meta table + overwrite exports. https://www.tutorialspoint.com/Lua/lua_metatables.htm --[[ ... ]] __index = function(mytable, key) local resource = getResourceFromName(key) if not resource then return false end return function (...) return call(resource, ...) end end --[[ ... ]] It is not 100% the same, but you got the idea.
  20. You can also use call instead of exports. Which uses a static resource pointer that doesn't change when a resource restarts. Less fancy, I know. But you can use it to make a wrapper when you overwrite exports with a meta table.
  21. getRealTime: https://wiki.multitheftauto.com/wiki/GetRealTime It returns by default the current date. timestamp can help you with calculate offset. Easy to use and no formatting required. local timestamp = getRealTime().timestamp -- seconds local days = 10 local futureTimestamp = timestamp + (60 * 60 * 24 * days) if timestamp >= futureTimestamp then end To get other date formats. Member Meaning Range second seconds after the minute 0-61* minute minutes after the hour 0-59 hour hours since midnight 0-23 monthday day of the month 1-31 month months since January 0-11 year years since 1900 weekday days since Sunday 0-6 yearday days since January 1 0-365 isdst Daylight Saving Time flag timestamp seconds since 1970 (Ignoring set timezone) local time = getRealTime() local hours = time.hour local minutes = time.minute These are the bricks you can use and the rest is up to your math skills.
  22. Doesn't the event onClientKey detects hold? hmmm Well if it doesn't: local nextCharacterRemoveTime = 0 local characterRemoveInterval = 200 function checkCharacterRemove () if getKeyState ( "backspace" ) then -- https://wiki.multitheftauto.com/wiki/GetKeyState local timeNow = getTickCount() if timeNow > nextCharacterRemoveTime then nextCharacterRemoveTime = timeNow + characterRemoveInterval -- strip the string! end end end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end local function backspacePress ( button, press ) if button == 'backspace' then if press then if not isEventHandlerAdded("onClientRender", root, checkCharacterRemove ) then addEventHandler("onClientRender", root, checkCharacterRemove) end elseif isEventHandlerAdded("onClientRender", root, checkCharacterRemove ) then removeEventHandler("onClientRender", root, checkCharacterRemove) end end end
  23. local theString = "blabla1\blabla2" local words = split ( theString, 92) -- returns a table with all items split by \, which is ASCII code 92 iprint(unpack(words)) https://wiki.multitheftauto.com/wiki/Split https://wiki.multitheftauto.com/wiki/ASCII
  24. You can use moveObject and fill in the strEasingType argument. If you want more customization, you need to spend more time on stuff like this: https://wiki.multitheftauto.com/wiki/Animate
  25. That doesn't sounds right. Multi-line strings do generate "\n", for each new line, not just "\". What do you want to achieve?
×
×
  • Create New...