Jump to content

Police kill arrest


bosslorenz

Recommended Posts

[2016-08-02 18:56:19] SCRIPT ERROR: PH\(PH)PoliceJob\police_arrest.lua:13: 'end' expected (to close 'if' at line 6) near 'elseif'

[2016-08-02 18:56:19] ERROR: Loading script failed: PH\(PH)PoliceJob\police_arrest.lua:13: 'end' expected (to close 'if' at line 6) near 'elseif'

function onCrimKill (ammo, attacker, weapon, bodypart) 
    local police = getTeamFromName("Police Officer") 
    local criminal = getElementType(source) 
    if ( getElementType (attacker) == "player" ) then 
    if (attacker) then 
        if attacker == police then 
            if criminal > 0 then 
            outputChatBox("You are arrested",source,255,0,0) 
            return end 
            outputChatBox("Police mistaken, killed you unwanted",source,255,0,0) 
        else 
        outputChatBox("You are not permitted to kill a criminal",attacker,255,0,0) 
    elseif not attacker then 
        outputChatBox(getPlayerName ( source ).."died from environment") 
        end 
    end 
end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onCrimKill) 
  
  

I have attacker == police then. Then I want to check the wantedLevel of the wasted crim.

If crim has > 0 WL then arrest elseif the crim not wanted then output to crim (You are mistaken killed by a police).

Else if attacker of crim is not on police team then output to Killer (You cant kill crim)

while if there is no attacker then output all (Player(killed) getName is killed through environment hazards.

I dont know have much scripting knowledge if the (IF argument gets higher than 2 ) :/ Someone help me?

Link to comment
function onCrimKill (ammo, attacker, weapon, bodypart) 
    local police = getTeamFromName("Police Officer") 
    local criminal = getPlayerWantedLevel(source) 
    if ( getElementType (attacker) == "player" ) then 
    if (attacker) then 
        if attacker == police then 
            if criminal > 0 then 
            outputChatBox("You are arrested",source,255,0,0) 
            return end 
            outputChatBox("Police mistaken, killed you unwanted",source,255,0,0) 
        else 
        outputChatBox("You are not permitted to kill a criminal",attacker,255,0,0) 
    end 
elseif not attacker then 
        outputChatBox(getPlayerName ( source ).."died from environment") 
        end 
    end 
end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onCrimKill) 
  
  

Link to comment
function onCrimKill (ammo, attacker, weapon, bodypart) 
    local police = getTeamFromName("Police Officer") 
    local criminal = getPlayerWantedLevel(source) 
    if ( getElementType (attacker) == "player" ) then 
    if (attacker) then 
        if attacker == police then 
            if criminal > 0 then 
            outputChatBox("You are arrested",source,255,0,0) 
            return end 
            outputChatBox("Police mistaken, killed you unwanted",source,255,0,0) 
        else 
        outputChatBox("You are not permitted to kill a criminal",attacker,255,0,0) 
    end 
elseif not attacker then 
        outputChatBox(getPlayerName ( source ).."died from environment") 
        end 
    end 
end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onCrimKill) 
  
  

Have tried this also, no errors. Tried;

being police and killed crim(unwanted) = You are not permitted to kill a criminal

being police and killed crim(wanted) = You are not permitted to kill a criminal

being non-police and killer crim(wanted) & crim(unwanted) = You are not permitted to kill a criminal

Link to comment
function onCrimKill (ammo, attacker, weapon, bodypart) 
    local police = getTeamFromName("Police Officer") 
    local crim = getTeamFromName("Criminals") 
    local criminal = getPlayerWantedLevel(source) 
    if ( getElementType (attacker) == "player" ) then 
    if getPlayerTeam(attacker) == "police" and getPlayerTeam(source) == "crim" then 
            if criminal > 0 then 
            outputChatBox("You are arrested",source,255,0,0) 
            outputChatBox("You earned money killing a wanted person",attacker,255,0,0) 
            return end 
            outputChatBox("Police mistaken, killed you unwanted",source,255,0,0) 
    elseif getPlayerTeam(attacker) ~= "police" and getPlayerTeam(source) == "crim" then 
        outputChatBox("You are not permitted to kill a criminal",attacker,255,0,0) 
    elseif getPlayerTeam(attacker) == "police" and getPlayerTeam(source) ~= "crim" then  
        outputChatBox("You cant killed a non-criminal player",attacker,255,0,0) 
    else 
end 
end 
end  
addEventHandler("onPlayerWasted", getRootElement(), onCrimKill) 
  

I have made another to check

attacker = team and playerWasted = team  

1) Doesnt return outputChatBox when doing all option.

2) Also if attacker and playerWasted both are non of those teams the end.

Can someone help?

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