RC Cars

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
Post Reply
User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

RC Cars

Post by Gustavob »

Im trying to make an RC Car race map (not mini cars, theyre only remote controlled), but when I get into the remote icon, I cant control the car, I just get above the rc icon and thats all, nothing happens; can someone help me?

Here is the script:

Code: Select all

PLAYER_PED player1 = ( 150.1 , 157.5 , 5.0 ) 8 0
PLAYER_PED player2 = ( 150.5 , 157.5 , 5.0 ) 10 0
PLAYER_PED player3 = ( 151.0 , 157.5 , 5.0 ) 11 0
PLAYER_PED player4 = ( 151.5 , 157.5 , 5.0 ) 7 0
PLAYER_PED player5 = ( 152.0 , 157.5 , 5.0 ) 6 0
PLAYER_PED player6 = ( 152.5 , 157.5 , 5.0 ) 13 0

PARKED_CAR_DATA ztype1 = ( 153.5 , 163.5 , 2.0 ) 2 270 VTYPE
PARKED_CAR_DATA ztype2 = ( 153.5 , 164.5 , 2.0 ) 28 270 VTYPE 
PARKED_CAR_DATA ztype3 = ( 153.5 , 165.5 , 2.0 ) 5 270 VTYPE
PARKED_CAR_DATA ztype4 = ( 153.5 , 166.5 , 2.0 ) 10 270 VTYPE
PARKED_CAR_DATA ztype5 = ( 153.5 , 167.5 , 2.0 ) 1 270 VTYPE
PARKED_CAR_DATA ztype6 = ( 153.5 , 168.5 , 2.0 ) 3 270 VTYPE

OBJ_DATA rc1
OBJ_DATA rc2
OBJ_DATA rc3
OBJ_DATA rc4
OBJ_DATA rc5
OBJ_DATA rc6

LEVELSTART

