Jump to content

arrest system (release )-2


Best-Killer

Recommended Posts

arrest Client - 



coptargets = 0
--ADDS BLIPS AND MARKERS FOR POLICE STATIONS
addEvent("copdirections", true)
function copshops()
	if coptargets == 0 then
		coptargets = 1
		blip1 = createBlip ( 2246.1008300781, 2453.1953125, 9.8203125, 30, 3, 0, 0, 255, 255, 50, getLocalPlayer() )
		marker1 = createMarker ( 2246.1008300781, 2453.1953125, 9.8203125, "cylinder", 6, 0, 0, 255, 55, getLocalPlayer() )
		colshape1 = createColSphere ( 2246.1008300781, 2453.1953125, 9.8203125, 6 )
		setElementData ( colshape1, "purpose", "copshop" )
		
		blip2 = createBlip ( -1406.9072265625, 2655.0927734375, 55.6875, 30, 3, 0, 0, 255, 255, 50, getLocalPlayer() )
		marker2 = createMarker ( -1406.9072265625, 2655.0927734375, 55.6875, "cylinder", 6, 0, 0, 255, 55, getLocalPlayer() )
		colshape2 = createColSphere ( -1406.9072265625, 2655.0927734375, 55.6875, 6 )
		setElementData ( colshape2, "purpose", "copshop" )
		
		blip3 = createBlip ( -209.9542, 977.7558, 18.188976, 30, 3, 0, 0, 255, 255, 50, getLocalPlayer() )
		marker3 = createMarker ( -209.9542, 977.7558, 18.188976, "cylinder", 6, 0, 0, 255, 55, getLocalPlayer() )
		colshape3 = createColSphere (-209.9542, 977.7558, 18.188976, 6 )
		setElementData ( colshape3, "purpose", "copshop" )
		
		blip4 = createBlip ( -1628.2619628906, 676.62005615234, 6.1901206970215, 30, 3, 0, 0, 255, 255, 50, getLocalPlayer() )
		marker4 = createMarker ( -1628.2619628906, 676.62005615234, 6.1901206970215, "cylinder", 6, 0, 0, 255, 55, getLocalPlayer() )
		colshape4 = createColSphere ( -1628.2619628906, 676.62005615234, 6.1901206970215, 6 )
		setElementData ( colshape4, "purpose", "copshop" )
		
		blip5 = createBlip ( 624.66278076172, -605.72027587891, 15.923292160034, 30, 3, 0, 0, 255, 255, 50, getLocalPlayer() )
		marker5 = createMarker ( 624.66278076172, -605.72027587891, 15.923292160034, "cylinder", 6, 0, 0, 255, 55, getLocalPlayer() )
		colshape5 = createColSphere ( 624.66278076172, -605.72027587891, 15.923292160034, 6 )
		setElementData ( colshape5, "purpose", "copshop" )
		
		blip6 = createBlip ( 1565.3386230469, -1628.5202636719, 12.382812, 30, 3, 0, 0, 255, 255, 50, getLocalPlayer() )
		marker6 = createMarker ( 1565.3386230469, -1628.5202636719, 12.382812, "cylinder", 6, 0, 0, 255, 55, getLocalPlayer() )
		colshape6 = createColSphere ( 1565.3386230469, -1628.5202636719, 12.382812, 6 )
		setElementData ( colshape6, "purpose", "copshop" )
		
		blip7 = createBlip ( -2164.3779296875, -2389.533203125, 29.617206573486, 30, 3, 0, 0, 255, 255, 50, getLocalPlayer() )
		marker7 = createMarker ( -2164.3779296875, -2389.533203125, 29.617206573486, "cylinder", 6, 0, 0, 255, 55, getLocalPlayer() )
		colshape7 = createColSphere ( -2164.3779296875, -2389.533203125, 29.617206573486, 6 )
		setElementData ( colshape7, "purpose", "copshop" )
	end
end
addEventHandler("copdirections", getRootElement(), copshops)

