justn Posted March 23, 2014 Share Posted March 23, 2014 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
WhoAmI Posted March 23, 2014 Share Posted March 23, 2014 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
Anubhav Posted March 23, 2014 Share Posted March 23, 2014 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
justn Posted March 23, 2014 Author Share Posted March 23, 2014 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
Anubhav Posted March 23, 2014 Share Posted March 23, 2014 See my . It will check for police team players every 50ms and if he has wanted level it will be set to 0 . Link to comment
justn Posted March 23, 2014 Author Share Posted March 23, 2014 Unexpected symbol on line 5 Link to comment
Anubhav Posted March 23, 2014 Share Posted March 23, 2014 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) Link to comment
justn Posted March 23, 2014 Author Share Posted March 23, 2014 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
NeO_DUFFMAN Posted March 23, 2014 Share Posted March 23, 2014 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
justn Posted March 23, 2014 Author Share Posted March 23, 2014 You clearly don't understand what I'm trying to do, I don't want players in police team to get wanted levels. Link to comment
NeO_DUFFMAN Posted March 23, 2014 Share Posted March 23, 2014 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
justn Posted March 24, 2014 Author Share Posted March 24, 2014 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
NeO_DUFFMAN Posted March 24, 2014 Share Posted March 24, 2014 Oh my bad. Anyway, try this: setTimer(function () for i,v in ipairs(getElementsByType("player")) do if isPlayerInTeam( v, "Police" ) and getPlayerWantedLevel(v) <= 6 then setPlayerWantedLevel (v,0) end end end,50,0) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now