IsArrest (arresting a player for carrying out an action)
8 replies, posted
I'm trying to use isArrest, for a test script so i can help a friend out.
so far we have as follows.
[CODE]hook.Add("PlayerDeath", "Jailing bad Pope", function(victim, weapon, attacker)
if weapon:GetClass() == "cst_ladyslap" and killer:Team() == TEAM_POPE and attacker:IsValid() then
attacker:PrintMessage( HUD_PRINTTALK, "Naughty, Naughty!" )
attacker:isArrested() = true
end
end)
[/CODE]
to be honest were just horsing around with Lua but we can't get it to work.
the only thing that works is, the Hud display message after I kill him.
but i don't got to jail for dong so.
We can't figure out how to use :isArrested properly.
First of all your syntax is wrong.
Second, isArrested is not what you're looking for. That does not arrest them. It tells you whether or not they are arrested.
Instead, use attacker:arrest("Naughty, naughty!")
[QUOTE]First of all your syntax is wrong.[/QUOTE] mind shedding some light? I'm not seeing any Lua Errors.
[code]attacker:isArrested() = true[/code]
That's your problem line. If it's not causing any errors then your if statement isn't running.
You're calling a function: isArrested, hence the parentheses. It is trying to give you output, not take input, which is what putting "= true" afterward is trying to do.
I couldn't get it to work. I corrected and replaced it with [CODE]attacker:arrest("naughty, naughty")[/CODE]
but to no success. still no errors though. :P
In line 2 you are referencing 'killer' when it should be 'attacker'
I corrected that, and this still didn't work
[editline]6th April 2014[/editline]
I tried to build off of this, and i can't get it to work this way either.
[code]function bitch(victim, weapon, attacker)
if weapon:GetClass() == "cstm_snip_m98" and attacker:Team() == TEAM_CLOWNTHUG and attacker:IsValid() then
attacker:addMoney(50)
attacker:arrest("naughty, naughty!")
end
end
hook.Add("PlayerDeath", "Last stand for riches", bitch(victim, weapon, attacker))[/code]
It should be like this.
[lua]function bitch(victim, weapon, attacker)
if weapon:GetClass() == "cstm_snip_m98" and attacker:Team() == TEAM_CLOWNTHUG and attacker:IsValid() then
attacker:addMoney(50)
attacker:arrest("naughty, naughty!")
end
end
hook.Add("PlayerDeath", "Last stand for riches", bitch)[/lua]
You shouldn't name your functions and hooks stupid stuff, though. It makes people wonder what they're looking at. People should be able to tell what they're looking at at a first glance.
[lua]hook.Add("PlayerDeath", "LastStand", function(victim, weapon, attacker)
if weapon:GetClass() == "cstm_snip_m98" and attacker:Team() == TEAM_CLOWNTHUG and attacker:IsValid() then
attacker:addMoney(50)
attacker:arrest("naughty, naughty!")
end
end)[/lua]
I used a nameless function for the hook, but you can use a named function if you wanted. Just don't name it something dumb like "bitch".
[QUOTE=BayLife;44473973]It should be like this.
[lua]function bitch(victim, weapon, attacker)
if weapon:GetClass() == "cstm_snip_m98" and attacker:Team() == TEAM_CLOWNTHUG and attacker:IsValid() then
attacker:addMoney(50)
attacker:arrest("naughty, naughty!")
end
end
hook.Add("PlayerDeath", "Last stand for riches", bitch)[/lua]
You shouldn't name your functions and hooks stupid stuff, though. It makes people wonder what they're looking at. People should be able to tell what they're looking at at a first glance.
[lua]hook.Add("PlayerDeath", "LastStand", function(victim, weapon, attacker)
if weapon:GetClass() == "cstm_snip_m98" and attacker:Team() == TEAM_CLOWNTHUG and attacker:IsValid() then
attacker:addMoney(50)
attacker:arrest("naughty, naughty!")
end
end)[/lua]
I used a nameless function for the hook, but you can use a named function if you wanted. Just don't name it something dumb like "bitch".[/QUOTE]
I tried this solution in two different areas, both [code]lua/autorun/server/[/code]" and [code]/addons/darkrpmodification/lua/darkrp_modules/testhook/[/code] as either [QUOTE]sv_testhook.lua[/QUOTE] and as [QUOTE]testhook.lua[/QUOTE] and it still does nothing.
[editline]7th April 2014[/editline]
What I want to accomplish is that it checks the active weapon of the killer, and if it finds the killer was using [code]"cstm_snip_m98"[/code], then the killer gets payed money
and then goes directly to jail. For the life of me, I can't get this to work. I've tried all of the above.
Sorry, you need to Log In to post a reply to this thread.