addEvent ( "onPlayerStartArrested", true )
function copshophit (theshape)
	if isElement(theshape) then
		if (getElementData(theshape, "purpose") == "copshop" ) then
			if ( getElementType( source ) == "player" ) then
				if ( getElementData ( source, "SAEGJobs:ArrestingOfficer" ) ) then						
					local mx, my, mz = getElementPosition(theshape)
					triggerServerEvent ("saegpolice:onJailCopCrimals", getLocalPlayer (), source, mx, my, mz  )
				end
			end
		end
	end
end
addEventHandler ( "onClientElementColShapeHit", getRootElement(), copshophit)
addEventHandler ( "onPlayerStartArrested", getRootElement(), copshophit)



arrest server side : 

arresties = { }
tased = { }

addEventHandler ( "onPlayerDamage", root, function ( cop, weapon, _, loss ) 
	-- arrest system
	if ( isElement ( cop ) and weapon and cop ~= source  ) then
		
		if ( getElementData ( cop, "SAEGEvents:IsPlayerInEvent" ) or getElementData ( source, "SAEGEvents:IsPlayerInEvent" ) ) then
			return 
		end
	
		if ( cop == source ) then return end
		if ( getElementType ( cop ) == 'vehicle' ) then
			cop = getVehicleOccupant ( cop )
		end
		if ( not isElement ( cop ) or getElementType ( cop ) ~= 'player' ) then return end
		if ( not getPlayerTeam ( cop ) ) then
			return
		end

		if ( exports['SAEGPlayerFunctions']:isTeamLaw ( getTeamName ( getPlayerTeam ( cop ) ) ) ) then
			if ( getElementData ( source, "isSpawnProtectionEnabled" ) == true ) then 
				return exports['SAEGMessages']:sendClientMessage ( "This player has spawn-protection enabled.", cop, 255, 0, 0 ) 
			end
			
			if ( getPlayerTeam ( source ) and getTeamName ( getPlayerTeam ( source ) ) == "Staff" ) then 
				return exports['SAEGMessages']:sendClientMessage ( "You cannot arrest/tase on-duty staff.", cop, 255, 0, 0 ) 
			end
			
			if ( arresties[source] ) then 
				return exports['SAEGMessages']:sendClientMessage ( "This player is already arrested.", cop, 255, 0, 0 ) 
			end
			if ( getPlayerWantedLevel ( source ) >= 1 ) then
				if ( weapon == 3 ) then
					-- Arrest
					arrestPlayer ( source, cop )
					exports['SAEGMessages']:sendClientMessage ( "You have arrested "..getPlayerName ( source )..", take him to a police station.", cop, 0, 255, 0 )
					exports['SAEGMessages']:sendClientMessage ( getPlayerName ( cop ).." arrested you!", source, 255, 255, 0 )
					setElementHealth ( source, getElementHealth ( source ) + loss )
					setElementData ( source, "SAEGJobs:ArrestingOfficer", cop )
					triggerClientEvent( cop,"copdirections",cop)
					addEventHandler ( "onPlayerQuit", source, onPlayerAttmemptArrestAvoid );
				elseif ( weapon == 23 ) then
					-- Taze Player
					if ( tased [ source ] ) then
						return exports.SAEGMessages:sendClientMessage ( "This player is already tased", cop, 255, 255, 255 )
					end
					
					local a = cop
					local t = getPlayerTeam ( a )
					if ( not t ) then return end
					if ( getPlayerWantedLevel ( source ) == 0 ) then return end
					if ( exports.SAEGPlayerFunctions:isTeamLaw ( getTeamName ( t ) ) and not getElementData ( source, "SAEGJobs:ArrestingOfficer" ) ) then
						-- now we know:
						-- source 	-> wanted, not arrested
						-- w 		-> teaser
						toggleAllControls ( source, false )
						if ( isPedInVehicle ( source ) ) then
							removePedFromVehicle ( source )
						end
						setPedAnimation(source, "CRACK", "crckdeth2", 4000, false, true, false)
						
						exports.SAEGMessages:sendClientMessage ( "You have tased ".. getPlayerName ( source ), a, 0, 255, 0 )
						exports.SAEGMessages:sendClientMessage ( "You have been tased by "..getPlayerName ( a ), source, 255, 0, 0 )
						tased [ source ] = true
						setTimer ( function ( p, c )
							if ( isElement ( p ) ) then
								setPedAnimation ( p )
								toggleAllControls ( p, true )
								exports.SAEGMessages:sendClientMessage ( "You are no longer tased", p, 0, 255, 0 )
								if ( isElement ( c ) ) then
									exports.SAEGMessages:sendClientMessage ( getPlayerName ( p ).." is now un-tased!", c, 255, 255, 0 )
								end
							end
							tased [ p ] = false
						end, 4000, 1, source, a )
					end
				else
					if ( isPedInVehicle ( cop ) ) then return end 
					exports['SAEGMessages']:sendClientMessage ( "Use a nightstick to arrest and a silenced pistol to tase", cop, 255, 255, 255 )
				end
			else
				local f = math.floor ( loss * 1.2)
				setElementHealth ( cop, getElementHealth ( cop ) - f )
				exports['SAEGMessages']:sendClientMessage ( "You've lost "..tostring ( f ).."% health for hurting an innocent player.", cop, 255, 255, 0 )
			end
		end	
	end
end )

