Jump to content

Arrests.


TheIceman1

Recommended Posts

Why this dont show me my arrests on scoreboard?

exports [ 'scoreboard' ]:addScoreboardColumn ( 'Arrests' ) 
  
addEventHandler("onPlayeDamage",root, 
function (attacker, weapon) 
local weap = getWeaponNameFromID(3) 
local skin = getElementModel ( attacker ) 
local team = getTeamFromName( getPlayerTeam ( attacker ) ) 
local wl = getPlayerWantedLevel ( source ) 
if (skin == 280 ) and ( team == "Police" ) and ( wl > 0 ) and ( weap == 3 ) then 
    addPlayerArrests(attacker) 
end 
end) 
  
  
function addPlayerArrests(attacker) 
    local account = getPlayerAccount(attacker) 
    if isGuestAccount(account) then return end 
    local arrests = getAccountData(account,"Arrests") 
    if not arrests then setAccountData(account,"Arrests",0) end 
    setAccountData(account,"Arrests",tonumber(arrests)+1) 
end 
  
  
addEventHandler("onPlayerLogin",root, 
function () 
    local account = getPlayerAccount(source) 
    if isGuestAccount(account) then return end 
    local arrests = getAccountData(account,"Arrests") 
    if arrests then 
        setElementData(source,"Arrests",tostring(arrests)) 
    else 
        setElementData(source,"Arrests",0)     
  
end 
end) 

Link to comment

try this:

exports [ 'scoreboard' ]:addScoreboardColumn ( 'Arrests' ) 
  
addEventHandler("onPlayeDamage",root,function (attacker, weapon) 
     -- local weap = getWeaponNameFromId(weapon) --this would return the name not the id 
     local skin = getElementModel ( attacker ) 
     local team = getTeamFromName( getPlayerTeam ( attacker ) ) 
     local wl = getPlayerWantedLevel ( source ) 
     if (skin == 280 ) and ( team == "Police" ) and ( wl > 0 ) and ( weapon == 3 ) then 
          addPlayerArrests(attacker) 
     end 
end) 
  
function addPlayerArrests(attacker) 
     local account = getPlayerAccount(attacker) 
     if isGuestAccount(account) then return end 
     local arrests = getAccountData(account,"Arrests") or 0 
     setAccountData(account,"Arrests",tonumber(arrests)+1) 
     setElementData(attacker,"Arrests",tonumber(arrests)+1) 
end 
  
addEventHandler("onPlayerLogin",root,function(_,account) --get the players account 
     if isGuestAccount(account) then return end 
     local arrests = getAccountData(account,"Arrests") or 0 --if there's no arrests data then return 0 
     setElementData(source,"Arrests",tostring(arrests)) 
end) 

EDITTED!!!

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