Jump to content

New function to script.


MitnickP56

Recommended Posts

Hi. Yesterday one guy was help me on script. It's a checker ping.

  
function detektor() 
    for i, player in ipairs(getElementsByType("player")) do 
        if (getPlayerPing(player) >= 150) then 
            outputChatBox(getPlayerName(player).." #CFECEC lagging his ping: #ff0000"..getPlayerPing(player),root, 255, 96, 96, true) 
        end 
    end 
end 
setTimer(detektor, 1000, 0)  

Today I wanna add ' script work only for ALIVE players.

So I tried.

function detektor () 
    for i, player in ipairs(getElementsByType("player")) do 
    if getElementData(v,"state") == "alive" then 
           local pingus = (getPlayerPing(player) >= 100) 
            outputChatBox(getPlayerName(v):gsub("#%x%x%x%x%x%x","").." #CFECEC lagging his ping: #ff0000:"..pingus,root, 255, 96, 96, true) 
        end 
    end  
end 
setTimer(detektor, 1000, 0)  
  

debugscript: 10820981613638858108.png

Link to comment
function detektor () 
    for _, player in ipairs(getElementsByType("player")) do 
    if (not isPedDead(player)) then 
           local pingus = getPlayerPing(player) 
           if (pingus >= 100) then 
            outputChatBox(getPlayerName(player):gsub("#%x%x%x%x%x%x","").." #CFECEC lagging his ping: #ff0000:"..pingus,root, 255, 96, 96, true) 
           end 
        end 
    end 
end 
setTimer(detektor, 1000, 0) 

Link to comment
function detektor () 
    for _, player in ipairs(getElementsByType("player")) do 
    if (not isPedDead(player)) then 
           local pingus = getPlayerPing(player) 
           if (pingus >= 100) then 
            outputChatBox(getPlayerName(player):gsub("#%x%x%x%x%x%x","").." #CFECEC lagging his ping: #ff0000:"..pingus,root, 255, 96, 96, true) 
           end 
        end 
    end 
end 
setTimer(detektor, 1000, 0) 

debugscript ; 08610524358684594352.png

when I change to:

outputChatBox(getPlayerName(player).." #CFECEC lagging his ping: #ff0000:"..pingus,root, 255, 96, 96, true) 

debugscript: 41424123493732215216.png

Link to comment
function detektor () 
    for _, player in ipairs(getElementsByType("player")) do 
    if (not isPedDead(player)) then 
           local pingus = getPlayerPing(player) 
           if (pingus >= 100) then 
            outputChatBox(getPlayerName(player):gsub("#%x%x%x%x%x%x","").." #CFECEC lagging his ping: #ff0000:"..tostring(pingus),root, 255, 96, 96, true) 
           end 
        end 
    end 
end 
setTimer(detektor, 1000, 0) 

I'm not sure what the issue is, I double checked the code and couldn't find what causes your error. I doubt this is it, but maybe you have to convert the ping with tostring(..) before concatenating.

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...