function onPlayerAttmemptArrestAvoid ( )
	--outputChatBox ( getPlayerName ( source )..  " attempted to arrest avoid" )
	triggerEvent ( "saegpolice:onJailCopCrimals", getElementData ( source, "SAEGJobs:ArrestingOfficer" ) )
end

addCommandHandler ( "release", function ( p, _, p2 )
	if ( getPlayerTeam ( p ) and exports['SAEGPlayerFunctions']:isTeamLaw ( getTeamName ( getPlayerTeam ( p ) ) ) ) then
		if ( p2 ) then
			local c = getPlayerFromName ( p2 ) or exports['SAEGPlayerFunctions']:getPlayerFromNamePart ( p2 )
			if c then
				if ( arresties[c] ) then
					if ( getElementData ( c, "SAEGJobs:ArrestingOfficer") == p ) then
						exports['SAEGMessages']:sendClientMessage ( "You have released "..getPlayerName ( c ), p, 0, 255, 0)
						exports['SAEGMessages']:sendClientMessage ( getPlayerName ( p ).." released you.", c, 0, 255, 0 )
						releasePlayer ( c )
						local arresties2 = { }
						for i, v in pairs ( arresties ) do
							if ( getElementData ( v, "SAEGJobs:ArrestingOfficer" ) == p ) then
								table.insert ( arresties2, v )
							end
						end
						triggerClientEvent ( root, "onPlayerEscapeCop", root, c, p, arresties2 )
					else exports['SAEGMessages']:sendClientMessage ( "You're not "..getPlayerName ( c ).."'s arresting officer, you cannot release him.", p, 255, 255, 0 ) end
				else exports['SAEGMessages']:sendClientMessage ( getPlayerName ( c ).." isn't being arrested", p, 255, 255, 0 ) end
			else exports['SAEGMessages']:sendClientMessage ( p2.." doesn't exist. ", p, 255, 255, 0 ) end
		else exports['SAEGMessages']:sendClientMessage ( "Syntax error. /release [player]", p, 255, 255, 0 ) end
	else exports['SAEGMessages']:sendClientMessage ( "You're not a law officer.", p, 255, 255, 0 ) end
end )

function arrestPlayer ( crim, cop )
	showCursor ( crim, true )
	arresties[crim] = true
	toggleControl ( crim, 'right', false )
	toggleControl ( crim, 'left', false )
	toggleControl ( crim, 'forwards', false )
	toggleControl ( crim, 'backwards', false )
	toggleControl ( crim, 'jump', false )
	toggleControl ( crim, 'sprint', false )
	toggleControl ( crim, 'walk', false )
	toggleControl ( crim, 'fire', false )
	onTimer ( crim, cop )
	triggerClientEvent ( root, "onPlayerStartArrested", root, crim, cop )
