-
Posts
6,062 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
function onPlayerHeadshot( attacker, _, bodypart, loss ) if not ( bodypart == 9 ) then return false end -- check if the player has been hit in the head if not ( getElementType( attacker ) == "player" ) then return false end -- check if the attacker is a player local playerOriginalHealth = getElementHealth( source ) + loss -- get the player's original health local newHealth = math.max(playerOriginalHealth - headshotDamage, 0) setElementHealth( localPlayer, newHealth) -- set the player's new health end addEventHandler( "onClientPlayerDamage", localPlayer, onPlayerHeadshot )
-
Try harder. You are not coding at the moment, you are simple moving lines.
-
Did you? You should have warnings/errors at the moment, so I don't think so. Replace line 8 with line 1 and 2. (of your updated code) Replace line 12 with the line that looks similar. (from my code) And show the updated code.
-
[PLEASE HELP]dxDrawMaterialLine3D and dxDrawText
IIYAMA replied to MysticEmpire's topic in Scripting
There is already an example on wiki, which only require copy past. -
I am talking about this: local selectWidth = 300 local selectHeight = 100 But if that doesn't work, there is also: https://wiki.multitheftauto.com/wiki/DxSetShaderTransform Which I prefer if it is UI. Shader needed for this? (most simple possible shader can be used) texture gTexture; technique IIYAMA { pass P0 { Texture[0] = gTexture; } }
-
function onPlayerHeadshot( attacker, _, bodypart, loss ) local playerOriginalHealth = getElementHealth( source ) + loss -- get the player's original health local newHealth = math.max(playerHealth - headshotDamage, 0) setElementHealth( localPlayer, newHealth) -- set the player's new health You have to add the loss back to get the original health. In this case it doesn't really matter since the damage is 200, but if you want to use values lower than 200, you will need to add that. If you put the health under 0, it will do strange things.(reset etc.) addEventHandler( "onClientPlayerDamage", localPlayer, onPlayerHeadshot ) You can't set other players their health with success, only that one of the localPlayer. So we only have to check the localPlayer. cancelEvent() No need for cancelling. Keep in mind that this can get bugged under strange occasions. Because of the GTA engine. If this doesn't work, post the updated code.
-
How about increasing the resolution of the captured area?
-
[PLEASE HELP]dxDrawMaterialLine3D and dxDrawText
IIYAMA replied to MysticEmpire's topic in Scripting
Render both as 2D. Then capture them with a render target. https://wiki.multitheftauto.com/wiki/DxCreateRenderTarget And as last render the rendertarget(image/texture format) in 3D. -
[PLEASE HELP]dxDrawMaterialLine3D and dxDrawText
IIYAMA replied to MysticEmpire's topic in Scripting
Your order: spaghetti with marinara sauce + egg noodles and ketchup is not ready yet, I am terrible sorry. I have no clue what you want. -
Check if onClientPlayerDamage gets cancelled. @Dziugasc Weapon properties do not work for fire or explosions. The damage of those effects are indirect and aren't attached to the weapons in your hand.
-
Setting the sniper at 100 damage will not do 100 damage. There is a multiplier that will give different damage results to players/peds, objects and vehicles. For example ~130 will do 50 damage to a player. (can't remember the exact values) So set the damage at 1000 or even 10000. I assume you use: setWeaponProperty
-
after randomize it, save the last result in a variable. With the next randomization you will have to check if the new value is not the same as the old one. local lastRandomResult local randomResult repeat randomResult = math.random() until lastRandomResult ~= randomResult lastRandomResult = randomResult
- 1 reply
-
- 1
-
local ox = getElementData(vehicle, "gear_f") -- ox can be used after here if ox then -- isn't it false or nil? end getElementData has a different syntax than setElementData. Check wiki pls.
-
"onClientPlayerDamage" or "onClientExplosion" + getDistanceBetweenPoints3D + getElementPosition(localPlayer) setElementHealth(localPlayer, 0)
-
hmm I was thinking about checking the memory(mipmap textures are bigger) or the load time(generating mipmaps cost more time). @CodyJ(L) But scaling down the images(in game) should work even better! Thx thx!
-
How can I test that?
-
In dxCreateTexture there is an argument called mipmaps. It will generate multiple copies in different resolutions, so that it looks good. If I create these mipmaps manually, do I have to enable or disable this option? (dds (image) files can have mipmaps included) element dxCreateTexture ( string pixels [, string textureFormat = "argb", bool mipmaps = true, string textureEdge = "wrap" ] ) element dxCreateTexture ( string pixels [, string textureFormat = "argb", bool mipmaps = true, string textureEdge = "wrap" ] )
-
https://wiki.multitheftauto.com/wiki/Resource:Dynamic_lighting
-
Yea it would, just not automatic and not easy to maintain. samples = { {8*(screenY/1024)), dxCreateFont("addons/font.ttf",8*(screenY/1024))}, {10*(screenY/1024), dxCreateFont("addons/font.ttf",10*(screenY/1024))} -- ... } function getFontFromSize (size) local sampleIndex = 1 for i=1, #samples do if size > samples[i][1] then sampleIndex = i else return samples[sampleIndex][2] end end return samples[sampleIndex][2] end local font = getFontFromSize (10 *(screenY/1024)) function getFontVariantFromSize (font, size) local sampleIndex = 1 local samples = fonts[font] for i=1, #samples do if size > samples[i][1] then sampleIndex = i else return samples[sampleIndex][2] end end return samples[sampleIndex][2] end local font = getFontVariantFromSize (":race/addons/font.ttf", 10 *(screenY/1024)) Untested of course...
-
if x and y then -- code where you use x and y end Let me remind you that this section is for learning scripting and not for repairing scripts from the community. (if you are not a scripter)
- 1 reply
-
- 1
-
local fonts = {} local scalingPercentagePerSample = 0.05 -- 5% local samplesCount = 10 -- samplesCount validate -- if samplesCount / 2 ~= math.floor(samplesCount/2) then samplesCount = samplesCount+1 end --------------------------- function dxCreateSamplesForFont (filepath, size) local _, screenY = guiGetScreenSize() local samples = {} for sampleScaleMultiplier=1, samplesCount do sampleScaleMultiplier = sampleScaleMultiplier - samplesCount/2 local newSize = size * (screenY/1024) - (size * (screenY/1024) * (sampleScaleMultiplier * scalingPercentagePerSample)) iprint("newSize:", newSize) local font = dxCreateFont(filepath, newSize) samples[#samples+1] = {newSize, font} end return samples end fonts[":race/addons/font.ttf"] = dxCreateSamplesForFont (":race/addons/font.ttf", 10) And if you create samples?
-
?font = dxCreateFont(":race/addons/font.ttf",math.max(12*(x/1280), 8)) You can set an under limit. Custom fonts on low resolutions are indeed an problem. I also haven't solved that problem yet.
-
You can do that by comparing the current position with the new position. If the current position is 90 and you are moving to 90, you should do nothing. If the current position is -90 and you are moving to -90, you should do nothing. If the current position is -45 and you are moving to -90, then you should execute the timer not 90 times, but only 45 times. end,100,90) Calculated to: end,100,45) This is just doing the math, like you do on school. I prefer onClientPreRender/onClientRender and getTickCount() for this kind of scripts, but I guess that is too complex for starters.