Jump to content

setWeaponProperty fix


iPanda

Recommended Posts

Hey, guys. My next problem - does not work function setWeaponProperty. I wanted to give the properties of the rifle "Country Rifle", but the function does not work. Help solve the problem.

server.lua file

local M1Garand = function() 
    setWeaponProperty(33, "poor", "weapon_range", 180) 
    setWeaponProperty(33, "poor", "target_range", 180) 
    setWeaponProperty(33, "poor", "accuracy", 5) 
    setWeaponProperty(33, "poor", "damage", 50) 
    setWeaponProperty(33, "poor", "maximum_clip_ammo", -- s8) -->
    setWeaponProperty(33, "poor", "move_speed", 90) 
    setWeaponProperty(33, "poor", "flags", 0x000010) 
    setWeaponProperty(33, "poor", "flags", 0x008000) 
end 
addEventHandler("onResourceStart", getRootElement(), M1Garand ) 

ps

I am using the server-side + prescribed minimum version client meta.xml

Link to comment

maybe the skill level of your player is not "poor". it can be "pro", "std" and "poor"

  
    local M1Garand = function() 
        local skills = {"pro", "std", "poor"}; 
        for _, skill in ipairs(skills) do  
           setWeaponProperty(33, skill, "weapon_range", 180) 
           setWeaponProperty(33, skill, "target_range", 180) 
           setWeaponProperty(33, skill, "accuracy", 5) 
           setWeaponProperty(33, skill, "damage", 50) 
           setWeaponProperty(33, skill, "maximum_clip_ammo", -- s8) -->
           setWeaponProperty(33, skill, "move_speed", 90) 
           setWeaponProperty(33, skill, "flags", 0x000010) 
           setWeaponProperty(33, skill, "flags", 0x008000) 
       end  
    end 
    addEventHandler("onResourceStart", getRootElement(), M1Garand ) 
  

Link to comment

keep in mind, that

addEventHandler("onResourceStart", getRootElement(), M1Garand ) 

will trigger the function EVERY single time ANY resource starts. You'd better do it like that:

addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), M1Garand ) 

Then it will be triggered only when the original resource starts.

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