end

function onTimer ( crim, cop )
	if ( isElement ( crim ) and isElement ( cop ) ) then
		if ( not getPlayerTeam ( cop ) or not exports['SAEGPlayerFunctions']:isTeamLaw ( getTeamName ( getPlayerTeam ( cop ) ) ) ) then return releasePlayer ( crim ) end
		if ( not arresties[crim] ) then return  end
		local cx, cy, cz = getElementPosition ( crim )
		local px, py, pz = getElementPosition ( cop )
		local rot = findRotation ( cx, cy, px, py )
		setPedRotation ( crim, rot )
		setCameraTarget ( crim, crim )
		local dist = getDistanceBetweenPoints3D ( cx, cy, cz, px, py, pz )
		if ( isPedInVehicle ( cop ) ) then
			if ( not isPedInVehicle ( crim ) ) then
				warpPedIntoVehicle ( crim, getPedOccupiedVehicle ( cop ), 1 )
			end
		else
			if ( isPedInVehicle ( crim ) ) then
				removePedFromVehicle ( crim )
			end
		end
		if ( not isPedInVehicle ( crim ) ) then
			if ( dist >= 20 ) then
				setElementPosition ( crim, px +1, py+1, pz )
			elseif ( dist >= 15 ) then
				setControlState ( crim, 'walk', false )
				setControlState ( crim, 'jump', true )
				setControlState ( crim, 'sprint', true )
				setControlState ( crim, "forwards", true )
			elseif ( dist >= 10 ) then
				setControlState ( crim, 'walk', false )
				setControlState ( crim, 'jump', false )
				setControlState ( crim, 'sprint', true )
				setControlState ( crim, "forwards", true )
			elseif ( dist >= 7 ) then
				setControlState ( crim, 'walk', false )
				setControlState ( crim, 'jump', true )
				setControlState ( crim, 'sprint', false )
				setControlState ( crim, "forwards", true )
			elseif ( dist >= 2 ) then
				setControlState ( crim, 'walk', true )
				setControlState ( crim, 'jump', false )
				setControlState ( crim, 'sprint', false )
				setControlState ( crim, "forwards", true )
			else
				setControlState ( crim, 'walk', false )
				setControlState ( crim, 'jump', false )
				setControlState ( crim, 'sprint', false )
				setControlState ( crim, "forwards", false )
			end
		end
		
		crim.interior = cop.interior;
		crim.dimension = cop.dimension
		
		setTimer ( onTimer, 500, 1, crim, cop )
	else
		arresties[crim] = false
		if ( not isElement ( cop ) and isElement ( crim ) ) then
			releasePlayer ( crim )
			exports['SAEGMessages']:sendClientMessage ( "Your arresting officer has quit, therefore, you've been released.", crim, 0, 255, 0 )
		end
	end
end

function findRotation(x1,y1,x2,y2)
	local t = -math.deg(math.atan2(x2-x1,y2-y1))
	if t < 0 then t = t + 360 end;
	return t;
end

function releasePlayer ( p )
	toggleAllControls ( p, true )
	setControlState ( p, 'walk', false )
	setControlState ( p, 'jump', false )
	setControlState ( p, 'sprint', false )
	setControlState ( p, "forwards", false )
	setElementData ( p, "SAEGJobs:ArrestingOfficer", nil )
	arresties[p] = nil
	showCursor ( p, false )
	removeEventHandler ( "onPlayerQuit", p, onPlayerAttmemptArrestAvoid );
end


