(DarkRP) Code that deletes an entity upon a player changing there job?
1 replies, posted
[CODE]hook.Add("OnPlayerChangedTeam", "RemovingThosePrinters", function(ply, oldTeam)
if oldTeam == TEAM_RADIO then
for k, v in pairs(ents.FindByClass("sr_radio")) do
if v:Getowning_ent() == ply then
v:Remove()
end
end
end
end)[/CODE]
I ususally use this code for deleting an entity upon job change.... But how would I change this so it deleted the entity no matter what job they where?
For example I have an entity that 90% of jobs are allowed, so how would I make this delete all of the entity's listed no matter what job they where.
p.s. Sorry for my bad explaining, I hope you understood it.
[lua]
hook.Add("OnPlayerChangedTeam", "RemovingThosePrinters", function(ply, oldTeam)
for k, v in pairs(ents.FindByClass("sr_radio")) do
if v:Getowning_ent() == ply then
v:Remove()
end
end
end)
[/lua]
Should work, you just needed to remove the oldTeam stuff.
Sorry, you need to Log In to post a reply to this thread.