DarkRP.PlayerBuyVehicle

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 vehicle
Syntax
GAMEMODE:PlayerBuyVehicle(Player ply, Entity ent)
Returnsallowed (boolean): whether the player is allowed to buy this vehicle.

reason (string): the reason to give to the player if they are not allowed to buy the vehicle

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

Arguments

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

  • ent (Entity)
  • The vehicle in question

    Examples

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