Skip to content

OnPlayerEnterCart

A player asks to get into a cart - return false to keep them out, or a seat number to seat them there.

Runs when the player uses the cart’s prompt, before they climb in: seat is the one they would get - 0 at the reins of a free cart, else a free seat that is not locked (SetCartSeatLocked): from the bench’s prompt the one beside the reins first, from the back’s the back on the player’s side. Return false to keep them out, another seat’s number to seat them there instead (it must be free - a locked one is fine, the reins of a route cart are not; a taken one keeps them out, told so), anything else to let them in on seat. Their game climbs onto the seat and GetPlayerCart answers from now on. It does not run for the mode’s own PutPlayerInCart. What the cart is - its route (GetCartRoute), its parts (GetCartParts), who sits where (GetCartSeatPlayer) - is there to read, as in every cart callback.

function OnPlayerEnterCart(pid, id, seat)
-- ...
end
Parameter Type
pid number the player
id number the cart
seat number the seat they would sit on (0 = at the reins)

false keeps them out; a number is the seat they get instead; anything else lets them in

-- a fare of 2 Groschen for a ride on the routes; the reins of a free cart cost nothing
function OnPlayerEnterCart(pid, id, seat)
if not GetCartRoute(id) then return true end
if GetPlayerMoney(pid) < 2 then
SendClientMessage(pid, COLOR_RED, "The ride costs 2 Groschen.")
return false
end
GivePlayerMoney(pid, -2)
return true
end

OnPlayerExitCart · OnPlayerChangeCartSeat · PutPlayerInCart · GetPlayerCart · SetCartSeatLocked · the Carts group of the index