function onJailCopCriminals( mx, my, mz )
	for v, _ in pairs ( arresties ) do 
		if ( getElementData ( v, "SAEGJobs:ArrestingOfficer" ) == source ) then
			
			releasePlayer ( v )
			local time = math.floor ( ( getElementData ( v, "WantedPoints" )  ) or 50 )
			local orgTime = time
			local vip = getElementData ( v, "VIP" )
			if ( exports.SAEGVIP:getVipLevelFromName ( vip ) == 4 ) then
				time = time - ( time * 0.5 )
				exports.SAEGMessages:sendClientMessage ( "You're serving 50% less jail time due to diamond VIP! (Original time: "..orgTime.." seconds)", v, 0, 255, 0 )
			elseif ( exports.SAEGVIP:getVipLevelFromName ( vip ) == 3  ) then
				time = time - ( time * 0.25 )
				exports.SAEGMessages:sendClientMessage ( "You're serving 25% less jail time due to gold VIP! (Original time: "..orgTime.." seconds)", v, 0, 255, 0 )
			elseif ( exports.SAEGVIP:getVipLevelFromName ( vip ) == 2 ) then
				time = time - ( time * 0.15 )
				exports.SAEGMessages:sendClientMessage ( "You're serving 15% less jail time due to silver VIP! (Original time: "..orgTime.." seconds)", v, 0, 255, 0 )
			elseif ( exports.SAEGVIP:getVipLevelFromName ( vip ) == 1 ) then
				time = time - ( time * 0.05 )
				exports.SAEGMessages:sendClientMessage ( "You're serving 5% less jail time due to bronze VIP! (Original time: "..orgTime.." seconds)", v, 0, 255, 0 )
			end
			
			local time = math.floor ( time )
			givePlayerMoney ( source, math.floor ( orgTime*2 ) )
			exports['SAEGMessages']:sendClientMessage ( "You were paid $"..math.floor ( orgTime*2 ).." for arresting "..getPlayerName ( v ).."!", source, 0, 255, 0 )
			exports['SAEGPolice']:jailPlayer ( v, time, false, mx, my, mz, source, "Police Arrest" )
			updateJobColumn ( getAccountName ( getPlayerAccount ( source ) ), "Arrests", "AddOne" )
		end
	end
end
addEvent ( "saegpolice:onJailCopCrimals", true )
addEventHandler ( "saegpolice:onJailCopCrimals", root, onJailCopCriminals )

Jail_ server side : 

local jailedPlayers = { }

function isPlayerJailed ( p )
	if ( p and getElementType ( p ) == 'player' ) then
		if ( jailedPlayers[p] ) then
			return tonumber ( getElementData ( p, 'SAEGPolice:JailTime' ) )
		else
			return false
		end
	end
	return nil
end

function jailPlayer ( p, dur, announce, element, reason ) 
	if( p and dur ) then
		local announce = announce or false
		jailedPlayers[p] = dur
		setElementInterior ( p, 0 )
		setElementDimension ( p, 33 )
		
		local __x, __y, __z = unpack ( WARP_LOCS.DEFAULT )
		if ( element and reason ) then
			__x, __y, __z = unpack ( WARP_LOCS.ADMIN )
		end 
		
		setElementPosition ( p, __x, __y, __z );
		--outputChatBox ( table.concat ( { __x, __y, __z }, ", " ) );
		
		setElementData ( p,'SAEGPolice:JailTime', tonumber ( dur ) )
		setElementData ( p, "isGodmodeEnabled", true )
		exports['SAEGJobs']:updateJobColumn ( getAccountName ( getPlayerAccount ( p ) ), 'TimesArrested', "AddOne" )
		if ( announce ) then
			local reason = reason or "Classified"
			local msg = ""
			if ( element and reason ) then
				msg = getPlayerName ( p ).." has been jailed by "..getPlayerName ( element ).." for "..tostring ( dur ).." seconds ("..reason..")"
			elseif ( element ) then
				msg =  getPlayerName ( p ).." has been jailed by "..getPlayerName ( element ).." for "..tostring ( dur ).." seconds"
			end
			exports['SAEGMessages']:sendClientMessage ( msg, root, 0, 120, 255 )
			exports['SAEGLogs']:outputPunishLog ( p, element or "Console", tostring ( msg ) )
		end
		triggerEvent ( "onPlayerArrested", p, dur, element, reason )
		triggerClientEvent ( p, "onPlayerArrested", p, dur, element, reason )
		return true
	end
	return false
end

