From 551cf74ec9182c2169c2be8973a4a4ecb8da42ae Mon Sep 17 00:00:00 2001 From: Lucas Eriksson Date: Wed, 13 Feb 2019 13:04:21 +0100 Subject: [PATCH] ghostcars: Add /ghost to disable vehicle collisions --- scripts/module/ghostcars.nut | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 scripts/module/ghostcars.nut diff --git a/scripts/module/ghostcars.nut b/scripts/module/ghostcars.nut new file mode 100644 index 0000000..7ead52b --- /dev/null +++ b/scripts/module/ghostcars.nut @@ -0,0 +1,44 @@ +function onScriptLoad() { + GHOSTKEY <- BindKey( true, 0x47, 0, 0 ); // G + ghost <- array( 100, false ); +} + +function onPlayerCommand( player, cmd, text ) { + cmd = cmd.tolower(); + if (cmd == "ghost") { + ghost[player.ID] = !ghost[player.ID]; + local message = "Your vehicle is a ghost: "; + if (ghost[player.ID]) { + if (player.VehicleSlot == 0) { // Player is driver + player.Vehicle.IsGhost = true; + } + message += "ON"; + } else { + if (player.VehicleSlot == 0) { + player.Vehicle.IsGhost = false; + } + message += "OFF"; + } + MessagePlayer(message, player); + } else if (cmd == "help") { + MessagePlayer("[#8080A0]/ghost", player); + } +} + +function onPlayerEnterVehicle( player, vehicle, door ) { + if (ghost[player.ID] && player.VehicleSlot == 0) { + vehicle.IsGhost = true; + } +} + +function onPlayerExitVehicle( player, vehicle ) { + if (player.VehicleSlot == 0) { + vehicle.IsGhost = false; + } +} + +function onPlayerPart( player, reason ) { + if (player.VehicleSlot == 0) { + player.Vehicle.IsGhost = false; + } +}