DarkRP Stopping People Buy Doors

Ok so I want TEAM_HOBO to not be able to buy doors.

I am awful at lua but wanting to learn so if someone could help me out here and explain what you have done, well… that would be great.



if TEAM_HOBO then
    HUDDrawDoorData() == false -- I know this is the wrong hook but its the only thing I could find on DarkRP wiki
end
hook.Add( "HUDDrawDoorData", "DoorData", DoorData )


I know I am terrible at lua, but you have to start somewhere!

I aint a super expert on lua, but Im sure if you made a way to do a custom check for hobo with this maybe.

GM:ShowTeam( Player ply )

it could work, Sorry I couldn’t be super helpful :frowning:

Edit:

or you can try these .

playerBuyDoor( Player ply, Entity ent )

Player:getJobTable( )

Thanks bro! Every little helps :slight_smile:

[editline]27th October 2014[/editline]

playerBuyDoor is when a player purchases a door, so that wouldn’t work.

Yeah, when the player buy’s the door, do a check if it’s a hobo, then return false

A suggestion by TCB, and a guess by me

So it would look like:



if TEAM_HOBO then
    playerBuyDoor() return
       false
end



http://wiki.darkrp.com/index.php/Hooks/server/playerbuydoor
Here’s basically what you want. Change the identifier.
[lua]
local function DenyDoorPurchase( ply, ent )
if ( ply:Team( ) == TEAM_HOBO ) then
return false, “Hobos can’t buy doors!”, false
end
end
hook.Add( “playerBuyDoor”, “UniqueHookIdentifier”, DenyDoorPurchase )
[/lua]

( ply, ent ), do you include this because a player and entity are involved in the code? Sorry I am just trying to understand why you put this in the parameter.

The ‘playerBuyDoor’ hook comes with 2 parameters the player buying the door (ply) and the door entity (ent).
When you then have them in your parameters, you can use it in the function.

If you go to the wiki page for the hook then it will tell you what parameters it comes with and what you can return.

Hobo’s are unable to own doors in a recent commit to DarkRP, this one specifically: Merge branch 'misc' of github.com:Bo98/DarkRP · FPtje/DarkRP@4fe86f2 · GitHub

Thanks man!