function unjailPlayer ( p, mx, my, mz, triggerClient )
	local p = p or source
	setElementDimension ( p, 0 )
	setElementInterior ( p, 0 )
	setElementPosition ( p, mx, my, mz )
	exports['SAEGMessages']:sendClientMessage ( "You've been released from jail! Behave next time.", p, 0, 255, 0 )
	jailedPlayers[p] = nil
	setElementData ( p, "SAEGPolice:JailTime", nil )
	setElementData ( p, "isGodmodeEnabled", nil )
	exports['SAEGLogs']:outputActionLog ( getPlayerName ( p ).." has been unjailed" )
	if ( triggerClient ) then
		triggerClientEvent ( p, 'SAEGJail:StopJailClientTimer', p ) 
	end
end
addEvent ( "SAEGJail:UnjailPlayer", true )
addEventHandler ( "SAEGJail:UnjailPlayer", root, unjailPlayer )

jail_serverside .lua:54: Bad Argument @ 'setElementPosition' expected vector 3 at argument 2 , got nill

It's not WSS leaked OMG guys -_- i'm using Nerd gaming scripts and trying to developer them ,

Thx to who can help

 

Link to comment

OMG it's Nerd gaming scripts -_- and Other SAEG using WSS leaked police and the other saeg is not mine -_- he did it when i left mta for 3 month -_- did you understand now ?? check my all old topics and you know if i'm using WSS leaked or no pffffffffff

i swear it's Nerd gaming scripts Comon pls help 

Link to comment

ah i'm sory and this jail Client Side 

local remainingTime = nil
local sx, sy = guiGetScreenSize ( )

addEvent ( "onPlayerArrested", true )
addEventHandler ( "onPlayerArrested", root, function ( dur )
	if dur then
		remainingTime = dur
		l_tick = getTickCount ( )
		addEventHandler ( 'onClientRender', root, dxDrawRemainingJailTime )
	end
end )

function dxDrawRemainingJailTime ( mx, my, mz )
	dxDrawText ( tostring ( remainingTime ).. " seconds", 0, 0, (sx/1.1)+2, (sy/1.1)+2, tocolor ( 0, 0, 0, 255 ), 2.5, 'default-bold', 'right', 'bottom' )
	dxDrawText ( tostring ( remainingTime ).. " seconds", 0, 0, sx/1.1, sy/1.1, tocolor ( 255, 255, 0, 255 ), 2.5, 'default-bold', 'right', 'bottom' )
	if ( getTickCount ( ) - l_tick >= 1000 ) then
		remainingTime = remainingTime - 1
		l_tick = getTickCount ( )
		setElementData ( localPlayer, "SAEGPolice:JailTime", remainingTime ) 
		if ( remainingTime < 0 ) then
			triggerServerEvent ( "SAEGJail:UnjailPlayer", localPlayer, mx, my, mz, false )
			remainingTime = nil
			l_tick = nil
			removeEventHandler ( "onClientRender", root, dxDrawRemainingJailTime )
		end
	end
end

addEvent ( "SAEGJail:StopJailClientTimer", true )
addEventHandler ( "SAEGJail:StopJailClientTimer", root, function ( )
	remainingTime = nil
	l_tick = nil
	removeEventHandler ( "onClientRender", root, dxDrawRemainingJailTime )
end )


-------------------------------
-- Export functions 
-- Implemented in NG V1.1.3
-------------------------------
function isPlayerJailed ( )
	return ( 
		getElementData ( localPlayer, 'SAEGPolice:JailTime' ) and 
		tonumber ( getElementData ( localPlayer, 'SAEGPolice:JailTime' ) ) 
		) and 
		tonumber ( getElementData ( localPlayer, 'SAEGPolice:JailTime' ) ) > 0
end

 

Link to comment

You're telling us that you're not using leaked scripts. Well it looks like you do.. the Scripting section is filled with your topics and it looks like you have some resource (or a set of resources) that doesn't work and you just keep posting topics asking us to fix bits of these resources and hoping that you can somehow put it together and that it will eventually work. That's just awful and this section is not intended for this.

  • Like 1
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...