Jump to content

why this didn't work?


Sparrow

Recommended Posts

I want this script to jail wanted players if they quit and a police was near them, I try this and didn't work, also no errors:

function sendToJail(policePlayer, wantedPlayer) 
    local playerTeam = getPlayerTeam (policePlayer) 
    if (playerTeam) then 
        local team = getTeamFromName ("Police") 
        local x, y, z = getElementPosition (wantedPlayer) 
        local marker = createMarker (x, y, z, "cylinder", 7, 255, 255, 255, 255) 
        local wanted = getPlayerWantedLevel (wantedPlayer, math.random(1, 6)) 
        if (wanted and marker) then 
            setElementInterior (wantedPlayer, 5) 
            setElementPosition (wantedPlayer,319,315,999) 
            outputChatBox ("You arrested a quiter.", policePlayer, 0, 255, 0) 
            givePlayerMoney (policePlayer, 2500) 
        end 
    end 
end 
addEventHandler ("onPlayerQuit", getRootElement(), sendToJail) 

Link to comment

That's all wrong, try this:

function sendToJail() 
    local wanted = getPlayerWantedLevel (source) 
    if (wanted > 0) then 
        local x, y, z = getElementPosition (source) 
        local marker = createMarker (x, y, z, "cylinder", 7, 255, 255, 255, 255) 
        for index, player in ipairs(getElementsWithinColShape(getElementColShape(marker), "player")) do 
            if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Police") then 
                setElementInterior (source, 5) 
                setElementPosition (source,319,315,999) 
                outputChatBox ("You arrested a quiter.", player, 0, 255, 0) 
                givePlayerMoney (player, 2500) 
            end 
        end 
    end 
end 
addEventHandler ("onPlayerQuit", getRootElement(), sendToJail) 

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