CityRP Documentation Repository

core.plugins.tesla_charger.entities.cityrp_tesla_homecharger.init

Tesla Homecharger (server)

Server logic for the player-owned Tesla Homecharger. Charges the driver of a nearby electric vehicle per 10% of charge; the charger's owner receives the profit above the base cost, and covers the shortfall when the price is set below base (including free charging). Every charger is driven by a single shared scan timer rather than a per-entity Think.

Functions

ServerENT:ChargePlayerVehicle(ply, veh) → booleanSource ☍

Charges one 10% increment into a vehicle, billing the driver and paying the owner. Asks for consent on first approach, refuses when the vehicle is full, the driver cannot pay, or a below-base price would put the owner out of pocket.

Parameters

  • plyPlayerThe driver being billed.
  • vehEntityThe vehicle being charged.

Returns

  1. booleanWhether charge was actually added this tick.
ServerENT:IsValidChargingCandidate(veh) → booleanSource ☍

Whether a vehicle is an electric one with a live, permitted driver at the wheel.

Parameters

  • vehEntityThe vehicle to test.

Returns

  1. boolean
ServerENT:SetChargingActive(active)Source ☍

Matches the hum to whether this charger is currently servicing a vehicle.

Parameters

  • activebooleanWhether a vehicle is charging in range.
ServerENT:StartChargingHum()Source ☍

Starts the charging hum, creating the looping sound on first use.

ServerENT:StopChargingHum()Source ☍

Stops the charging hum if one is playing.

Fields

ServerENT._ChargeSoundSource ☍
ServerENT._tesla_subsidy_notify_timeSource ☍