//Create the remote icons
IF ( CHECK_CHARACTER_HEALTH ( player1 , 0 ) )
rc1 = CREATE_OBJ ( 160.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player2 , 0 ) )
rc2 = CREATE_OBJ ( 161.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player3 , 0 ) )
rc3 = CREATE_OBJ ( 162.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player4 , 0 ) )
rc4 = CREATE_OBJ ( 163.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player5 , 0 ) )
rc5 = CREATE_OBJ ( 164.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player6 , 0 ) )
rc6 = CREATE_OBJ ( 165.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

//Get remote of cars
IF ( ( CHECK_CHARACTER_HEALTH ( player1 , 0 ) ) AND ( LOCATE_CHARACTER_ON_FOOT ( player1 , 160.5 , 162.5 , 5.0 , 1.0 , 1.0 ) ) )
 DELAY_HERE ( 30 )
 TAKE_REMOTE_CONTROL_OF_CAR ( player1 , ztype1 )
ENDIF

IF ( ( CHECK_CHARACTER_HEALTH ( player2 , 0 ) ) AND ( LOCATE_CHARACTER_ON_FOOT ( player1 , 161.5 , 162.5 , 5.0 , 1.0 , 1.0 ) ) )
 DELAY_HERE ( 30 )
 TAKE_REMOTE_CONTROL_OF_CAR ( player2 , ztype2 )
ENDIF

IF ( ( CHECK_CHARACTER_HEALTH ( player3 , 0 ) ) AND ( LOCATE_CHARACTER_ON_FOOT ( player1 , 162.5 , 162.5 , 5.0 , 1.0 , 1.0  ) ) )
 DELAY_HERE ( 30 )
 TAKE_REMOTE_CONTROL_OF_CAR ( player3 , ztype3 )
ENDIF

IF ( ( CHECK_CHARACTER_HEALTH ( player4 , 0 ) ) AND ( LOCATE_CHARACTER_ON_FOOT ( player1 , 163.5 , 162.5 , 5.0 , 1.0 , 1.0  ) ) )
 DELAY_HERE ( 30 )
 TAKE_REMOTE_CONTROL_OF_CAR ( player4 , ztype4 )
ENDIF

IF ( ( CHECK_CHARACTER_HEALTH ( player5 , 0 ) ) AND ( LOCATE_CHARACTER_ON_FOOT ( player1 , 164.5 , 162.5 , 5.0 , 1.0 , 1.0  ) ) )
 DELAY_HERE ( 30 )
 TAKE_REMOTE_CONTROL_OF_CAR ( player5 , ztype5 )
ENDIF

IF ( ( CHECK_CHARACTER_HEALTH ( player6 , 0 ) ) AND ( LOCATE_CHARACTER_ON_FOOT ( player1 , 165.5 , 162.5 , 5.0 , 1.0 , 1.0  ) ) )
 DELAY_HERE ( 30 ),
 TAKE_REMOTE_CONTROL_OF_CAR ( player6 , ztype6 )
ENDIF

LEVELEND
it compiles successfully, but I dont take the remote control of car
You just lost the game.

User avatar
DAFE
Car Jacker
Car Jacker
Posts: 33
Joined: 15 Apr 2009, 01:31

Re: RC Cars

Post by DAFE »

Hey Gustavob,

You failed to see the obvious :P I hope this is the solution for you:

You need to put all your IF Checks within a WHILE or WHILE_EXEC main loop. I think what is happening is the game is running through your whole script once before your player even completes its spawn...the whole script can be read in 1/45th of a second from my experience. Didn't take me long to figure that out and I hope that's what fixes you up (as I'm sure it will). Everything looks good formatwise. Be careful about using DELAY_HERE's. They don't seem to do anything in a WHILE_EXEC loop anyways...but they may mess with slowing game down or desynching. The delay is noticeable in Normal WHILE loops. For WHILE_EXEC loops use:

IF ( NOT ( DELAY ( 45 ) ) ) //Only execute next commands every 45 game cycles ( 45cycles ~ 1 second on my computer) in WHILE_EXEC loop
... insert code that needs 1 second delay here...
ENDIF

Good luck!

PLAYER_PED player1 = ( 150.1 , 157.5 , 5.0 ) 8 0
PLAYER_PED player2 = ( 150.5 , 157.5 , 5.0 ) 10 0
PLAYER_PED player3 = ( 151.0 , 157.5 , 5.0 ) 11 0
PLAYER_PED player4 = ( 151.5 , 157.5 , 5.0 ) 7 0
PLAYER_PED player5 = ( 152.0 , 157.5 , 5.0 ) 6 0
PLAYER_PED player6 = ( 152.5 , 157.5 , 5.0 ) 13 0

PARKED_CAR_DATA ztype1 = ( 153.5 , 163.5 , 2.0 ) 2 270 VTYPE
PARKED_CAR_DATA ztype2 = ( 153.5 , 164.5 , 2.0 ) 28 270 VTYPE
PARKED_CAR_DATA ztype3 = ( 153.5 , 165.5 , 2.0 ) 5 270 VTYPE
PARKED_CAR_DATA ztype4 = ( 153.5 , 166.5 , 2.0 ) 10 270 VTYPE
PARKED_CAR_DATA ztype5 = ( 153.5 , 167.5 , 2.0 ) 1 270 VTYPE
PARKED_CAR_DATA ztype6 = ( 153.5 , 168.5 , 2.0 ) 3 270 VTYPE

OBJ_DATA rc1
OBJ_DATA rc2
OBJ_DATA rc3
OBJ_DATA rc4
OBJ_DATA rc5
OBJ_DATA rc6

LEVELSTART

//Create the remote icons
IF ( CHECK_CHARACTER_HEALTH ( player1 , 0 ) )
rc1 = CREATE_OBJ ( 160.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player2 , 0 ) )
rc2 = CREATE_OBJ ( 161.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player3 , 0 ) )
rc3 = CREATE_OBJ ( 162.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player4 , 0 ) )
rc4 = CREATE_OBJ ( 163.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player5 , 0 ) )
rc5 = CREATE_OBJ ( 164.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player6 , 0 ) )
rc6 = CREATE_OBJ ( 165.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF
counter mainloop = 1

WHILE_EXEC ( mainloop = 1 ) // MAIN LOOP - ALL COMMANDS READ EVERY GAME CYCLE

//Get remote of cars
IF ( ( CHECK_CHARACTER_HEALTH ( player1 , 0 ) ) AND ( LOCATE_CHARACTER_ON_FOOT ( player1 , 160.5 , 162.5 , 5.0 , 1.0 , 1.0 ) ) )
DELAY_HERE ( 30 )
TAKE_REMOTE_CONTROL_OF_CAR ( player1 , ztype1 )
ENDIF

IF ( ( CHECK_CHARACTER_HEALTH ( player2 , 0 ) ) AND ( LOCATE_CHARACTER_ON_FOOT ( player1 , 161.5 , 162.5 , 5.0 , 1.0 , 1.0 ) ) )
DELAY_HERE ( 30 )
TAKE_REMOTE_CONTROL_OF_CAR ( player2 , ztype2 )
ENDIF

IF ( ( CHECK_CHARACTER_HEALTH ( player3 , 0 ) ) AND ( LOCATE_CHARACTER_ON_FOOT ( player1 , 162.5 , 162.5 , 5.0 , 1.0 , 1.0 ) ) )
DELAY_HERE ( 30 )
TAKE_REMOTE_CONTROL_OF_CAR ( player3 , ztype3 )
ENDIF

IF ( ( CHECK_CHARACTER_HEALTH ( player4 , 0 ) ) AND ( LOCATE_CHARACTER_ON_FOOT ( player1 , 163.5 , 162.5 , 5.0 , 1.0 , 1.0 ) ) )
DELAY_HERE ( 30 )
TAKE_REMOTE_CONTROL_OF_CAR ( player4 , ztype4 )
ENDIF

IF ( ( CHECK_CHARACTER_HEALTH ( player5 , 0 ) ) AND ( LOCATE_CHARACTER_ON_FOOT ( player1 , 164.5 , 162.5 , 5.0 , 1.0 , 1.0 ) ) )
DELAY_HERE ( 30 )
TAKE_REMOTE_CONTROL_OF_CAR ( player5 , ztype5 )
ENDIF

IF ( ( CHECK_CHARACTER_HEALTH ( player6 , 0 ) ) AND ( LOCATE_CHARACTER_ON_FOOT ( player1 , 165.5 , 162.5 , 5.0 , 1.0 , 1.0 ) ) )
DELAY_HERE ( 30 ),
TAKE_REMOTE_CONTROL_OF_CAR ( player6 , ztype6 )
ENDIF

ENDWHILE // END MAIN LOOP that keeps looping while multiplayer game continues to run

LEVELEND

User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

Re: RC Cars

Post by Gustavob »

Thanks DAFE, I had the remote control now, but now I have another problem:



http://www.youtube.com/watch?v=VTO4eKHNQds
You just lost the game.

User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

Re: RC Cars

Post by Gustavob »

DAFE, thanks for your help :)
I tested it in multiplayer and I found something out: only the player2 lap counter was shown. I have no idea of what is the problem. The current script is:

