• Restrict DarkRP jobs from pickingup/using entities
    11 replies, posted
local function up( ply, ent ) return ply:IsTeam( "TEAM_) end hook.Add( "AllowPlayerPickup", "some_unique_name", up ) Im not sure if this code above can be useful but ive been thinking of ways to work it for entities because a addon we are using uses spell books players must pick up with e before they can learn that spell but we need to stop teachers from spawning it and using it for themself any help would be much appreciated
I think this would stop the staff team from picking up things: hook.Add( "AllowPlayerPickup", "NoJobPickup", function( ply ) return ply:Team() ~= TEAM_STAFF end ) I don't know anything about DarkRP but it seems this is how you check jobs
to add multiple teams would it just be? hook.Add( "AllowPlayerPickup", "NoJobPickup", function( ply ) return ply:Team() ~= TEAM_STAFF, TEAM_STAFF2, TEAM_STAFF3 end )
For multiple teams this might work: local blocked = { [ TEAM_STAFF ] = true, [ TEAM_STAFF2 ] = true, [ TEAM_STAFF3 ] = true } hook.Add( "AllowPlayerPickup", "NoJobPickup", function( ply ) return not blocked[ ply:Team() ] end )
so this will stop anyone in that job from picking up any entites even though it requires the user to press e on it?
sorry, I really don't know what i'm doing. maybe if the table is in the hook it'll work: hook.Add( "AllowPlayerPickup", "NoJobPickup", function( ply ) local blocked = { [ TEAM_FLITWICK ] = true, [ TEAM_LUPIN ] = true, [ TEAM_SNAPE ] = true, [ TEAM_SUBSTITUTE ] = true } return not blocked[ ply:Team() ] end ) If this doesn't work then it's probably better to wait for someone who knows DarkRP
You could get the players job and do a list/table with it like ply:getDarkRPVar("job") == "whatever" and the jobs listed are not allowed to pick up the books. I would stick with the same function idea you guys are getting at as it seems to be the right one.
would you mind adding whats you have said above to our current code im not quite sure what you mean hook.Add( "AllowPlayerPickup", "NoJobPickup", function( ply ) local blocked = { [ TEAM_FLITWICK ] = true, [ TEAM_LUPIN ] = true, [ TEAM_SNAPE ] = true, [ TEAM_SUBSTITUTE ] = true } return not blocked[ ply:Team() ] end )
// A table full of player jobs by Name. Not Variable. // Set to true to disallow these jobs from picking up tiems. local Teams = {} Teams["Administartor"] = true Teams["Moderator"] = true Teams["Admin On Duty"] = true Teams["Mod On Duty"] = true Teams["Teachers"] = true Teams["Magical Beings"] = true hook.Add( "AllowPlayerPickup", "Game.NewHooks.AllowPPickupBooks", function( p ) // Get the players Team Name into a simple 'tn' Variable local tn = team.GetName( p:Team() ) // If the table that is chosen by our tn (team name) exists, // then return false, making the player not able to pickup the book. if Teams[tn] then return false end end )
Thank you so much just to confirm when i am doing the Teams["Teachers"] = true is the "Teachers" the ulx group or the dark job we want it based of the darkrp job should it be entered like this Teams["TEAM_TEACHER"] = true or Teams["TEACHER"] = true
You missed where I said, these depend on the Job Names. Not Job Variables. Variable = TEAM_TEACHER Name(string) = "TEACHER" You want to make sure the "String" inside the Table. Teams[ "String" ] Matches exactly as the Job Name would on your F4, HUD, and so on. Teams[ "TEACHER" ] or even an example of Teams[ "Police Chief" ] or Teams[ "Mayor" ]
They are still able to use the entity please tell me if i am doing something wrong also im placing this in client side files is that correct? // A table full of player jobs by Name. Not Variable. // Set to true to disallow these jobs from picking up tiems. local Teams = {} Teams["Professor Flitwick"] = true Teams["Professor Lupin"] = true Teams["Professor Snape"] = true Teams["Substitue Teacher"] = true // We will also need some Entities to blacklist from being picked up local Bents = {} Bents["entity_hpwand_spell_accio"] = true Bents["entity_hpwand_spell_acriea"] = true Bents["entity_hpwand_spell_aguamenti"] = true Bents["entity_hpwand_spell_alarte_ascendare"] = true Bents["entity_hpwand_spell_alohomora"] = true Bents["entity_hpwand_spell_antihellia"] = true Bents["entity_hpwand_spell_apparition"] = true Bents["entity_hpwand_spell_arresto_momentum"] = true Bents["entity_hpwand_spell_arrow-shooting_spell"] = true Bents["entity_hpwand_spell_ascendio"] = true Bents["entity_hpwand_spell_balloonico"] = true Bents["entity_hpwand_spell_bombarda"] = true Bents["entity_hpwand_spell_bombarda_maxima"] = true Bents["entity_hpwand_spell_brevis_circuitous"] = true Bents["entity_hpwand_spell_carpe_retractum"] = true Bents["entity_hpwand_spell_collapsio"] = true Bents["entity_hpwand_spell_colloportus"] = true Bents["entity_hpwand_spell_colloshoo"] = true Bents["entity_hpwand_spell_color_lumos"] = true Bents["entity_hpwand_spell_colovaria"] = true Bents["entity_hpwand_spell_conjunctivitis_curse"] = true Bents["entity_hpwand_spell_deprimo"] = true Bents["entity_hpwand_spell_confringo"] = true Bents["entity_hpwand_spell_depulso"] = true Bents["entity_hpwand_spell_descendo"] = true Bents["entity_hpwand_spell_dimentio"] = true Bents["entity_hpwand_spell_disarm_curse_duo"] = true Bents["entity_hpwand_spell_dragoner"] = true Bents["entity_hpwand_spell_dremboom"] = true Bents["entity_hpwand_spell_dwisp"] = true Bents["entity_hpwand_spell_ear_shrivelling_curse"] = true Bents["entity_hpwand_spell_engorgio"] = true Bents["entity_hpwand_spell_engorgio_skullus"] = true Bents["entity_hpwand_spell_episkey"] = true Bents["entity_hpwand_spell_everte_statum"] = true Bents["entity_hpwand_spell_expelliarmus"] = true Bents["entity_hpwand_spell_expulso"] = true Bents["entity_hpwand_spell_extinguishing_spell"] = true Bents["entity_hpwand_spell_feather-light_charm"] = true Bents["entity_hpwand_spell_flarus"] = true Bents["entity_hpwand_spell_forbefire"] = true Bents["entity_hpwand_spell_fuelus_descendo"] = true Bents["entity_hpwand_spell_fumos"] = true Bents["entity_hpwand_spell_geminio"] = true Bents["entity_hpwand_spell_godivillio"] = true Bents["entity_hpwand_spell_gonfiare"] = true Bents["entity_hpwand_spell_green_sparks"] = true Bents["entity_hpwand_spell_grenadio"] = true Bents["entity_hpwand_spell_hail_of_bullets"] = true Bents["entity_hpwand_spell_heyedillio"] = true Bents["entity_hpwand_spell_hiding_charm"] = true Bents["entity_hpwand_spell_hillium"] = true Bents["entity_hpwand_spell_hocus"] = true Bents["entity_hpwand_spell_immobulus"] = true Bents["entity_hpwand_spell_impedimenta"] = true Bents["entity_hpwand_spell_inflatus"] = true Bents["entity_hpwand_spell_legimmio"] = true Bents["entity_hpwand_spell_levicorpus"] = true Bents["entity_hpwand_spell_locomotor_turret"] = true Bents["entity_hpwand_spell_lumos"] = true Bents["entity_hpwand_spell_lumos_maxima"] = true Bents["entity_hpwand_spell_lumos_solem"] = true Bents["entity_hpwand_spell_lux_bulbus"] = true Bents["entity_hpwand_spell_mimblewimble"] = true Bents["entity_hpwand_spell_mostro"] = true Bents["entity_hpwand_spell_muffliato"] = true Bents["entity_hpwand_spell_no_collide_charm"] = true Bents["entity_hpwand_spell_obscuratio"] = true Bents["entity_hpwand_spell_obscuro"] = true Bents["entity_hpwand_spell_perfectium"] = true Bents["entity_hpwand_spell_periculum"] = true Bents["entity_hpwand_spell_petrificus_totalus"] = true Bents["entity_hpwand_spell_protego"] = true Bents["entity_hpwand_spell_punchek"] = true Bents["entity_hpwand_spell_punchek_duo"] = true Bents["entity_hpwand_spell_purple_firecrackers"] = true Bents["entity_hpwand_spell_rechargio"] = true Bents["entity_hpwand_spell_red_sparks"] = true Bents["entity_hpwand_spell_rechargio"] = true Bents["entity_hpwand_spell_reducio"] = true Bents["entity_hpwand_spell_reducto"] = true Bents["entity_hpwand_spell_revealing_charm"] = true Bents["entity_hpwand_spell_rictusempra"] = true Bents["entity_hpwand_spell_salvio_hexia"] = true Bents["entity_hpwand_spell_secare"] = true Bents["entity_hpwand_spell_sectumsempra"] = true Bents["entity_hpwand_spell_shield_penetration"] = true Bents["entity_hpwand_spell_speedavec"] = true Bents["entity_hpwand_spell_stupefy"] = true Bents["entity_hpwand_spell_switching_spell"] = true Bents["entity_hpwand_spell_tarantallegra"] = true Bents["entity_hpwand_spell_timesum"] = true Bents["entity_hpwand_spell_trap_curse"] = true Bents["entity_hpwand_spell_trap_curse_duo"] = true Bents["entity_hpwand_spell_unbreakable_charm"] = true Bents["entity_hpwand_spell_vulnera_sanentur"] = true Bents["entity_hpwand_spell_waddiwasi"] = true Bents["entity_hpwand_spell_walkspeeden"] = true Bents["entity_hpwand_spell_welding_charm"] = true Bents["entity_hpwand_spell_winborium"] = true Bents["entity_hpwand_spell_winborium_duo"] = true Bents["entity_hpwand_spell_winborium_maxima"] = true Bents["entity_hpwand_spell_wingardium_leviosa"] = true // p is the Player, ent is the ENTITY hook.Add( "AllowPlayerPickup", "Game.NewHooks.AllowPPickupBooks", function( p, ent )     // Get the players Team Name into a simple > tn < Variable     local tn = team.GetName( p:Team() )     // See if our job name matches a table, and if the ENTITY we are trying to pick up matches the Bents Table.     if Teams[tn] && Bents[ent:GetClass()] then        return false     end end )
Sorry, you need to Log In to post a reply to this thread.