Jump to content

Need a little help


justn

Recommended Posts

So hi, I've been working on a script, so if the player is on team "Police" then he cant get wanted level, but i dont know how to make it so the player doesnt get wanted level, can someone help please ? This is what i made already.

function ifIsTeam () 
if isPlayerInTeam( source, "Police" ) then 
-- CODE 
end 
end 

Link to comment

This is code from today

        function onPlayerWasted ( _, attacker ) 
            if ( attacker ) then 
                if ( getPlayerTeam ( source ) == getTeamFromName ( "Police" ) ) then 
                    if ( getElementType ( attacker ) == "player" ) then 
                       setPlayerWantedLevel ( attacker, getPlayerWantedLevel ( attacker ) + 1 ) 
                    end 
                end 
            end 
        end 
        addEventHandler ( "onPlayerWasted", root, onPlayerWasted ) 

You mean that if policeman kills policeman he doesn't get wantedlevel? If so

        function onPlayerWasted ( _, attacker ) 
            if ( attacker and getPlayerTeam ( attacker ) ~= getTeamFromName ( "Police" ) then 
                if ( getPlayerTeam ( source ) == getTeamFromName ( "Police" ) ) then 
                    if ( getElementType ( attacker ) == "player" ) then 
                       setPlayerWantedLevel ( attacker, getPlayerWantedLevel ( attacker ) + 1 ) 
                    end 
                end 
            end 
        end 
        addEventHandler ( "onPlayerWasted", root, onPlayerWasted ) 

Link to comment
So hi, I've been working on a script, so if the player is on team "Police" then he cant get wanted level, but i dont know how to make it so the player doesnt get wanted level, can someone help please ? This is what i made already.
function ifIsTeam () 
if if ( getPlayerTeam ( source ) == getTeamFromName ( "Police" ) )  then 
-- CODE 
end 
end 

  
function ifIsTeam () 
if isPlayerInTeam( source, "Police" ) then 
local wanted = getPlayerWantedLevel(thePlayer) 
if wanted < 6 and > 0 then 
setPlayerWantedLevel ( thePlayer, 0 ) 
          end 
     end 
end 
setTimer(ifIsTeam,50,ifIsTeam) 
  

Link to comment

No, what i mean is, i have created a wanted system, it has like if player aims at cops then the player will get 1 wanted level etc... and when a cop (attacker) aims at a cop, the cop (attacker) gets a wanted level, But i dont want the cop (attacker) to get wanted levels.

Link to comment
function ifIsTeam () 
if isPlayerInTeam( source, "Police" ) then 
local wanted = getPlayerWantedLevel(source) 
if wanted < 6 then 
setPlayerWantedLevel ( source, 0 ) 
          end 
     end 
end 
setTimer(ifIsTeam,50,ifIsTeam) 

Not working.

Link to comment
  
function ifIsTeam () 
if isPlayerInTeam( source, "Police" ) then 
local wanted = getPlayerWantedLevel(thePlayer) 
if wanted < 6 then 
setPlayerWantedLevel ( thePlayer, 0 ) 
          end 
     end 
end 
setTimer(ifIsTeam,50,ifIsTeam) 
  

Firstly, source and thePlayer are not defined and secondly that is not the correct syntax for setTimer.

Anyway, i have never used this event before but i guess this should do the job. Hope it works for you lol.

  
addEventHandler ( "onPlayerTarget",root, 
function (target) 
if not getElementType(target) == "player" then return end -- Ignore if the target is not a player 
  
if (getPlayerTeam(target) == getTeamFromName("Police")) and (getPlayerTeam(source) ~= getTeamFromName("Police")) then -- If the target is in the police team but the attacker isn't 
   setPlayerWantedLevel(source,getPlayerWantedLevel(source)+1) 
   end 
end) 

Link to comment

No i do get what you're trying to do. As per the code that i've given you, if the source(attacker) is not in the police team but if the target is then the source's wanted level will be increased. Isn't that what you want?

Btw, wiki says that onPlayerTarget also gets triggered when the player is no longer aiming at something. I'm a little skeptical about my approach now. Ill try coming up with an alternative :3

Link to comment

I wanted something's like Anubhav's code, if the player is in police team , and has 1 or more wanted level , it will remove the player's wanted level. I already have a onPlayerTarget Code, so if the attacker aims at the police he will get 1 star. but the problem is, sometimes police aims at police and gets 1 star that's why i need this code.

Um, is this code correct ?

function ifIsTeam (attacker) 
if not getElementType(attacker) == "player" then return end 
if isPlayerInTeam( attacker, "Police" ) then 
local wanted = getPlayerWantedLevel(attacker) 
if wanted < 6 then 
setPlayerWantedLevel ( attacker, 0 ) 
          end 
     end 
end 
setTimer(ifIsTeam ,100 ,1 ) 
  

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