[DarkRP] Killing a player who isnt wearing the right suit

Hey guys! I own a Black Mesa Roleplay server with an edited version of DarkRP. It isnt a complete rip off of DarkRP, it has alot of edits but i just can’t seem to get one thing right. So i have this code i made in my DarkRP Modules, and here it is:

function XenDie()

local entities = ents.FindInBox( Vector(-3951.572998, -11466.885742, 347.655273), Vector(-5822.107422, -5733.926758, -965.334229) );
if ply:GetModel() ~= “models/player/sgg/hev_helmet.mdl” then
for k, v in pairs(entities) do
if ( IsValid(v) and v:IsPlayer() and v:GetName() == ply:GetName() and v:Alive() ) then

Entity:SetHealth( 0 )



Now, the point is to kill any player that isnt wearing the correct “Suit” (playermodel). This does not seem to work, anyone got any ideas? Thanks!

You’re looping through ‘entities’, which are vectors, then looking if the value from it is a player, then checking the entity’s name is the same as ply’s name, but ply doesn’t seem to be defined anywhere

Then you want to set Entity’s health to zero, another variable which appears to have been pulled out of thin air

Like, it seems you know in your head what to do but have made a lot of mistakes when writing it out - unless this isn’t the full code

This is the full code, i recently started programming and i was given a few tips from a guy who is now offline, i understand what the code is doing, but im not great at GLUA coding. I just need some help on this code

[editline]20th October 2015[/editline]

Got any ideas on how to fix the code? Sorry if i seem newby to this.

You should provide the full code. Its hard to tell what is wrong when only looking at a small section. If it is a large file I would suggest you post it to pastebin.

You are checking for the players model in the wrong location(outside the loop). You also need to change the ‘ply’ variable to be the variable ‘v’ because as far as I can see the ply variable has not been created. Also the ‘v:GetName() == ply:GetName()’ really isn’t needed unless your trying to make it only kill players with a certain name.

I’m pretty sure ents.FindInBox uses withinAABounds to determine if it’s true or not. It’s probably better to run that last since it’s the most intensive part.

Also, never set the players health to 0.

local function XenDie()
    for k,v in pairs(player.GetAll()) do
        --Quickly parse through all non-valid players.
        if IsValid(v) and v:Alive() and v:GetModel() != "models/player/sgg/hev_helmet.mdl" then
            --We're going to run this last since WithinAABox is kind of intensive.
            if v:GetPos():WithinAABox(Vector(-3951, -5733, 347), Vector(-5822, -11466, -965)) then
                --Never set the players health to 0. It just makes them invincible. Hurting them properly removes their health.

It’s still not clear where you’re putting it though. Which function/event are you trying to hook into?

edit: I just realized you don’t even need to parse all entities. Woops.

You also need to put highest vector vs lowest vector when doing ents.FindInBox or WithinAABox. I don’t know why, but it bugs out if the corner doesn’t make sense.

Thank you Deathward :slight_smile:

Where are you trying to hook it, out of curiosity? That could also be attributing to why it won’t work.

By hooking it what do you mean exactly? If you mean where am i placing this? I am placing it in my dark rp modules folder.

[editline]21st October 2015[/editline]

It did not seem to work, in GLUA if im right, instead of !=, isnt it ~=? for the not equal to operator?

I uh, don’t think it works that way.

You probably want to tie this to an actual event, or at least have it run on a timer. It doesn’t just “work” all the time, something has to call it and tell it when to run.

!= is the same as ~=.

Scratch that, that didnt even work, you said something about reseting the killbox?

[editline]21st October 2015[/editline]

Okay, ill try something, thanks

[editline]21st October 2015[/editline]

I’m not sure what to tie it too, im sorry im very new to Glua

[editline]21st October 2015[/editline]

Figured it out

[editline]21st October 2015[/editline]

Thank you :slight_smile: