Alright, so thanks to you guys I've made it this far, but now I'm having trouble reseting the health of the player using the "drug" heh. Heres my code:
[code]
local function DrawBlur()
DrawMotionBlur( 0.1, 0.79, 0.035);
DrawSharpen(1.991, 5)
end
local function HealthReset()
self.Owner:SetHealth(100)
end
function SWEP:PrimaryAttack()
self.Owner:SetHealth(200);
self:EmitSound (ShootSound);
self:TakePrimaryAmmo(1);
hook.Add( "RenderScreenspaceEffects", "MMotionBlur", DrawBlur )
if SERVER then
self:Remove()
end
timer.Simple( 30, function()
hook.Remove( "RenderScreenspaceEffects", "MMotionBlur", HealthReset )
end)
end
[/code]
When the timer completes, it doesn't reset the players health. Any help?
You need to reset health or remove screen effect?
Both, I got the screen effect to go away, now I just need to get the players health to reset.[QUOTE=lua_error;42334690]You need to reset health or remove screen effect?[/QUOTE]
SetHealth is run serverside.
You might also want to record the player's health before using, since someone could use this at perhaps 1 hp and regain 100 at the end.
You don't need 3rd argument for hook.Remove.
That's the point, to reset your health, and give you a 30 buff.. [QUOTE=Humility;42334850]SetHealth is run serverside.
You might also want to record the player's health before using, since someone could use this at perhaps 1 hp and regain 100 at the end.[/QUOTE]
[editline]28th September 2013[/editline]
Alright, but when I call the HealthReset function, within the timer function, it just errors out. I honestly have no clue what I'm doing here :/ [QUOTE=Robotboy655;42334857]You don't need 3rd argument for hook.Remove.[/QUOTE]
Maybe this will help you
[LUA]
if SERVER then
end
[/LUA]
[LUA]
if CLIENT then return end
[/LUA]
First of all, if it errors, post the code that errors AND the error itself. And you don't need to create separate function to just call another function.
This is where I need help with:
[code]
local function HealthReset()
if SERVER then
ply:SetHealth(100)
end
end
function SWEP:PrimaryAttack()
self.Owner:SetHealth(200);
self:EmitSound (ShootSound);
self:TakePrimaryAmmo(1);
hook.Add( "RenderScreenspaceEffects", "MMotionBlur", DrawBlur )
if SERVER then
self:Remove()
end
timer.Simple( 30, function()
hook.Remove( "RenderScreenspaceEffects", "MMotionBlur")
HealthReset()
end)
end
[/code]
And it doesn't error out, it just doesn't set your health back to 100.
[QUOTE=Robotboy655;42335901]First of all, if it errors, post the code that errors AND the error itself. And you don't need to create separate function to just call another function.[/QUOTE]
Alright, will try that now, I'll get back to you if it errors and what the error is. [QUOTE=Robotboy655;42336088][code]
timer.Simple( 30, function()
hook.Remove( "RenderScreenspaceEffects", "MMotionBlur")
self.Owner:SetHealth(100);
end)
[/code][/QUOTE]
[editline]28th September 2013[/editline]
Alright, that didn't work.
Console spat this out:
[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_pcp/shared.lua:66: Trie
d to use a NULL entity!
1. __index - [C]:-1
2. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_pcp/shared.lua:
66
and Like 66 is the self.Owner:SetHealth(100);
[QUOTE=Robotboy655;42336088][code]
timer.Simple( 30, function()
hook.Remove( "RenderScreenspaceEffects", "MMotionBlur")
self.Owner:SetHealth(100);
end)
[/code][/QUOTE]
Add [code]if IsValid( self ) then return end[/code] before the set health. And make sure you don't die and make sure the weapon doesn't disappear.
Sorry, you need to Log In to post a reply to this thread.