Code: Select all

PLAYER_PED player1 = ( 160.5 , 161.5 , 5.0 ) 8 0
PLAYER_PED player2 = ( 161.5 , 161.5 , 5.0 ) 10 0
PLAYER_PED player3 = ( 162.5 , 161.5 , 5.0 ) 11 0
PLAYER_PED player4 = ( 163.5 , 161.5 , 5.0 ) 7 0

//The cars and hidden car transporters for transporting car wrecks
CAR_DATA ztype1
CAR_DATA ztype2
CAR_DATA ztype3
CAR_DATA ztype4
PARKED_CAR_DATA transporter1 = ( 152.5 , 168.5 , 2.0 ) -1 90 TRUKTRNS
PARKED_CAR_DATA transporter2 = ( 154.5 , 168.5 , 2.0 ) -1 90 TRUKTRNS
PARKED_CAR_DATA transporter3 = ( 156.5 , 168.5 , 2.0 ) -1 90 TRUKTRNS
PARKED_CAR_DATA transporter4 = ( 158.5 , 168.5 , 2.0 ) -1 90 TRUKTRNS

//The remote icons
OBJ_DATA rc1
OBJ_DATA rc2
OBJ_DATA rc3
OBJ_DATA rc4
OBJ_DATA rc5
OBJ_DATA rc6

LEVELSTART

//Create the remote icons
IF ( CHECK_CHARACTER_HEALTH ( player1 , 0 ) )
rc1 = CREATE_OBJ ( 160.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player2 , 0 ) )
rc2 = CREATE_OBJ ( 161.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player3 , 0 ) )
rc3 = CREATE_OBJ ( 162.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player4 , 0 ) )
rc4 = CREATE_OBJ ( 163.5 , 162.5 , 5.0 ) 0 REMOTE END
ENDIF

counter mainloop = 1
counter p1_remote_car_exists = 0
counter p2_remote_car_exists = 0
counter p3_remote_car_exists = 0
counter p4_remote_car_exists = 0
counter p1_lap_counter
counter p2_lap_counter
counter p3_lap_counter
counter p4_lap_counter
onscreen_counter p1_lap_counter_display
onscreen_counter p2_lap_counter_display
onscreen_counter p3_lap_counter_display
onscreen_counter p4_lap_counter_display

