Jump to content

Jail system


TorNix~|nR

Recommended Posts

so, if i'm right, you want that, when player wanted level change to 3, automaticly goin to jail.

If yes,

you can use

setElementData -- Set the data when player wanted level change

onElementDataChange -- you dont need setTimer

setElementPosition -- Set the player position to jail

setPlayerWantedLevel -- remove the wanted level 

I hope this help u. If i forgott something, or if you have some problems, feel free to ask here and we help ya

Edited by TheMOG
Link to comment
addEventHandler("onPlayerJoin", root, 		--for the purpose of this tutorial only, really you should use a saving system
	function()
		setElementData(source, "wantedLevel", 0)
	end
)

function warpToJail(wantedLevel)
	if (getElementType(source) == "player") then
		if getElementData(source, wantedLevel) == 3 then
			setElementInterior(source, interior)	--insert interior of jail
			setElementPosition(source, posX, posY, posZ)	--insert position of jail
			setElementRotation(source, rotX, rotY, rotZ)	--set the players rotation if need be
      		outputChatBox("You have been sent to jail!", source, 255, 0, 0)		--output a message to the player who was jailed
		end
	end
end
addEventHandler("onElementDataChange", root, warpToJail)

Then you will need a system to add wanted levels to players and preferably a saving system to save the wanted level for each player. To accomplish this you should use MySQL or SQLite to save the players data into a table in a database every time they log out and retrieve it when they log back in.

Edited by Pembo
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...