DarkRP.PlayerBuyDoor

From Official DarkRP Wiki
Jump to: navigation, search
This page refers to DarkRP 2.4.3. This information may be incorrect as of later versions.
Check here for a up-to-date list of hooks.

Syntax

DescriptionCalled when a player wants to buy a door
Syntax
GAMEMODE:PlayerBuyDoor(Player ply, Entity ent)
Returnsallowed (boolean): whether the player is allowed to buy this door.

reason (string): the reason to give if the player is not allowed to buy the door.

surpressMessage (boolean): whether the "You bought this door!" message should be supressed.

Arguments

  • ply (Player)
  • The player who wants to buy it

  • ent (Entity)
  • The door in question

    Examples

    DescriptionAllows only citizens to buy the door with EntIndex 31. The reason it gives to non-citizens is that they're not citizens. It also makes sure the message "You bought this door!" does not appear (that's what the last true does)
    Code
    hook.Add( "PlayerBuyDoor", "example", function(ply, ent)
    	if ent:EntIndex() == 31 then
    		return ply:Team() == TEAM_CITIZEN, "You're not a citizen!", true
    	end
    end)
    OutputDoor 31 is citizen only



    DescriptionMakes sure hobo's can't buy any doors
    Code
    hook.Add( "PlayerBuyDoor", "example2", function(ply, ent)
    	return ply:Team() ~= TEAM_CITIZEN, "You're homeless, you can't buy doors!", true
    end)
    OutputHobo's can't purchase doors