Jump to content

getRandomPlayer accurately find


Dolinho

Recommended Posts

This gives me random players:

getRandomPlayer() 

How do I find a player first?

It takes a lot to find in random, and that's too bad

have any precise way to find a player?

accurately find.

addEvent("Marktres",true) 
addEventHandler("Marktres",root,   
function (wanter) 
local wanter = getRandomPlayer() 
local theName = getPlayerName ( source ) 
if (getPlayerWantedLevel(wanter) == 3) then 
setTimer ( function() 
outputChatBox("Procurando Niveis 3..", source, 0, 255,255, true) 
end,1000, 1 ) 
setTimer ( function() 
outputChatBox("Registrando...", source, 0, 255,255, true) 
end,2000, 1 ) 
setTimer ( function() 
outputChatBox("Altenticando....", source, 0, 255,255, true) 
end,3000, 1 ) 
setTimer ( function() 
outputChatBox("Um Meliante "..getPlayerName(wanter).." Encontrado pelo sistema policial...", source, 0, 255,255, true) 
outputChatBox ( "Dica quanto mais Criminosos com estrela, mais facil fica para achalos", source ) 
exports.killmessages:outputMessage("*"..getPlayerName(wanter).." Esta sendo Oficialmente procurado pela PM.", root, 255, 15, 15, true) 
local blip = createBlipAttachedTo(wanter, 19)  
end,4000, 1 ) 
else 
        outputChatBox ( "Verifique se realmente tenha jogadores com 3 nivel de procurado.", source ) 
        outputChatBox ( "Caso tenha, procure ate achar.", source ) 
end 
end 
) 

Link to comment
function getPlayersWithWantedLevel(level) 
    if type(level) == "number" then 
        local total = 0 
        for _,player in ipairs(getElementsByType("player")) do 
            if getPlayerWantedLevel(player) == level then 
                total = total + 1 
            end 
        end 
        return total 
    end 
    return false 
end 

e.g:

outputChatBox( getPlayersWithWantedLevel(3) ) 

Is that what do you mean?

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