Jump to content

SkatCh

Members
  • Content Count

    365
  • Joined

  • Last visited

Posts posted by SkatCh

  1. every thing is working fine but when the muted player reconnect i got this warning

    Bad Argument @ 'getElementData' Expected Element at agument 1.

    function decreaseMutedTime ( player, time ) 
        if not ( isElement ( player ) ) then return; end 
        
        unmuteTimer[player] = setTimer ( function () 
                
                local timeLeft = tonumber ( getElementData ( player, "mt" ) );  ---- this line 
                if ( timeLeft == 0 ) then 
                    killTimer(unmuteTimer[player]) 
                    outputDebugString ( "0 sec left" ); 
                    if ( getElementData ( player, "mute" ) ) then 
                        outputDebugString ( "is muted" ); 
                        setPlayerMuted ( player, false ); 
                        setElementData ( player, "mt", 0 ); 
                        setElementData ( player, "mute", false ); 
                        outputChatBox ( "Your time of being muted has expired.", player, 0, 255, 0 ); 
                        outputChatBox ( getPlayerName ( player ) .."'s mute has expired", root, 0, 255, 0 ); 
                        unmuteTimer[player] = nil; 
                    end 
                else 
                    if ( getElementData ( player, "mute" ) ) then -------------- and this line 
                        setElementData ( player, "mt", timeLeft - 1 ); 
                    end 
                end 
            end, 1000, -1 
        ); 
    end 
    

  2. bro i try it also i create an other thing but didn't work i don't now why when the player quit the game this warning appear i can fix it by my self but i don't know what's the problem check this ;

    function decreaseMutedTime(player, time) 
        if (not isElement(player) or not time) then return end 
        local function decreaseTime() 
            local o = tonumber(getElementData(player, "mt")) or 0 
            local time = o - 1 
            setElementData(player, "mt", getElementData(player, "mt") - 1) 
            if (time <= 1 and isPlayerMuted(player)) then 
                local time = nil 
                setElementData(player, "mt", false) 
                outputChatBox("You have been unmuted ", player, 255, 255, 0) 
                setPlayerMuted(player, false) 
                setElementData(player, "muteinfo", false) 
                if (isTimer(unmuteTimer[player])) then 
                    killTimer(unmuteTimer[player]) 
                end 
            end 
        end 
        unmuteTimer[player] = setTimer(decreaseTime, 1000, tonumber(getElementData(player, "mt"))) 
    end 
    

    -- onPlayerLogout

    function checkMuteOnLogout(account) 
        if (not isPlayerMuted(source)) then return end 
        local mutedTime = getElementData(source, "mt") or 0 
        if (tonumber(mutedTime > 1)) then 
            setAccountData(account, "mt", tonumber(mutedTime)) 
        end 
    end 
    addEventHandler("onPlayerLogout", root, checkMuteOnLogout) 
    

    and i create this onPlayerLogin

    function checkMuteOnLogin(account) 
        local mutedTime = getAccountData(account, "mt") or 0 
        if (tonumber(mutedTime > 1)) then 
            setPlayerMuted(source, true) 
            decreaseMutedTime(source, mutedTime) 
        end 
    end 
    addEventHandler("onPlayerLogin", root, checkMuteOnLogin) 
    

  3. guys please i need some help here i create save system for guns but i have small problem here ,

    addEventHandler ( "onPlayerSpawn", root, 
        function () 
            local theAccount = getPlayerAccount ( source ); 
      -- weapons 
            local weapon0 = getAccountData ( theAccount, "weapons.weapon0" ); 
     -- ammo 
            local ammo0 = getAccountData ( theAccount, "weapons.ammo0" );  
     -- give the weapons 
            if ( weapon0 > 0 ) then giveWeapon ( source, weapon0, ammo0 ); end ----- this line  
      
    ); 
    

    the script is working fine but this weapon Fist 0 , when a new player join the server i got this error ;

    attempt to compare number with boolean .

  4. It seems you aren't reading my post correctly. I am not talking about the mute time, I am hell talking about the player element it self, while leaving an invalid player element is still in the system.

    sorry bro i don't undrestand this can you help me to fix it i'm sorry if i aste ur time .

  5. bro it happen just when the player reconnect i already create a save system to check the player mute time :

    function checkMuteOnLogout(account) 
        if (not isPlayerMuted(source)) then return end 
        local mutedTime = getElementData(source, "mt") or 0 
        if (tonumber(mutedTime > 1)) then 
            setAccountData(account, "mt", tonumber(mutedTime)) 
        end 
    end 
    addEventHandler("onPlayerLogout", root, checkMuteOnLogout) 
    

  6. guys please i need some help here i create a mute system but i have some problems when the player reconnect i got some warnings:

    function decreaseMutedTime ( player, time ) 
        if not ( isElement ( player ) ) then return; end 
         
        unmuteTimer[player] = setTimer ( function () 
                 
                local timeLeft = tonumber ( getElementData ( player, "mt" ) );  ---- this line  
                if ( timeLeft == 0 ) then 
                    killTimer(unmuteTimer[player]) 
                    outputDebugString ( "0 sec left" ); 
                    if ( getElementData ( player, "mute" ) ) then 
                        outputDebugString ( "is muted" ); 
                        setPlayerMuted ( player, false ); 
                        setElementData ( player, "mt", 0 ); 
                        setElementData ( player, "mute", false ); 
                        outputChatBox ( "Your time of being muted has expired.", player, 0, 255, 0 ); 
                        outputChatBox ( getPlayerName ( player ) .."'s mute has expired", root, 0, 255, 0 ); 
                        unmuteTimer[player] = nil; 
                    end 
                else 
                    if ( getElementData ( player, "mute" ) ) then -------------- and this line  
                        setElementData ( player, "mt", timeLeft - 1 ); 
                    end 
                end 
            end, 1000, -1 
        ); 
    end 
    

    Bad Argument @ 'getElementData' Expected Element at agument one 1.

    any help

  7. guys please i need some i create a command to attach a marker to player then i create destroy function , check this it's a part from my script:

    function destroyMarker (player) 
        for index, m in ipairs ( markers ) do 
            if isElement(markers[index][1]) and markers[index][2] == player then 
                destroyElement (markers[index][1]) 
                break 
            end 
        end 
    end 
    

    the problems is i want to destroy the marker when the player logout or when the player die .

    i tried this but didn't work

    function loggedOut (player) 
        destroyMarker (player) 
    end 
    addEventHandler("onPlayerLogout",getRootElement(),loggedOut) 
    addEventHandler( "onPlayerWasted", getRootElement( ),loggedOut) 
    addEventHandler ( "onPlayerQuit", getRootElement(), loggedOut ) 
    

    Note i tried the same funtion with CommandHandler and it's working fine.

    i'm sorry about my english

×
×
  • Create New...