Jump to content

Trying to set wanted level?


FWCentral

Recommended Posts

Posted (edited)

Ok Im making a wanted system that shows up stars and it works fine,

i made this command:

(Client)

  
function wantme() 
local wlvl = getElementData(getLocalPlayer(),"Wanted-Level") 
setElementData(getLocalPlayer(), "Wanted-Level", wlvl+1) 
end 
addCommandHandler("wantme", wantme) 
  

This works fine and it makes a star add to the GUI.

I want to make it when the player was damaged the attacker will get a star unless the attacker is a certain skin:

(Client)

  
function damagestars ( attacker, weapon, bodypart, loss ) 
if (getElementModel(attacker) == 280 or 284) then 
else 
local wlevel = getElementData(attacker, "Wanted-Level") 
setElementData(attacker, "Wanted-Level", wlevel+1) 
end  
end 
addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), damagestars ) 
  

EDIT:

Thought this might help more to why its not working, Im using onClientElementDataChange to trigger the star function.

Edited by Guest
3677124c9d4d768da64a55d5bebf578e.png
Posted (edited)

I would use onPlayerDamage server side instead.

function damagestars ( attacker, weapon, bodypart, loss ) 
local model = getElementModel(attacker) 
if (model ~= 280 and model ~= 284) then 
    local wlevel = tonumber(getElementData(attacker, "Wanted-Level")) 
    setElementData(attacker, "Wanted-Level", wlevel+1) 
    end 
end 
addEventHandler ( "onPlayerDamage", root, damagestars ) 

Edited by Guest

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I've edited my post, try that (is server side).

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

try this

Should work

(Client) 
  
function wantme() 
local wlvl = getElementData(getLocalPlayer(),"Wanted-Level") 
setElementData(getLocalPlayer(), "Wanted-Level", wlvl+1) 
end 
addCommandHandler("wantme", wantme) 
  
  
  
server 
  
addEventHandler("onPlayerDamage", root, 
    function(attacker,weapon,bodypart,loss) 
        local Skin = getPedSkin ( attacker ) 
                local wlevel = getElementData(attacker, "Wanted-Level") 
        if not attacker or attacker == source then return end 
        if Skin == 280 or 284 then return end 
                setElementData(attacker, "Wanted-Level", wlevel+1) 
        setPlayerWantedLevel(attacker, getPlayerWantedLevel(attacker) + 1) 
    end 
) 

krsofa999.gif

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