Sparrow Posted February 2, 2012 Posted February 2, 2012 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)
Castillo Posted February 2, 2012 Posted February 2, 2012 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)
BriGhtx3 Posted February 2, 2012 Posted February 2, 2012 Easy thing policePlayer is wrong! Paramters for onPlayerQuit : string quitType, string reason, element responsibleElement This script will never work, cause both players are nil.
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