death_knight
Dark is the heart of a corrupted man.
- Reaction score
- 24
Hey guys,
What I'm trying to do is make a system where a player unit can own a car. What I need from the system is to only allow the player's car to move when a unit owned by the player who has the car keys in their inventory is loaded into the car.
Here's what I got in terms of buying the car:
Trigger 1:
Trigger 2:
My question is: how do I make a system that only allow the player's car to move when a unit owned by the player who has the car keys in their inventory is loaded into the car?
What I'm trying to do is make a system where a player unit can own a car. What I need from the system is to only allow the player's car to move when a unit owned by the player who has the car keys in their inventory is loaded into the car.
Here's what I got in terms of buying the car:
Trigger 1:
Code:
Buying a Car
Events
Player - Player 1 (Red) Selects a unit
Conditions
(Triggering unit) Equal to Salesman (Male 2) 0019 <gen>
CarOwned Equal to False
Actions
Unit Group - Pick every unit in (Units within 256.00 of (Position of (Triggering unit))) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Picked unit)) Equal to Player 1 (Red)
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarDialogCreated Equal to False
Then - Actions
Dialog - Change the title of BuyingCarDialog to Do you Wish to Buy ...
Dialog - Create a dialog button for BuyingCarDialog labelled Yes, here's 200 gol...
Set BuyingCarDialogButtons[1] = (Last created dialog Button)
Dialog - Create a dialog button for BuyingCarDialog labelled I don't have that s...
Set BuyingCarDialogButtons[2] = (Last created dialog Button)
Dialog - Show BuyingCarDialog for Player 1 (Red)
Set CarDialogCreated = True
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarDialogCreated Equal to True
Then - Actions
Dialog - Show BuyingCarDialog for Player 1 (Red)
Else - Actions
Trigger - Turn on Buying a Car Dialog Button Clicked <gen>
Else - Actions
Trigger 2:
Code:
Buying a Car Dialog Button Clicked
Events
Dialog - A dialog button is clicked for BuyingCarDialog
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 1 (Red) Current gold) Less than 200
Then - Actions
Game - Display to (All players) the text: You don't have enou...
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to BuyingCarDialogButtons[1]
(Player 1 (Red) Current gold) Greater than or equal to 200
Then - Actions
Dialog - Hide BuyingCarDialog for Player 1 (Red)
Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) - 200)
Special Effect - Destroy SpecialEffect[1]
Hero - Create Car Keys and give it to PlayerUnit
Set CarKeys = (Last created item)
Set CarKeyHolder = PlayerUnit
Set CarKeyIDNo = (Random integer number between 100000 and 999999)
Item - Set the custom value of CarKeys to CarKeyIDNo
Multiboard - Set the text for Multiboard item in column 2, row 6 to (String(CarKeyIDNo))
Set CarOwned = True
Set CarInteger = (CarInteger + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 1
Then - Actions
Unit - Change ownership of Car 0001 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of Car 0001 <gen> to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 2
Then - Actions
Unit - Change ownership of Car 0002 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 3
Then - Actions
Unit - Change ownership of Car 0003 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 4
Then - Actions
Unit - Change ownership of Car 0004 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 5
Then - Actions
Unit - Change ownership of Car 0005 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 6
Then - Actions
Unit - Change ownership of Car 0006 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 7
Then - Actions
Unit - Change ownership of Car 0007 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 8
Then - Actions
Unit - Change ownership of Car 0008 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 9
Then - Actions
Unit - Change ownership of Car 0009 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 10
Then - Actions
Unit - Change ownership of Car 0010 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 11
Then - Actions
Unit - Change ownership of Car 0018 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 12
Then - Actions
Unit - Change ownership of Car 0017 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 13
Then - Actions
Unit - Change ownership of Car 0016 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 14
Then - Actions
Unit - Change ownership of Car 0015 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 15
Then - Actions
Unit - Change ownership of Car 0014 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 16
Then - Actions
Unit - Change ownership of Car 0013 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 17
Then - Actions
Unit - Change ownership of Car 0012 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CarInteger Equal to 18
Then - Actions
Unit - Change ownership of Car 0011 <gen> to Player 1 (Red) and Change color
Unit - Set the custom value of (Last created unit) to CarKeyIDNo
Set PlayerCar = (Last created unit)
Else - Actions
Unit - Pause PlayerCar
Trigger - Run Car Info <gen> (checking conditions)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to BuyingCarDialogButtons[2]
Then - Actions
Dialog - Hide BuyingCarDialog for Player 1 (Red)
Game - Display to (All players) the text: |ccffffcc00Salesman...
Else - Actions
My question is: how do I make a system that only allow the player's car to move when a unit owned by the player who has the car keys in their inventory is loaded into the car?