IF ( CHECK_CHARACTER_HEALTH ( player1 , 0 ) )
 ADD_ONSCREEN_COUNTER ( p1_lap_counter_display , p1_lap_counter )
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player2 , 0 ) )
 ADD_ONSCREEN_COUNTER ( p2_lap_counter_display , p2_lap_counter )
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player3 , 0 ) )
 ADD_ONSCREEN_COUNTER ( p3_lap_counter_display , p3_lap_counter )
ENDIF

IF ( CHECK_CHARACTER_HEALTH ( player4 , 0 ) )
 ADD_ONSCREEN_COUNTER ( p4_lap_counter_display , p4_lap_counter )
ENDIF

WHILE_EXEC ( mainloop = 1 ) // MAIN LOOP - ALL COMMANDS READ EVERY GAME CYCLE

//Get remote of cars
IF ( p1_remote_car_exists = 0 )
    IF ( CHECK_CHARACTER_HEALTH ( player1 , 0 ) )
        IF ( LOCATE_CHARACTER_ON_FOOT ( player1 , 160.5 , 162.5 , 5.0 , 1.0 , 1.0 ) )
            ztype1 = CREATE_CAR ( 153.5 , 163.5 , 2.0 ) 2 270 VTYPE END
            // You may need a delay here try it without first...
            TAKE_REMOTE_CONTROL_OF_CAR ( player1 , ztype1 )
            SET p1_remote_car_exists = 1
        ENDIF
    ENDIF
ENDIF
 IF ( p1_remote_car_exists = 1 )
    IF ( ( IS_CAR_WRECKED ( ztype1 ) ) OR ( HAS_CAR_JUST_SUNK ( ztype1 ) ) )
        IF ( NOT ( DELAY ( 200 ) ) )  //  INTRODUCES A CYCLE OF THIS EVENT BEING ABLE TO HAPPEN, SORT OF A DELAY
            PUT_CAR_ON_TRAILER ( ztype1 , transporter1 )  //  INSTANTLY TRANSPORT WRECK TO HIDDEN TRANSPORTER TRAILER TO PREVENT SPAWN AND WRECK ISSUES
            DELETE_ITEM ( ztype1 )  //  Cleanup:  Remove remote wreck
            SET p1_remote_car_exists = 0
        ENDIF
    ENDIF
ENDIF

IF ( p2_remote_car_exists = 0 )
    IF ( CHECK_CHARACTER_HEALTH ( player2 , 0 ) )
        IF ( LOCATE_CHARACTER_ON_FOOT ( player2 , 161.5 , 162.5 , 5.0 , 1.0 , 1.0 ) )
            ztype2 = CREATE_CAR ( 153.5 , 164.5 , 2.0 ) 2 270 VTYPE END
            TAKE_REMOTE_CONTROL_OF_CAR ( player2 , ztype2 )
            SET p2_remote_car_exists = 1
        ENDIF
    ENDIF
ENDIF
 IF ( p2_remote_car_exists = 1 )
    IF ( ( IS_CAR_WRECKED ( ztype2 ) ) OR ( HAS_CAR_JUST_SUNK ( ztype2 ) ) )
        IF ( NOT ( DELAY ( 200 ) ) )  //  INTRODUCES A CYCLE OF THIS EVENT BEING ABLE TO HAPPEN, SORT OF A DELAY
            PUT_CAR_ON_TRAILER ( ztype2 , transporter2 )  //  INSTANTLY TRANSPORT WRECK TO HIDDEN TRANSPORTER TRAILER TO PREVENT SPAWN AND WRECK ISSUES
            DELETE_ITEM ( ztype2 )  //  Cleanup:  Remove remote wreck
            SET p2_remote_car_exists = 0
        ENDIF
    ENDIF
ENDIF

IF ( p3_remote_car_exists = 0 )
    IF ( CHECK_CHARACTER_HEALTH ( player3 , 0 ) )
        IF ( LOCATE_CHARACTER_ON_FOOT ( player3 , 162.5 , 162.5 , 5.0 , 1.0 , 1.0 ) )
            ztype3 = CREATE_CAR ( 153.5 , 165.5 , 2.0 ) 2 270 VTYPE END
            TAKE_REMOTE_CONTROL_OF_CAR ( player3 , ztype3 )
            SET p3_remote_car_exists = 1
        ENDIF
    ENDIF
