• Getattacker problem
    15 replies, posted
im trying to make so if a player is swat and he gets shot at the player shooting sould get wanted, im kinda stuck in making the player wanted. function PlayerWante( ent, attacker, dmginfo, ply ) if ( ent:IsPlayer() ) then if ply == TEAM_SWAT then attacker:GetAttacker ply.DarkRPVars.wanted end end end
[QUOTE=Gastav3;38281254] function PlayerWante( [/QUOTE] You forgot the "d"
i dont think i need a d its just a function name i came up with
[QUOTE=Gastav3;38281377]i dont think i need a d its just a function name i came up with[/QUOTE] Post the rest of your code.
function PlayerWante( ent, attacker, dmginfo, ply ) if ( ply:IsPlayer() ) then if ply == TEAM_SWAT then dmginfo:GetAttacker() then ply:RunConsoleCommand("say /wanted" .. tostring(dmginfo:GetAttacker()).. end end end Ok this isent working either help please
what do you mean it isnt working? is there errors? is it simply not doing anything? not hard to including a little information as to whats actually happening.
If that is all the code you have, then of course it won't work.
also what is this? [lua]if ply == TEAM_SWAT then attacker:GetAttacker ply.DarkRPVars.wanted[/lua] thats almost as bad as [quote][lua]PlayerWante( ent attacker, dmginfo, ply )[/lua][/quote] [editline]2nd November 2012[/editline] oh just a heads up thats probably your problem. seeing as you havent indicated in anyway what you are trying to achieve by this i cant help
Op, try using this hook [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexedfa.html"]here[/URL]. As an example, I wrote you an admin plugin. Example: [CODE] chat.AddText(Color(255,255,255), "Sasha's L33t Admin plugin load3d") function ouch(target, inflictor, attacker, amount) if (amount != nil || 0 && target != nil && attacker != nil && inflictor != nil) then if (target:IsPlayer() and attacker:IsPlayer()) then if (attacker:IsSuperAdmin() || attacker:IsAdmin()) then chat.AddText(Color(255,255,255), "ADMIN ABOOSE ADMIN ABOOSE ".. attacker:GetName() .. " JUST ADMIN ABOOSED ".. target:GetName() .." WITH A ".. inflictor:GetName() .." AND INFLICTED "..amount.." DAMAGE ON HIM! ANTI ADMIN ABOOSE MOD ACTIVATED!") attacker:Ignite(9999, 200) elseif (target:IsSuperAdmin() || target:IsAdmin()) then chat.AddText(Color(255,255,255), "OHH SHHIIIIIIIT, ".. attacker:GetName() .. " JUST SHOT AN ADMIN NAMED ".. target:GetName() .." WITH A ".. inflictor:GetName() .." AND INFLICTED "..amount.." DAMAGE ON HIM! AUTO PLAYER RDM PUNISHMENT ACTIVATED!") attacker:Ignite(9999, 200) else chat.AddText(Color(255,255,255), "OUCH! SOME BITCH NAMED ".. attacker:GetName() .. " JUST SHOT ".. target:GetName() .." WITH A ".. inflictor:GetName() .." AND INFLICTED "..amount.." DAMAGE ON HIM!") end end end end hook.Add("EntityTakeDamage", "da fuq u shootin at niqquh", ouch) [/CODE] Run that on your server, and it will take care of all admin abuse, auto player punishment, and player damage logging.
niqquh please.. good work on the example :P
function ouchi(target, inflictor, attacker, amount) if (amount != nil || 0 && target != nil && attacker != nil) then if (target:IsPlayer() and if target:Team() == TEAM_POLICE or target:Team() == TEAM_CHIEF then if (attacker:IsPlayer() || attacker:IsPlayer()) then hook.Call("PlayerWanted") end end end end end hook.Add("EntityTakeDamage", "make wanted", ouchi) Ok, I think i've got some part right but making the attacker wanted is the problem at least i think
[quote][lua]if (target:IsPlayer() and if target:Team() == TEAM_POLICE or target:Team() == TEAM_CHIEF then[/lua][/quote] seriously if you dont know how to code learn before coding. thats not even the right syntax. you have an if where you dont need it and an unmatched parenthesis. [lua]if (target:IsPlayer() and (target:Team() == TEAM_POLICE or target:Team() == TEAM_CHIEF)) then[/lua]
As much as we want to help, we're not going to spoonfeed you the answer. You clearly don't know enough about lua scripting to understand what we are telling you. Personally, I don't like this feature idea anyway. It sounds kinda stupid.
[QUOTE=SashaWolf;38291601]As much as we want to help, we're not going to spoonfeed you the answer. You clearly don't know enough about lua scripting to understand what we are telling you. Personally, I don't like this feature idea anyway. It sounds kinda stupid.[/QUOTE] It seems just like the system GangWarsRP uses.. Go get your own ideas.
Don't forget, Garry changed how dmginfo on certain hooks works. This works: [code]function GM:EntityTakeDamage(ent, dmginfo) local inflictor = dmginfo:GetInflictor() local attacker = dmginfo:GetAttacker() local damage = dmginfo:GetDamage() end[/code] This doesn't (the old method): [code] function GM:EntityTakeDamage(ent, inflictor, attacker, damage, dmginfo)[/code]
[QUOTE=Dark Slayre;38293402]Don't forget, Garry changed how dmginfo on certain hooks works. This works: [code]function GM:EntityTakeDamage(ent, dmginfo) local inflictor = dmginfo:GetInflictor() local attacker = dmginfo:GetAttacker() local damage = dmginfo:GetDamage() end[/code] This doesn't (the old method): [code] function GM:EntityTakeDamage(ent, inflictor, attacker, damage, dmginfo)[/code][/QUOTE] Ohh, didn't know that. My bad OP.
Sorry, you need to Log In to post a reply to this thread.