[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityTakeDamage]GM/EntityTakeDamage[/url]
Basicly check if the dmginfo:GetAttacker():GetActiveWeapon():GetClass() == SWEP and if attacker got the perk. If you hook the metatable for it, its up to you.
Then just scale the dmginfo with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CTakeDamageInfo/ScaleDamage]CTakeDamageInfo:ScaleDamage[/url] to the point you wanna.
[QUOTE=Tomelyr;47341572][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityTakeDamage]GM/EntityTakeDamage[/url]
Basicly check if the dmginfo:GetAttacker():GetActiveWeapon():GetClass() == SWEP and if attacker got the perk. If you hook the metatable for it, its up to you.
Then just scale the dmginfo with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CTakeDamageInfo/ScaleDamage]CTakeDamageInfo:ScaleDamage[/url] to the point you wanna.[/QUOTE]
thanks :) i got it :o , but umm
how do i make it check if ply uses swep <namehere?> then
[QUOTE=frozendragon;47341633]thanks :) i got it :o , but umm
how do i make it check if ply uses swep <namehere?> then[/QUOTE]
[url]http://wiki.garrysmod.com/page/Player/GetActiveWeapon[/url]
local Player = LocalPlayer();
local Weapon = Player:GetActiveWeapon();
if( Weapon:IsValid() && Weapon:GetClass() == "weapon_bianchi" ) then
CTakeDamageInfo:ScaleDamage(2.5)
end
is this right q.q
[editline]17th March 2015[/editline]
help :/
no. The correct way would be: dmginfo:GetAttacker():GetActiveWeapon():GetClass()
[lua]function GM:EntityTakeDamage( target, dmginfo )[/lua]
take the dmginfo, which is an local variable which contains the CTakeDamageInfo.
from there we can reference the Player who attacked with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CTakeDamageInfo/GetAttacker]CTakeDamageInfo:GetAttacker[/url].
From the Player (dmginfo:GetAttacker()) we can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetActiveWeapon]Player:GetActiveWeapon[/url]to get the Weapon.
From the Weapon (dmginfo:GetAttacker():GetActiveWeapon()) we finally can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetClass]Entity:GetClass[/url] to get the SWEP Class as an String to compare it.
also you should read [url]http://wiki.garrysmod.com/page/Hook_Library_Usage[/url] to ultilize the [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityTakeDamage]GM/EntityTakeDamage[/url] from ealier correctly.
thanks :) i kinda understood what you say but for being 100% sure can you check if i did it righT?
[QUOTE]function GM:EntityTakeDamage( target, dmginfo )
local Player = LocalPlayer();
local Weapon = Player:GetActiveWeapon();
if( Weapon:IsValid() && Weapon:GetClass() == "weapon_bianchi" ) then
if( target:IsPlayer() and dmginfo:IsExplosionDamage() ) then
dmginfo:ScaleDamage( 5.0 )
end
end
end[/QUOTE]
[QUOTE=frozendragon;47341866]thanks :) i kinda understood what you say but for being 100% sure can you check if i did it righT?[/QUOTE]
LocalPlayer does not exist on the server, so no.
Use dmginfo:GetAttacker, make sure it's a player, then do your checks. [url]http://wiki.garrysmod.com/page/Category:CTakeDamageInfo[/url]
[ERROR] addons/darkrpmodification-master/lua/weapons/weapon_bianchi/shared.lua:572: attempt to index global 'GM' (a nil value)
1. unknown - addons/darkrpmodification-master/lua/weapons/weapon_bianchi/shared.lua:572
[editline]17th March 2015[/editline]
[QUOTE=Greetings;47341930]LocalPlayer does not exist on the server, so no.[/QUOTE]
how do i do it right please :/
[editline]17th March 2015[/editline]
[QUOTE=Greetings;47341930]LocalPlayer does not exist on the server, so no.[/QUOTE]
how do i do it right please tell me :( im bad at lua atm just trying to learn would be awesome if u could help
[QUOTE=Tomelyr;47341811]also you should read [url]http://wiki.garrysmod.com/page/Hook_Library_Usage[/url] to ultilize the [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityTakeDamage]GM/EntityTakeDamage[/url] from ealier correctly.[/QUOTE]
[QUOTE=Tomelyr;47341952][/QUOTE]
i tried reading it ...i dont understand anything :/ , could you just fix the code for me please ...
[QUOTE=frozendragon;47341933][ERROR] addons/darkrpmodification-master/lua/weapons/weapon_bianchi/shared.lua:572: attempt to index global 'GM' (a nil value)
1. unknown - addons/darkrpmodification-master/lua/weapons/weapon_bianchi/shared.lua:572
[editline]17th March 2015[/editline]
how do i do it right please :/
[editline]17th March 2015[/editline]
how do i do it right please tell me :( im bad at lua atm just trying to learn would be awesome if u could help[/QUOTE]
Do not use GM:Func outside of the gamemode to do hooking, use hook.Add instead. LocalPlayer is nil on server, so instead use dmginfo:GetAttacker() to set the Player variable. Not going to code it for you, but here's an example:
[lua]
local function HookEntityTakeDamage( victim, dmg )
if( IsValid( dmg:GetAttacker() ) && dmg:GetAttacker():IsPlayer() ) then
//Do code
end
end
hook.Add( "EntityTakeDamage", "hook_name", HookEntityTakeDamage );
[/lua]
[CODE]local function HookEntityTakeDamage( victim, dmg )
if( IsValid( dmg:GetAttacker() ) && dmg:GetAttacker():IsPlayer() ) then
dmg:ScaleDamage( 5.0 )
end
end
hook.Add( "EntityTakeDamage", "hook_name", HookEntityTakeDamage );
[/CODE]
this :)?
[QUOTE=frozendragon;47342082][CODE]local function HookEntityTakeDamage( victim, dmg )
if( IsValid( dmg:GetAttacker() ) && dmg:GetAttacker():IsPlayer() ) then
dmg:ScaleDamage( 5.0 )
end
end
hook.Add( "EntityTakeDamage", "hook_name", HookEntityTakeDamage );
[/CODE]
this :)?[/QUOTE]
While that should work, it's just going to scale the damage anytime a player shoots another player, regardless of which weapon is used. Set a variable to dmg:GetAttacker() after the if statement, this will be the player who is shooting, then do your checks for the weapon.
[QUOTE=Greetings;47342103]While that should work, it's just going to scale the damage anytime a player shoots another player, regardless of which weapon is used. Set a variable to dmg:GetAttacker() after the if statement, this will be the player who is shooting, then do your checks for the weapon.[/QUOTE]
ermm... i put that inside the shared.lua of my SWEP
will that still make all guns do it? , and if im not supposed to place it inside my swep do i put it in autorun :D? , also
if i want to add dmg:SetDamageType(DMG_SHOCK) do i just add it after dmg:ScaleDamage(5.0) or i have to make something else for it? thanks <3
[editline]17th March 2015[/editline]
nvm i figured it out <3 (the DMG_Type part:) , but umm what about the weapon specification.. i didnt kinda understand it :/ could you give me example
[editline]17th March 2015[/editline]
also another question : How to make it so if you shoot someone you slow their movement speed for ex. 80% for 5seconds..?
[QUOTE=frozendragon;47342180]
also another question : How to make it so if you shoot someone you slow their movement speed for ex. 80% for 5seconds..?[/QUOTE]
Tbh try to learn the basics first. i linked the hook usage tutorial 2 times and mentioned it, and you still refuse imo to read it properly.
[QUOTE=Tomelyr;47342281]Tbh try to learn the basics first. i linked the hook usage tutorial 2 times and mentioned it, and you still refuse imo to read it properly.[/QUOTE]
i am reading it.. but i still dont understand how i make it weapon specific q.q
[QUOTE=frozendragon;47342291]i am reading it.. but i still dont understand how i make it weapon specific q.q[/QUOTE]
[url]http://wiki.garrysmod.com/page/Player/GetActiveWeapon[/url]
[QUOTE=SkitZz;47342348][url]http://wiki.garrysmod.com/page/Player/GetActiveWeapon[/url][/QUOTE]
man i know that. but im not sure where to put it in my code
[code]local function HookEntityTakeDamage( victim, dmg )
if( IsValid( dmg:GetAttacker() ) && dmg:GetAttacker():IsPlayer() ) then
dmg:ScaleDamage( 5.0 )
end
end
hook.Add( "EntityTakeDamage", "hook_name", HookEntityTakeDamage );[/code]
[QUOTE=frozendragon;47342368]man i know that. but im not sure where to put it in my code
[code]local function HookEntityTakeDamage( victim, dmg )
if( IsValid( dmg:GetAttacker() ) && dmg:GetAttacker():IsPlayer() ) then
dmg:ScaleDamage( 5.0 )
end
end
hook.Add( "EntityTakeDamage", "hook_name", HookEntityTakeDamage );[/code][/QUOTE]
This should work for you. If not, then i don't know:
[CODE]
local function HookEntityTakeDamage( victim, dmg )
if( IsValid( dmg:GetAttacker() ) && dmg:GetAttacker():IsPlayer() && dmg:GetAttacker():GetActiveWeapon():GetClass() == "INSERT WEAPON NAME HERE") then
dmg:ScaleDamage( 5.0 )
end
end
hook.Add( "EntityTakeDamage", "hook_name", HookEntityTakeDamage );
[/CODE]
[QUOTE=SkitZz;47342411]This should work for you. If not, then i don't know:
[CODE]
local function HookEntityTakeDamage( victim, dmg )
if( IsValid( dmg:GetAttacker() ) && dmg:GetAttacker():IsPlayer() && dmg:GetAttacker():GetActiveWeapon():GetClass() == "weapon_gw_binachi") then
dmg:ScaleDamage( 5.0 )
end
end
[/CODE][/QUOTE]
il try it out :) thanks alot :3
[QUOTE=frozendragon;47342416]il try it out :) thanks alot :3[/QUOTE]
Don't forget to add the hook.
[code]
hook.Add( "EntityTakeDamage", "hook_name", HookEntityTakeDamage )
[/code]
I forgot that.
Edit:
Just tested it, and it seems to work how you wanted it.
[QUOTE=SkitZz;47342423]Don't forget to add the hook.
[code]
hook.Add( "EntityTakeDamage", "hook_name", HookEntityTakeDamage )
[/code]
I forgot that.
Edit:
Just tested it, and it seems to work how you wanted it.[/QUOTE]
thanks =) , also ummmm i know you helped me already but do you have any idea how to make it slow player 80% for 5sec o.o
[QUOTE=frozendragon;47342513]thanks =) , also ummmm i know you helped me already but do you have any idea how to make it slow player 80% for 5sec o.o[/QUOTE]
Well, this might not be the best way, but it should work:
1. Put the victims current run/walkspeed into a variable
2. Set their run/walk speed to a low number
3. Use [url]http://wiki.garrysmod.com/page/timer/Simple[/url] to make a delay of 5 seconds and then set their Walk speed / run speed to the original.
4. Destory the timer.
It will overlap if you shoot them more than once, but meh.
Also, this is probably a stupid way to do it, but i tried. You could hope that someone with a lot more knowledge than me would help you. Good luck :P
[QUOTE=SkitZz;47342543]Well, this might not be the best way, but it should work:
1. Put the victims current run/walkspeed into a variable
2. Set their run/walk speed to a low number
3. Use [url]http://wiki.garrysmod.com/page/timer/Simple[/url] to make a delay of 5 seconds and then set their Walk speed / run speed to the original.
4. Destory the timer.
It will overlap if you shoot them more than once, but meh.
Also, this is probably a stupid way to do it, but i tried. You could hope that someone with a lot more knowledge than me would help you. Good luck :P[/QUOTE]
thanks for the help i appreciate it alot =)
[QUOTE=frozendragon;47342626]thanks for the help i appreciate it alot =)[/QUOTE]
Something like this would probably work if you didn't figure it out yet:
[code]
local function HookEntityTakeDamage( victim, dmg )
if( IsValid( dmg:GetAttacker() ) && dmg:GetAttacker():IsPlayer() && dmg:GetAttacker():GetActiveWeapon():GetClass() == "INSERT WEAPON NAME HERE") then
OriginalSpeed = victim:GetWalkSpeed()
dmg:ScaleDamage( 5.0 )
victim:SetWalkSpeed(100)
timer.Create( "Slow", 5, 1, function() victim:SetWalkSpeed(OriginalSpeed) timer.Destroy("Slow") end )
end
end
hook.Add( "EntityTakeDamage", "hook_name", HookEntityTakeDamage )
[/code]
But as i said before, they will overlap if you shoot more than once.
[QUOTE=SkitZz;47342778]Something like this would probably work if you didn't figure it out yet:
[code]
local function HookEntityTakeDamage( victim, dmg )
if( IsValid( dmg:GetAttacker() ) && dmg:GetAttacker():IsPlayer() && dmg:GetAttacker():GetActiveWeapon():GetClass() == "INSERT WEAPON NAME HERE") then
OriginalSpeed = victim:GetWalkSpeed()
dmg:ScaleDamage( 5.0 )
victim:SetWalkSpeed(100)
timer.Create( "Slow", 5, 1, function() victim:SetWalkSpeed(OriginalSpeed) timer.Destroy("Slow") end )
end
end
hook.Add( "EntityTakeDamage", "hook_name", HookEntityTakeDamage )
[/code]
But as i said before, they will overlap if you shoot more than once.[/QUOTE]
GetWalkSpeed() * 0.80
If you're only going to use 1 rep for the timer, why not just use timer.Simple?
[QUOTE=Greetings;47342961]GetWalkSpeed() * 0.80
If you're only going to use 1 rep for the timer, why not just use timer.Simple?[/QUOTE]
As i said before, I'm new to lua and i was just trying to help him.
[QUOTE=SkitZz;47343642]As i said before, I'm new to lua and i was just trying to help him.[/QUOTE]
Doesn't mean you have to spoonfeed, people don't learn if you do that.
[QUOTE=LUModder;47344282]Doesn't mean you have to spoonfeed, people don't learn if you do that.[/QUOTE]
Oh, give me a break. It's such a little thing.
Sorry, you need to Log In to post a reply to this thread.