ENDIF
 IF ( p3_remote_car_exists = 1 )
    IF ( ( IS_CAR_WRECKED ( ztype3 ) ) OR ( HAS_CAR_JUST_SUNK ( ztype3 ) ) )
        IF ( NOT ( DELAY ( 200 ) ) )  //  INTRODUCES A CYCLE OF THIS EVENT BEING ABLE TO HAPPEN, SORT OF A DELAY
            PUT_CAR_ON_TRAILER ( ztype3 , transporter3 )  //  INSTANTLY TRANSPORT WRECK TO HIDDEN TRANSPORTER TRAILER TO PREVENT SPAWN AND WRECK ISSUES
            DELETE_ITEM ( ztype3 )  //  Cleanup:  Remove remote wreck
            SET p3_remote_car_exists = 0
        ENDIF
    ENDIF
ENDIF

IF ( p3_remote_car_exists = 0 )
    IF ( CHECK_CHARACTER_HEALTH ( player3 , 0 ) )
        IF ( LOCATE_CHARACTER_ON_FOOT ( player3 , 163.5 , 162.5 , 5.0 , 1.0 , 1.0 ) )
            ztype1 = CREATE_CAR ( 153.5 , 166.5 , 2.0 ) 2 270 VTYPE END
            // You may need a delay here try it without first...
            TAKE_REMOTE_CONTROL_OF_CAR ( player3 , ztype3 )
            SET p3_remote_car_exists = 1
        ENDIF
    ENDIF
ENDIF
 IF ( p3_remote_car_exists = 1 )
    IF ( ( IS_CAR_WRECKED ( ztype3 ) ) OR ( HAS_CAR_JUST_SUNK ( ztype3 ) ) )
        IF ( NOT ( DELAY ( 200 ) ) )  //  INTRODUCES A CYCLE OF THIS EVENT BEING ABLE TO HAPPEN, SORT OF A DELAY
            PUT_CAR_ON_TRAILER ( ztype3 , transporter3 )  //  INSTANTLY TRANSPORT WRECK TO HIDDEN TRANSPORTER TRAILER TO PREVENT SPAWN AND WRECK ISSUES
            DELETE_ITEM ( ztype3 )  //  Cleanup:  Remove remote wreck
            SET p3_remote_car_exists = 0
        ENDIF
    ENDIF
ENDIF

//Count the laps
If ( check_Character_Health ( player1 , 0 ) )
    If ( IS_CAR_IN_BLOCK ( ztype1 , 153.9 , 165.0 , 2.0 , 0.04 , 6.0 ) )
        ++p1_lap_counter
								ADD_SCORE ( player1 , 2000 )
    ENDIF
ENDIF

If ( check_Character_Health ( player2 , 0 ) )
    If ( IS_CAR_IN_BLOCK ( ztype2 , 153.9 , 165.0 , 2.0 , 0.04 , 6.0 ) )
        ++p2_lap_counter
								ADD_SCORE ( player2 , 2000 )
    ENDIF
ENDIF

If ( check_Character_Health ( player3 , 0 ) )
    If ( IS_CAR_IN_BLOCK ( ztype3 , 153.9 , 165.0 , 2.0 , 0.04 , 6.0 ) )
        ++p3_lap_counter
								ADD_SCORE ( player3 , 2000 )
    ENDIF
ENDIF

If ( check_Character_Health ( player4 , 0 ) )
    If ( IS_CAR_IN_BLOCK ( ztype4 , 153.9 , 165.0 , 2.0 , 0.04 , 6.0 ) )
        ++p4_lap_counter
								ADD_SCORE ( player4 , 2000 )
    ENDIF
ENDIF

ENDWHILE // END MAIN LOOP that keeps looping while multiplayer game continues to run

LEVELEND
You just lost the game.

Razor
Lunatic
Lunatic
Posts: 453
Joined: 19 Jul 2008, 14:14
GH nick: Razor, R
Location: Poland / Szczecin
Contact:

Re: RC Cars

Post by Razor »

if you set "time limit" first counter will be replaced by TIMER! My advice:

Create special counter to to remove glitch i did it in TEAM FAILURE.

Code: Select all

COUNTER ptk = 666
ONSCREEN_COUNTER zero

LEVELSTART 
ADD_ONSCREEN_COUNTER  ( zero , ptk )
CLEAR_ONSCREEN_COUNTER (zero) [add it one line above levelend or last endwhile]
LEVELEND

User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

Re: RC Cars

Post by Gustavob »

Thanks! Its working fine now :)
You just lost the game.

Post Reply