Monty Posted April 23, 2012 Share Posted April 23, 2012 i downloadded this script... this is a client-side.... what's wrong? when i arrest someone it says cuffed but the criminal can go anywhere local curTarget local screenX , screenY = guiGetScreenSize ( ) addEvent('playCD', true) addEventHandler('playCD', root, function(cd) playSound(cd..'.mp3', false) end ) addEvent ( "client:setPlayerFollowPlayer" , true ) addEventHandler ( "client:setPlayerFollowPlayer" , root , function ( bool , target ) if bool then curTarget = target addEventHandler ( "onClientRender" , root , setPlayerFollowPlayer ) else showCursor(false) toggleAllControls(true) removeEventHandler ( "onClientRender" , root , setPlayerFollowPlayer ) end end ) function setPlayerFollowPlayer ( ) if isPedInVehicle ( curTarget ) then local vehicle = getPedOccupiedVehicle ( curTarget ) local seat = getPedOccupiedVehicleSeat ( curTarget ) if not warpPedIntoVehicle ( source , vehicle , seat + 1 ) then local posX , posY , posZ = getElementPosition ( vehicle ) setElementPosition ( source , posX , posY , posZ + 1 ) attachRotationAdjusted ( source , vehicle ) end else if isPedInVehicle ( source ) then removePedFromVehicle ( source ) end local posX , posY , posZ = getElementPosition ( source ) local posX2 , posY2 , posZ2 = getElementPosition ( curTarget ) local rotation = math.deg ( math.atan2 ( posX2 - posX , posY2 - posY ) ) % 360 setElementRotation ( source , 0 , 0 , 360 - rotation ) setCameraTarget ( source ) local distance = getDistanceBetweenPoints2D(posX2, posY2, posX, posY) if distance > 22 then setElementData(source, "Cuffed", false) setElementData(source, "Handcuffer", "") showCursor(false) toggleAllControls(true) removeEventHandler ( "onClientRender" , root , setPlayerFollowPlayer ) elseif distance > 12 then setControlState("sprint", true) setControlState("walk", false) setControlState("forwards", true) elseif distance > 6 then setControlState("sprint", false) setControlState("walk", false) setControlState("forwards", true) elseif distance > 1.5 then setControlState("sprint", false) setControlState("walk", true) setControlState("forwards", true) elseif distance < 1.5 then setControlState("sprint", false) setControlState("walk", false) setControlState("forwards", false) end end end function Follow(target, player) if not isPedInVehicle(player) then local px, py, pz = getElementPosition(player) local tx, ty, tz = getElementPosition(target) local angle = ( 360 - math.deg ( math.atan2 ( ( px - tx ), ( py - ty ) ) ) ) % 360 setPedRotation(target, angle) setCameraTarget(target) local distance = getDistanceBetweenPoints2D(px, py, tx, ty) if distance > 22 then stopFollow(target, player) setElementData(target, "Cuffed", false) setElementData(target, "Handcuffer", "") elseif distance > 12 then setControlState(target, "sprint", true) setControlState(target, "walk", false) setControlState(target, "forwards", true) followTimer[target] = setTimer(Follow, 500, 1, target, player) elseif distance > 6 then setControlState(target, "sprint", false) setControlState(target, "walk", false) setControlState(target, "forwards", true) followTimer[target] = setTimer(Follow, 500, 1, target, player) elseif distance > 1.5 then setControlState(target, "sprint", false) setControlState(target, "walk", true) setControlState(target, "forwards", true) followTimer[target] = setTimer(Follow, 500, 1, target, player) elseif distance < 1.5 then setControlState(target, "sprint", false) setControlState(target, "walk", false) setControlState(target, "forwards", false) followTimer[target] = setTimer(Follow, 500, 1, target, player) end end end function attachRotationAdjusted ( from, to ) local frPosX, frPosY, frPosZ = getElementPosition( from ) local frRotX, frRotY, frRotZ = getElementRotation( from ) local toPosX, toPosY, toPosZ = getElementPosition( to ) local toRotX, toRotY, toRotZ = getElementRotation( to ) local offsetPosX = frPosX - toPosX local offsetPosY = frPosY - toPosY local offsetPosZ = frPosZ - toPosZ local offsetRotX = frRotX - toRotX local offsetRotY = frRotY - toRotY local offsetRotZ = frRotZ - toRotZ offsetPosX, offsetPosY, offsetPosZ = applyInverseRotation ( offsetPosX, offsetPosY, offsetPosZ, toRotX, toRotY, toRotZ ) attachElements( from, to, offsetPosX, offsetPosY, offsetPosZ, offsetRotX, offsetRotY, offsetRotZ ) end function applyInverseRotation ( x,y,z, rx,ry,rz ) local DEG2RAD = (math.pi * 2) / 360 rx = rx * DEG2RAD ry = ry * DEG2RAD rz = rz * DEG2RAD local tempY = y y = math.cos ( rx ) * tempY + math.sin ( rx ) * z z = -math.sin ( rx ) * tempY + math.cos ( rx ) * z local tempX = x x = math.cos ( ry ) * tempX - math.sin ( ry ) * z z = math.sin ( ry ) * tempX + math.cos ( ry ) * z tempX = x x = math.cos ( rz ) * tempX + math.sin ( rz ) * y y = -math.sin ( rz ) * tempX + math.cos ( rz ) * y return x, y, z end addEventHandler ( "onClientRender" , root , function ( ) for index , player in ipairs ( getElementsByType ( "player" ) ) do if not getElementData ( player , "Arrested" ) then return end if getElementData(player, "Timeleft") < 1 then return end dxDrawFramedText ( "Time left: " .. getElementData ( player , "Timeleft" ) , ( screenX / 1440 ) * 720 , ( screenY / 900 ) * 200 , ( screenX / 1440 ) * 1440 , ( screenY / 900 ) * 200 , tocolor ( 255 , 255 , 255 , 255 ) , ( screenX / 1440 ) * 3 , "default-bold" , "center" , "center" , false , false , true ) if getElementData ( player , "Timeleft" ) < 6 then playSound ( getElementData ( player , "Timeleft" ) .. ".mp3" , false ) return end end end ) Link to comment
Wei Posted April 23, 2012 Share Posted April 23, 2012 I see that you are downloaded J-Jobs. If you use only police-server and police-client will not work. You need to use utils as well. Or script may not work. You need to completly modify it. Link to comment
Monty Posted April 23, 2012 Author Share Posted April 23, 2012 this is the server-side local LSPDColShape = createColTube ( 1544.599609375, -1675.6923828125, 13.558725357056 , 5 , 5 ) addEventHandler("onPlayerJoin", root, function() setElementData(source, "justDamaged", false) end ) function outputPoliceRadio(msg, msg2) if msg and msg2 then for i, v in ipairs(getPlayersInTeam(getTeamFromName("Police"))) do outputChatBox("LSP Radio: "..msg, v, settingPoliceTeamColor [ 1 ] , settingPoliceTeamColor [ 2 ] , settingPoliceTeamColor [ 3 ]) outputChatBox(msg2, v, settingPoliceTeamColor [ 1 ] , settingPoliceTeamColor [ 2 ] , settingPoliceTeamColor [ 3 ]) end else for i, v in ipairs(getPlayersInTeam(getTeamFromName("Police"))) do outputChatBox("LSP Radio: "..msg, v, settingPoliceTeamColor [ 1 ] , settingPoliceTeamColor [ 2 ] , settingPoliceTeamColor [ 3 ]) end end end addEventHandler ( "onPlayerDamage" , root , function ( attacker , attackerWeapon ) if getElementHealth ( source ) < 1 then return end if not isPlayerInTeam ( attacker , "Police" ) then return end if not attacker or attacker == source then return end if getPlayerWantedLevel ( source ) < 1 then return end if getElementData ( source , "Cuffed" ) then return end if attackerWeapon ~= 3 then return end setElementData(source, "Cuffed", true) setElementData(source, "Handcuffer", getPlayerName(attacker)) outputPoliceRadio(getPlayerName(source).." has been handcuffed by "..getPlayerName(attacker)) outputChatBox("You have been handcuffed by " .. getPlayerName ( attacker ), source) outputChatBox("Take " .. getPlayerName ( source ) .. " to LSPD to arrest him" , attacker ) toggleAllControls(source, false, true, false) showCursor(source, true) setPlayerFollowPlayer ( source , attacker ) end ) function setPlayerFollowPlayer ( player , target ) triggerClientEvent ( player , "client:setPlayerFollowPlayer" , player , true , target ) end addCommandHandler("uncuff", function(player, _, name) if not isPlayerInTeam(player, "Police") then return outputChatBox("You are not a cop", player) end if not name then return outputChatBox("Syntax: /uncuff <player partial name>", player) end local target = findPlayer(name, player) if not target then return end if target == player then return outputChatBox("You can't uncuff yourself", player) end if not getElementData(target, "Cuffed") then return outputChatBox(getPlayerName(target).." is not cuffed", player) end local tx, ty, tz = getElementPosition(target) if not isPlayerInRangeOfPoint(player, tx, ty, tz, 3) then return outputChatBox("You are too far from "..getPlayerName(target), player) end if not getElementData(target, "Handcuffer") == getPlayerName(player) then return outputChatBox("You didn't cuff "..getPlayerName(target), player) end setElementData(target, "Cuffed", false) setElementData(target, "Handcuffer", "") outputChatBox(getPlayerName(player).." has uncuffed you", target) outputPoliceRadio(getPlayerName(target).." has been uncuffed by "..getPlayerName(player)) triggerClientEvent ( target , "client:setPlayerFollowPlayer" , target , false , player ) end ) addEventHandler ( "onColShapeHit" , LSPDColShape , function ( hElement , mDim ) if not mDim then return end if getElementType ( hElement ) ~= player then return end if getPlayerWantedLevel ( hElement ) < 1 then return end if not getElementData ( hElement , "Cuffed" ) then return end local player = getPlayerFromName ( getElementData ( hElement , "Handcuffer" ) ) if not player then return end local wantedLevel = getPlayerWantedLevel ( hElement ) fadeCamera(hElement, false) setTimer(setElementInterior, 1000, 1, hElement, settingPrisonLocation [ 4 ]) setTimer(setElementPosition, 1000, 1, hElement, settingPrisonLocation [ 1 ] , settingPrisonLocation [ 2 ] , settingPrisonLocation [ 3 ] ) setTimer(setElementDimension, 1000, 1, hElement, settingPrisonLocation [ 5 ] ) setTimer(setElementRotation, 1000, 1, hElement, settingPrisonLocation [ 6 ]) setTimer(fadeCamera, 1000, 1, hElement, true) outputPoliceRadio ( getPlayerName ( hElement ) .. " has been arrested by " .. getPlayerName ( player ) ) if settingTakePlayerWeaponsOnArrest then takeAllWeapons(hElement) end setElementData(hElement, "Arrested", true) setElementData(hElement, "Cuffed", false) setElementData(hElement, "Handcuffer", "") if wantedLevel == 1 then givePlayerMoney(player, 1000) takePlayerMoney(hElement, 5000) setElementData(hElement, "Timeleft", 30) setTimer ( releasePlayer , 30000 , 1 , hElement ) elseif wantedLevel == 2 then givePlayerMoney(player, 2000) takePlayerMoney(hElement, 8000) setElementData(hElement, "Timeleft", 60) setTimer ( releasePlayer , 60000 , 1 , hElement ) elseif wantedLevel == 3 then givePlayerMoney(player, 3000) takePlayerMoney(hElement, 10000) setElementData(hElement, "Timeleft", 120) setTimer ( releasePlayer , 120000 , 1 , hElement ) elseif wantedLevel == 4 then givePlayerMoney(player, 4000) takePlayerMoney(hElement, 12000) setElementData(hElement, "Timeleft", 180) setTimer ( releasePlayer , 180000 , 1 , hElement ) elseif wantedLevel == 5 then givePlayerMoney(player, 5000) takePlayerMoney(hElement, 15000) setElementData(hElement, "Timeleft", 200) setTimer ( releasePlayer , 200000 , 1 , hElement ) elseif wantedLevel == 6 then givePlayerMoney(player, 8000) takePlayerMoney(hElement, 20000) setElementData(hElement, "Timeleft", 240) setTimer ( releasePlayer , 240000 , 1 , hElement ) end setPlayerWantedLevel(hElement, 0) end ) function releasePlayer(player) fadeCamera(player, false) setTimer(setElementInterior, 1000, 1, player, 0) setTimer(setElementPosition, 1000, 1, player, 1544.0986328125, -1675.591796875, 13.557745933533) setTimer(setPedRotation, 1000, 1, player, 90) setTimer(setElementDimension, 1000, 1, player, 0) setTimer(fadeCamera, 1000, 1, player, true) setTimer(outputChatBox, 1000, 1, "You have been released from jail , try to be a better citizen", player) setTimer(outputPoliceRadio, 1000, 1, getPlayerName(player).." has been released from jail") setTimer(setElementData, 1000, 1, player, "Arrested", false) toggleAllControls(player, true) showCursor(player, false) end addCommandHandler("release", function(player, _, name) if not isPlayerInTeam(player, "Police") then return outputChatBox("You are not a cop", player) end if not name then return outputChatBox("Syntax: /release <player partial name>", player) end local target = findPlayer(name, player) if not target then return end if target == player then return outputChatBox("You can't release yourself", player) end if not getElementData(target, "Arrested") then return outputChatBox(getPlayerName(target).." is not arrested", player) end releasePlayer(player) end ) local rb = {} addCommandHandler("rb", function(player, cmd) if not isPlayerInTeam(player, "Police") then return outputChatBox("You are not a cop", player) end if getElementData(player, "RB") then return outputChatBox("You have already deployed a road block", player, 192, 192, 192) end local x, y, z = getElementPosition(player) local rx, ry, rz = getElementRotation(player) rb[player] = createObject ( 981, x+4, y, z, rx, ry, rz) setElementData(rb[player], "creator", getPlayerName(player)) setElementData(player, "RB", true) outputPoliceRadio(getPlayerName(player).." deployed a road block at "..getZoneName(x, y, z)) end ) addCommandHandler("rrb", function(player, cmd) if not isPlayerInTeam(player, "Police") then return outputChatBox("You are not a cop", player) end if not getElementData(player, "RB") then return outputChatBox("You haven't deployed any road blocks", player, 192, 192, 192) end for i, v in ipairs(getElementsByType("object")) do if getElementModel(v) == 981 then if getElementData(v, "creator") == getPlayerName(player) then local x, y, z = getElementPosition(v) destroyElement(v) outputPoliceRadio(getPlayerName(player).." removed a road block at "..getZoneName(x, y, z)) setElementData(player, "RB", false) break end end end end ) addCommandHandler("free", function(player, cmd, name, ...) if not isPlayerInTeam(player, "Police") then return outputChatBox("You are not a cop", player) end if not name then return outputChatBox("Syntax: /free <partial Name> <reason>", player) end if ... then local target = findPlayer(name, src) if not target then return end if target == player then return outputChatBox("You can't free yourself", player) end local reason = table.concat({...}, " ") setPlayerWantedLevel(target, 0) outputPoliceRadio(getPlayerName(target).." has been freed by "..getPlayerName(player), "Reason: "..reason) else local target = findPlayer(name, src) if not target then return end if target == player then return outputChatBox("You can't free yourself", player) end setPlayerWantedLevel(target, 0) outputPoliceRadio(getPlayerName(target).." has been freed by "..getPlayerName(player), "Reason: Not Specified") end end ) addCommandHandler("ticket", function(player, _, name, ammount) if not isPlayerInTeam(player, "Police") then return outputChatBox("You are not a cop", player) end if not name or not ammount and tonumber(ammount) ~= nil then return outputChatBox("Syntax: /ticket <partial Name> <ammount>", player) end local target = findPlayer(name, player) if not target then return end if target == player then return outputChatBox("You can't ticket yourself", player) end if getPlayerWantedLevel(target) == 0 then return outputChatBox(getPlayerName(target).." is not a criminal", player) end if not getElementData(target, "Cuffed") then return outputChatBox(getPlayerName(target).." is not cuffed", player) end if not getElementData(target, "Handcuffer") == getPlayerName(player) then return outputChatBox("You didn't cuff that player", player) end if tonumber(ammount) < 100 then return outputChatBox("The ammount must be higher than $100", player) end if not getElementData(target, "gotTicket") then ammount = tonumber(ammount) setElementData(target, "gotTicket", true) setElementData(target, "ticketAmmount", ammount) outputChatBox(getPlayerName(player).." gave u a ticket with $"..ammount.." go pay it in LSPD", target, 255, 255, 0) toggleAllControls(target, true) showCursor(target, false) outputPoliceRadio(getPlayerName(player).." gave "..getPlayerName(target).." a ticket with $"..ammount) stopFollow(target, player) setElementData(target, "Cuffed", false) setElementData(target, "Handcuffer", "") else ammount = tonumber(ammount) setElementData(target, "ticketAmmount", getElementData(target, "ticketAmmount") + ammount) outputChatBox(getPlayerName(player).." gave u a ticket with $"..ammount.." go pay it in LSPD", target, 255, 255, 0) toggleAllControls(target, true) showCursor(target, false) outputPoliceRadio(getPlayerName(player).." gave "..getPlayerName(target).." a ticket with $"..ammount) stopFollow(target, player) setElementData(target, "Cuffed", false) Link to comment
CapY Posted April 24, 2012 Share Posted April 24, 2012 i downloadded this script... this is a client-side.... what's wrong? when i arrest someone it says cuffed but the criminal can go anywhere Because the resource needs improvements and the resource author did not do an update for a while. Link to comment
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