I want to ask how to make vehicle script like in |ExT| Happy Town, that has :
- Start/Stop engine
- Gear(Press F2 to gear down, Press F3 to gear up)
- Vehicle settings
Screenshot :
edited 1×, last 23.10.16 03:40:43 am
Scripts
Vehicle Script
Vehicle Script
1

Inserting new index into table.table.insert(table, [pos,] value)
Removing lastest index on table.table.remove(table, [pos])
ipairs looping method.for KEY, VALUE in ipairs ( TABLE ) do
Sine and cosine calculation.player(id,"x")-math.sin(math.rad(player(id,"rot")-180)) [*SPEED]
player(id,"y")+math.cos(math.rad(player(id,"rot")-180)) [*SPEED]
Image thing.local id = image("gfx/path.png",player(id,"x"),player(id,"y"),1)
Baloon said, you need to dig the CS2D Commands/Lua list for the following hooks and Lua functions in order to implement the actions desired. At this time I'm going to help you with the prime basics:
serveraction is our main hook for this task. Seeing the screenshot we'll use F4 as main button. I'll explain it in the code below.function ServerActionHook(id, action)
	if ( action == 3 ) then -- The 3 value stands for F4 button in our case
		-- Start/Stop Engine code here...
	end
end
addhook('serveraction', 'ServerActionHook')
serveraction for this. I'll use the same code like above.function ServerActionHook(id, action)
	if ( action == 3 ) then -- The 3 value stands for F4 button in our case
		-- Start/Stop Engine code here...
	elseif ( action == 1 ) then -- Now the 1 value stands for F2 button
		-- Gear Down code here...
	elseif ( action == 2 ) then -- Finally the 2 value stands for F3 button
		-- Gear Up code here...
	end
end
addhook('serveraction', 'ServerActionHook')
elseif. The fifth and seventh line must be replaced with an actual Gear function code.
say for that.function SayVehicleSettings(id, message)
	if ( string.sub(message, 1, 16) == '!vehiclesettings' ) then
		menu(id, 'Vehicle Settings, ..., ..., ...')
	end
end
function VehicleSettingsMenu(id, title, button)
	if ( title == 'Vehicle Setings' ) then -- Check if the title of the menu is Vehicle Settings
		if ( button == 1 ) -- Check if the player presses the first button within the menu.
			menu(id, 'Another menu, ..., ..., ...') -- Create a subsequent menu
		-- Repeat the same thing for other buttons at your choice...
		end
	end
end
addhook('say', 'SayVehicleSettings')
addhook('menu', 'VehicleSettingsMenu')
menu as to expand the menu template with various menu functions. In the third line this is our main template menu and the ...dots must be replaced with title buttons (i.e Vehicle Lights). Afterwards, within
VehicleSettingsMenufunction you must define each button their task (i.e Turn CD Player ON -> CD Player is turned ON) or create a subsequent menu for sub functions like I did in the code.
1
