My SWEP has it so if you pick up a "PSI Hypo", it goes to a seperate ammo counter alongside "Psychic Points". When you use your attack, the psyshic points are depleted. But then you can click right-click to use a PSI-Hypo and regain your psychic points using GiveAmmo.
It does work in multiplayer, however it always gives a lua error that reads the following:
[CODE]
[ERROR] addons/psionicpowers/lua/weapons/psi_staticburst/shared.lua:386: attempt to call method 'GiveAmmo' (a nil value)
1. unknown - addons/psionicpowers/lua/weapons/psi_staticburst/shared.lua:386
[/CODE]
im not sure if running GiveAmmo in a SWEP is efficent after this. any alternatives i should know about?
Maybe you are trying to add it to the SWEP, not the player. Post your code.
Most likely your code is ran on the client too.
[QUOTE=RaKo;52258155]Maybe you are trying to add it to the SWEP, not the player. Post your code.[/QUOTE]
[CODE]
local wep = self.Weapon
local ply = self.Owner
if self.Owner:GetAmmoCount( self.Weapon:GetSecondaryAmmoType() ) <= 0 then
ply:PrintMessage(HUD_PRINTTALK, "You are out of PSI Hypos")
return true end
if self.Owner:GetAmmoCount( "psi_psychpoints" ) >= 250 then
ply:PrintMessage(HUD_PRINTTALK, "Your Psionic energy is already at it's maximum")
return true end
ply:PrintMessage(HUD_PRINTTALK, "PSI Hypo used")
ply:GiveAmmo( 50, "psi_psychpoints", true )
ply:EmitSound("player/suit_sprint.wav")
wep:TakeSecondaryAmmo(self.Secondary.TakeAmmo)
end
[/CODE]
GiveAmmo is serverside only.
[QUOTE=code_gs;52259540]GiveAmmo is serverside only.[/QUOTE]
thank you. I fixed it by putting "if SERVER then" before all the code. It also fixed another problem where the printmessages were repeated.
Sorry, you need to Log In to post a reply to this thread.