Jump to content

Police Script [ HELP ]


damien111

Recommended Posts

I need help with making it so when a player is hit with a nightstick and his wlevel is higher than 0 he is sent to the jail for 10seconds * wlevel. :/. doesnt matter who hits them with the nightstick, cause nighstick will be a police only weapon. :) sso can anyone help? Also. How can i make it so peoples money is saved, off topic but it will help me Thanks

Link to comment

Example of code:

--CLIENT SIDE 
addEventHandler("onClientPlayerDamage", localPlayer, 
    function (attacker, weapon) 
        if (attacker and source ~= attacker) then 
            if (getElementType ( attacker ) == "player") then 
                if ( weapon == 3 and getTeamName(getPlayerTeam(attacker)) == "Police" ) then 
                    local SourceWantedLevel = getPlayerWantedLevel() 
                    if ( SourceWantedLevel > 0 ) then 
                        if ( getElementHealth ( source ) < 90 and getElementHealth ( source ) > 0 )then 
                            triggerServerEvent("POLICESYS:JailThePlayer", localPlayer, attacker)  
                        end 
                    end 
                end 
            end 
        end 
    end 
) 
  
  
  
--SERVER SIDE 
addEvent("POLICESYS:JailThePlayer",true) 
addEventHandler("POLICESYS:JailThePlayer",root, 
function (attacker) 
    local x = 1  
    local y = 1 
    local z = 1 
    givePlayerMoney ( attacker, math.random(500, 1000) ) --Give money to cop 
    setElementPosition ( source, x, y, z, true ) 
end 
) 

Link to comment

Alright! Heres my code so far! It is not working, i did /debugscript 3, here are the errors if that will hep. i did not understand them :

Loading script failed : POLICE5/arrest_server.lua:3 '' expected near '('

Loading script failed : POLICE5/arrest_client.lua:15 ')' expected (to close '(' at line 1) near

CLIENT

addEventHandler("onClientPlayerDamage", localPlayer, 
    function (attacker, weapon) 
        if (attacker and source ~= attacker) then 
            if (getElementType ( attacker ) == "player") then 
                if ( weapon == 3 and getTeamName(getPlayerTeam(attacker)) == "Police" ) then 
                    local SourceWantedLevel = getPlayerWantedLevel() 
                    if ( SourceWantedLevel > 0 ) then 
                        if ( getElementHealth ( source ) < 90 and getElementHealth ( source ) > 0 )then 
                            triggerServerEvent("POLICESYS:JailThePlayer", localPlayer, attacker) 
                        end 
                    end 
                end 
            end 
        end 
    end 

SERVER

level = getPlayerWantedLevel ( source ) 
reward = 3000 
function ( attacker ) 
    local x = -4162.3032226563 
    local y = 1697.4566650391 
    local z = 1.0687500238419 
    givePlayerMoney ( attacker, reward ) --Give money to cop 
    setElementPosition ( source, x, y, z, true ) 
    setTimer ( releaseSuspect, 30000, 1 ) 
end 
addEvent("POLICESYS:JailThePlayer",true) 
addEventHandler("POLICESYS:JailThePlayer",root) 
  
function releaseSuspect ( ) 
local x = 2285.9599609375 
local y = 2423.1164550781 
local z = 10.8203125 
    setElementPosition ( source, x, y, z, true ) 
end 

Link to comment
addEventHandler("onClientPlayerDamage", localPlayer, 
    function (attacker, weapon) 
        if (attacker and source ~= attacker) then 
            if (getElementType ( attacker ) == "player") then 
                if ( weapon == 3 and getTeamName(getPlayerTeam(attacker)) == "Police" ) then 
                    local SourceWantedLevel = getPlayerWantedLevel() 
                    if ( SourceWantedLevel > 0 ) then 
                        if ( getElementHealth ( source ) < 90 and getElementHealth ( source ) > 0 )then 
                            triggerServerEvent("POLICESYS:JailThePlayer", localPlayer, attacker) 
                        end 
                    end 
                end 
            end 
        end 
    end) 

-- level = getPlayerWantedLevel ( source ) -- source not defined here 
reward = 3000 
addEvent("POLICESYS:JailThePlayer",true) 
addEventHandler("POLICESYS:JailThePlayer",root, 
function ( attacker ) 
    local x = -4162.3032226563 
    local y = 1697.4566650391 
    local z = 1.0687500238419 
    givePlayerMoney ( attacker, reward ) --Give money to cop 
    setElementPosition ( source, x, y, z, true ) 
    setTimer ( releaseSuspect, 30000, 1,source) 
end) 
  
function releaseSuspect(source) 
if not isElement(source) return end 
local x = 2285.9599609375 
local y = 2423.1164550781 
local z = 10.8203125 
    setElementPosition ( source, x, y, z, true ) 
end 

Link to comment
Thanks! Also! can you showm e how to restrict resource to ACL Groups or Teams, and, how can i turn off /kill :) thanks

for teams

this for Police, already done in your script :roll:

if getTeamName(getPlayerTeam(attacker)) == "Police" then 

for ACL group (Admin)

local accName = getAccountName(getPlayerAccount(attacker)) 
if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then 

to turn off /kill

you need to delete it from the script that enabled it

or use this script:

addEventHandler("onPlayerCommand", root, 
function(cmd)  
     if cmd == "kill" then  
          cancelEvent() 
     end 
end) 

Link to comment
Okay, Also! Sorry! 1 More Thing! How can i make it so a player cant deal damage? :) and also how to take a players gun :P just send me wiki pages if u want :)

use cancelEvent() for prevents any damage:

https://wiki.multitheftauto.com/wiki/OnC ... ayerDamage

if you want take one weapon:

https://wiki.multitheftauto.com/wiki/TakeWeapon

if you want take all weapons:

https://wiki.multitheftauto.com/wiki/TakeAllWeapons

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