Jump to content
  • 0

Problem with detach elements


Z.l.X

Question

3 answers to this question

Recommended Posts

  • 0
  • MTA Team

Your script has way too many timers, which can cause server to lag or clients to crash. I suggest no using timers at all, because I honestly can't see any idea why to use timers. Secondly, this is the wrong section to post your issues with scripts. Here is the section for script issues »

Try the code below.

Server-side

local arte = createMarker(-2200.11, 2400.68, 4.97, "corona", 1, 255, 255, 255, 255) 
createBlipAttachedTo(arte, 25) 
outputChatBox("* Artefakt pojawia sie w okolicach miasteczka Bayside!", root, 244, 211, 27, false) 
  
addEventHandler("onMarkerHit", arte, 
    function(hitElement, matchingDimension) 
        if getElementType(hitElement) == "player" and matchingDimension then 
            outputChatBox("* " .. getPlayerName(hitElement) .. " podnosi artefakt!", root, 244, 211, 27, false) 
            attachElements(arte, hitElement) 
             
            -- zdrowie, naprawa pojazdu 
            setTimer( 
                setElementHealth(hitElement, 1000) 
                outputChatBox("* Artefakt ulecza Cie!", hitElement, 244, 211, 27, false) 
                playSoundFrontEnd(hitElement, 45) 
            end, 160000, 1, hitElement) 
             
            -- kasa 
            setTimer(function(hitElement) 
                givePlayerMoney(hitElement, math.random(10000, 50000)) 
                outputChatBox("* Artefakt dodaje Ci pieniedzy!", hitElement, 244, 211, 27, false) 
                playSoundFrontEnd(hitElement, 45) 
            end, 300000, 1, hitElement) 
             
            -- armor 
            setTimer(function(hitElement) 
                setPedArmor(hitElement, 1000) 
                outputChatBox("* Artefakt dodaje Ci armora!", hitElement, 244, 211, 27, false) 
                playSoundFrontEnd(hitElement, 45) 
            end, 360000, 1, hitElement) 
        end 
    end 
) 
  
addEventHandler("onPlayerWasted", root, 
    function(ammo, killer, weapon, bodypart, stelath) 
        detachElements(arte, source) 
        outputChatBox("* Artefakt zostal upuszczony!", root, 244, 211, 27, false) 
    end 
) 

Link to comment
  • 0
Your script has way too many timers, which can cause server to lag or clients to crash. I suggest no using timers at all, because I honestly can't see any idea why to use timers.

I will remember for the future as the number of timers.

Artifact would have to give the money and armor to the owner from time to time, so I used the setTimer function.

Secondly, this is the wrong section to post your issues with scripts. Here is the section for script issues »

Very sorry ;X

Anyway, thank you for helping.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...