nic062 Posted September 4, 2013 Share Posted September 4, 2013 Hello Everybody, I think there is a problem with the function getWeaponAmmo when it's used with a custom weapon created with createWeapon. It seems that the function always return 0. Here is an example : local theWeapon addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() theWeapon = createWeapon("m4", 1, 1, 3) setWeaponOwner(theWeapon, localPlayer) setWeaponClipAmmo(theWeapon, 10) setWeaponAmmo(theWeapon, 90) end) function handleCustomWeapon() if getKeyState("mouse1") then setWeaponState(theWeapon, "firing") else setWeaponState(theWeapon, "ready") end dxDrawText("getWeaponClipAmmo = "..getWeaponClipAmmo(theWeapon).."\ngetWeaponAmmo = "..getWeaponAmmo(theWeapon), 100, 200) setControlState("fire", false) end addEventHandler("onClientPreRender", getRootElement(), handleCustomWeapon) Can you confirm me or explain why my script doesn't work. Cordialy. ps : I use Link to comment
nic062 Posted September 7, 2013 Author Share Posted September 7, 2013 anyone can tell me ? Link to comment
WASSIm. Posted September 7, 2013 Share Posted September 7, 2013 addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() theWeapon = createWeapon("m4", 1, 1, 3) setWeaponOwner(theWeapon, localPlayer) setWeaponClipAmmo(theWeapon, 10) setWeaponAmmo(theWeapon, 90) end) function handleCustomWeapon() if getKeyState("mouse1") then setWeaponState(theWeapon, "firing") else setWeaponState(theWeapon, "ready") end dxDrawText("getWeaponClipAmmo = "..getWeaponClipAmmo(theWeapon).." \n getWeaponAmmo = "..getWeaponAmmo(theWeapon), 100, 200) setControlState("fire", false) end addEventHandler("onClientPreRender", getRootElement(), handleCustomWeapon) Link to comment
GamerDeMTA Posted September 7, 2013 Share Posted September 7, 2013 setWeaponAmmo is server side........ Link to comment
TAPL Posted September 7, 2013 Share Posted September 7, 2013 setWeaponAmmo is server side........ Server side for player weapon, but client side for custom weapon. Link to comment
nic062 Posted September 7, 2013 Author Share Posted September 7, 2013 @WASSIm the space after the \n is not important but thank's for help @GamerDeMTA Yes client side for custom weapon, thank's too. I think is a real bug, I will report this bug this week on the bugtracker 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