Jump to content

IIYAMA

Moderators
  • Posts

    6,097
  • Joined

  • Last visited

  • Days Won

    218

Everything posted by IIYAMA

  1. IIYAMA

    Player demage

    no, you missed placed it. Try this: (not tested) addEventHandler("onClientPlayerDamage", localPlayer, function (attacker, weapon, loss) -- source is the player that got damaged. if isElement ( attacker ) and weapon == 51 and getElementType(attacker) == "player" and getElementModel(source) == 165 then local oldHealth = getElementHealth(source) local newHealth = oldHealth + loss - 5 if newHealth > 0 then setElementHealth(source,newHealth ) cancelEvent() elseif oldHealth > 0 then setElementHealth(source,0) end end end) Make sure you are wearing skin 165, when somebody attacks you.
  2. IIYAMA

    Player demage

    Add(new stuff), replace(that look a like) and remove.(strike)
  3. IIYAMA

    Player demage

    You have to add the health loss, before you set the new health. local newHealth = getElementHealth(source) + loss - 5 if newHealth > 0 then setElementHealth(source,newHealth ) else setElementHealth(source,0) end And not to forget, put the handler on the localPlayer. addEventHandler("onClientPlayerDamage", localPlayer, You can't set the health of a remote player with success, only the localPlayer as source can give correct result. and attacker== localPlayer The attacker can also be a vehicle. getElementType(attacker) == "player"
  4. Scaling stuff in two directions, gives a terrible result when the ratio chances. That's why I am using only 1 scalingFactor.
  5. I scale down like this. local scaleFactor = math.min(guiGetScreenSize ())/1080 My resolution is 1920x1080. So when you are making your dx stuff on your screen, replace 1080 with your screen height*. * probably your screen height, I don't think people (can)play with 1080x1920. Also sometimes you must limit the scaleFactor when you are working with text functions. When text get too small, people can't read it any more. For example: local scaleFactorText = scaleFactor if scaleFactorText < 0.3 then scaleFactorText = 0.3 end
  6. Line 6 >local randomteam = teams[math.random(#teams)]<, must be placed between line 9 and 10. Else it isn't random per player.
  7. Atenos, what does dxDrawRectangle return? You can find the answer here: https://wiki.multitheftauto.com/wiki/DxDrawRectangle Which is also the answer why it doesn't work.
  8. Both choices have benefits, but it has nothing to do with optimization. You won't notice those extra execution time for exports. As long as you use more exports in stead of custom events, everything is al right. This is a choice for the developer, based on his knowledge and logic thinking. Some resources can be placed together and others can better not.
  9. https://wiki.multitheftauto.com/wiki/Se ... ntrolState
  10. No. local teamBlue = createTeam ( "Team Blue", 0, 0, 255 ) local teamRed = createTeam ( "Team Red", 255, 0, 0 ) local teams = {teamBlue,teamRed} local randomteam = teams[math.random(#teams)]
  11. IIYAMA

    Set delay

    repairTimer = setTimer(function() repairTimer = false end,repairDelayTime,1) Although tickcount would be more suitable for this code.
  12. You forgot to define if it is relative or absolute. element guiCreateStaticImage ( float x, float y, float width, float height, string path, bool relative, [element parent = nil] )
  13. dxDraw functions don't create elements. Ones they are executed they will show a DX effect, which is only shown for 1 frame. If you want images in your gui, use: https://wiki.multitheftauto.com/wiki/Gu ... taticImage
  14. afk, your limit is your HDD. And when you write too much characters per frame, you might crash(unless you enable fileFlush, which is for logging). The max string length is limited by your ram.
  15. are you kidding me? That code just creates a custom event. You are the one that has to test and add everything. If you forget to add everything, it will be impossible to help you.
  16. afaik, weapon sounds aren't the same as the tank sound or am I incorrect? Try to find the correct sounds using: /debugscript 3 /start runcode /crun setDevelopmentMode ( true) /showsound 1 Shoot the tank cannon.
  17. that laggs, will use too much bandwidth and it is incorrect. This example should enable the event "onPlayerTeamChange". local lastPlayerTeam = {} setTimer(function () local players = getElementsByType("player") for i=1,#players do local player = players[i] local playerTeam = getPlayerTeam(player) or false -- make sure it always returns false, if it returns nil. if playerTeam then local lastTeam = lastPlayerTeam[player] or false -- make sure it always returns false, if it returns nil. if playerTeam ~= lastTeam then triggerEvent("onPlayerTeamChange",player,isElement(lastTeam) and lastTeam or false,playerTeam) lastPlayerTeam[player] = playerTeam end else local lastTeam = lastPlayerTeam[player] if lastTeam then triggerEvent("onPlayerTeamChange",player,isElement(lastTeam) and lastTeam or false,nil) lastPlayerTeam[player] = nil end end end end,1000,0) addEventHandler("onPlayerQuit",root, function () if lastPlayerTeam[source] then lastPlayerTeam[source] = nil end end) Which you can use here: addEventHandler ( "onPlayerTeamChange", root, function ( oldTeam,newTeam ) local team = getTeamFromName ( "Criminal" ) if oldTeam == team then setElementVisibleTo( criminalBlip, source, nil ) elseif newTeam == team then setElementVisibleTo( criminalBlip, source, true ) end end) And this is maybe handy too. addEventHandler("onPlayerJoin",root, function () setElementVisibleTo(criminalBlip, source, false) end) Nothing is tested, I will leave that to you.
  18. It means that the account data hasn't been set yet. It is nil. Replace line 7 t/m 8 with: local points = tonumber(getAccountData (account, "DMpoints")) or 0 local money = tonumber(getAccountData (account, "DMmoney")) or 0 Which will replace the accountdata with 0, when it hasn't been set/hasn't been set correct.
  19. Because dxDraw functions are rendering behind the gui. Unless the argument postGUI is set to true(which is by default false): postGUI: A bool representing whether the text should be drawn on top of or behind any ingame GUI (rendered by CEGUI).
  20. Is the server OK, when players start download resources? What about the RAM, SWAP and CPU usage?
  21. IIYAMA

    Web Browser

    the createBrowser function returns a dynamic texture, which you can render with a 3D render function near the object. Using: dxDrawMaterialLine3D
  22. Try to render with lower resolution, if your pc can't handle it. This should be optional for the user experience.
  23. I personal see it like this: (others have different opinions about it) A: can be anything in the table. B: can also be anything in the table. The only way to sort a table is by comparing data with each other. So what are A and B? [color=#0000FF]toptimes[/color] = { [color=#FF0000][b]{[/b][/color]32423,"nickname"[color=#FF0000][b]},[/b][/color] [color=#FF0000][b]{[/b][/color]12313,"nickname"[color=#FF0000][b]},[/b][/color] }; A and B are the data which are inside of the sorted table. Which are in this case tables too. The table.sort function will be comparing and sort those data behind the scene. And the function(with the A and B) will be used in this process.
  24. Smooth animations can be done with onClientRender. Untested, but this might give you an idea how this can be working. local animationEnd = 0 local startRotation local isRenderingAnimation = false local changeRotateSmoothFunction changeRotateSmoothFunction = function () local timeNow = getTickCount() local factor = 1-((animationEnd - timeNow)/300) -- calculate the factor based on future time. if factor < 1 then rot1 = (startRotation + (5*factor))%360 else rot1 = startRotation+5 -- set at the end to the correct rotation removeEventHandler("onClientRender",root,changeRotateSmoothFunction) -- remove the event handler. isRenderingAnimation = false -- set the variable to false, so you can render an animation again. end end function onPanelRegisterButtonClicked( btn, state ) if btn ~= "left" or state ~= "up" then return end if not isRenderingAnimation then animationEnd = getTickCount()+300 -- timeNow + 300 ms = futureTime startRotation = rot1 -- save the start of the animation. addEventHandler("onClientRender",root,changeRotateSmoothFunction) -- add an render event handler. isRenderingAnimation = true -- use a variable to check if you are rendering end end addEventHandler("onClientGUIClick", lu, onPanelRegisterButtonClicked, false)
  25. You have to index twice instead of one time. Because you have tables inside a table. local messages = { -- < table 1 {"TEXT1",255,0,0}, -- table inside table 1 {"TEXT2",0,0,255}, -- table inside table 1 {"TEXT3",0,255,0} -- table inside table 1 } local i = 0 function sendNextAutomatedMessage ( ) i = i + 1 if ( i > #messages ) then i = 1 end local content = messages[i] outputChatBox( content[1], root ,content[2],content[3],content[4]) setTimer ( sendNextAutomatedMessage, 150000, 1 ) end setTimer ( sendNextAutomatedMessage, 200, 1 )
×
×
  • Create New...