Jump to content

[HELP] PedAiming


lolman

Recommended Posts

Hello,

I got a problem with my code... I want that if you are in the team Criminal, and if you aim at a player which is in the team "Police" the criminal guy which aimed will get stars...

But in this code, if you are in the police team and you aim, you also get stars. and as a crim you get stars too.

function playerTargetCheck ( thePlayer ) 
    local target 
    for i, thePlayer in ipairs ( getElementsByType("player") ) do   
        target = getPedTarget ( thePlayer )                         
        if ( target ) then                                          
            if ( getElementType ( target ) == "player" ) and thePlayer then      
                setPlayerWantedLevel(thePlayer, 6) 
            elseif target == thePlayer then return false 
            end 
        end 
    end 
end 
setTimer ( playerTargetCheck, 1000, 0 )  

Link to comment

Try this using onPlayerTarget event.

function onPlayerTarget (element) 
    local teamNameC = getTeamName(getPlayerTeam(source)) 
    if element and getElementType (element) == "player" then 
        local theTeamName = getTeamName(getPlayerTeam(element)) 
            if (theTeamName == "Police") then  
            if (teamNameC ~= "Criminal") then return end  
            setPlayerWantedLevel(source, 6) 
        end  
    end 
end 
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTarget )  

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