Quantcast

Jump to content

» «
Photo

[VC] Switching between 2 (or more characters) like in GTA 5

11 replies to this topic
Rainbow Party
  • Rainbow Party

  • BUSTED!
  • Joined: 16 Oct 2013

#1

Posted 19 October 2013 - 09:21 PM Edited by Rainbow Party, 20 October 2013 - 06:24 PM.

Hello. I've tried to make a Cleo code that lets you switch between two characters, kind of like in GTA 5 (which I haven't played yet).

Here's my code so far:

 

// This file was decompiled using VICESCM.INI published by GtaForums.com on 27.7.07

{$VERSION 2.2.0000}
{$CLEO .cs}

//-------------MAIN---------------
thread 'SWITCH'
wait 100
$CHARACTER = 0 // integer values
$C1POSX = 0 // integer values
$C1POSY = 0 // integer values
$C1POSZ = 0 // integer values
$C2POSX = 250.899 // floating-point values
$C2POSY = -1263.31 // floating-point values
$C2POSZ = 9.96706 // floating-point values
$C1HEALTH = 0 // integer values
$C2HEALTH = 0 // integer values
$C1WANTED = 0 // integer values
$C2WANTED = 0 // integer values
wait 500
0054: store_player $PLAYER_CHAR position_to $C1POSX $C1POSY $C1POSZ
023C: load_special_actor 1 'IGPHIL2'
038B: load_requested_models
wait 0
jump @SWITCH_144

:SWITCH_144
wait 0
if
023D:   special_actor 1 loaded
else_jump @SWITCH_144
wait 0
02C0: set $C1POSX $C1POSY $C1POSZ to_ped_path_coords_closest_to $C1POSX $C1POSY $C1POSZ
$C2 = Actor.Create(CivMale, #SPECIAL01, $C1POSX, $C1POSY, $C1POSZ)
$C2HEALTH = Actor.Health($C2)
wait 500
0193: set_actor $C2 objective_to_act_like_ped
$C1WANTED = Player.WantedLevel($PLAYER_CHAR)
$C2WANTED = Player.WantedLevel($PLAYER_CHAR)
wait 100
jump @SWITCH_250

:SWITCH_250
wait 10
if and
00E1:   key_pressed 0 4
00E1:   key_pressed 0 5
else_jump @SWITCH_250
if and
   not Actor.Dead($PLAYER_ACTOR)
   not Actor.Dead($C2)
8449:   not actor $C2 in_a_car
8449:   not actor $PLAYER_ACTOR in_a_car
   Player.Controllable($PLAYER_CHAR)
else_jump @SWITCH_250
if
  $CHARACTER == 0 // integer values
else_jump @SWITCH_589
$C2HEALTH = Actor.Health($C2)
0225: $C1HEALTH = player $PLAYER_CHAR health
Actor.StorePos($PLAYER_ACTOR, $C1POSX, $C1POSY, $C1POSZ)
Actor.StorePos($C2, $C2POSX, $C2POSY, $C2POSZ)
$C1WANTED = Player.WantedLevel($PLAYER_CHAR)
Player.WantedLevel($PLAYER_CHAR) = $C2WANTED
Actor.DestroyInstantly($C2)
Actor.RemoveReferences($C2)
Actor.PutAt($PLAYER_ACTOR, $C2POSX, $C2POSY, $C2POSZ)
0352: set_actor $PLAYER_ACTOR skin_to 'IGPHIL2'
$CHARACTER = 1 // integer values
038B: load_requested_models
0353: refresh_actor $PLAYER_ACTOR
0222: set_player $PLAYER_CHAR health_to $C2HEALTH
023C: load_special_actor 1 'PLAYER'
038B: load_requested_models
wait 0
jump @SWITCH_475

:SWITCH_475
wait 10
if
023D:   special_actor 1 loaded
else_jump @SWITCH_475
wait 0
02C0: set $C1POSX $C1POSY $C1POSZ to_ped_path_coords_closest_to $C1POSX $C1POSY $C1POSZ
$C2 = Actor.Create(CivMale, #SPECIAL01, $C1POSX, $C1POSY, $C1POSZ)
if
  $C1WANTED > 0 // integer values
else_jump @SWITCH_851
0193: set_actor $C2 objective_to_act_like_ped
jump @SWITCH_566

:SWITCH_566
wait 0
Actor.Health($C2) = $C1HEALTH
wait 10
jump @SWITCH_250

:SWITCH_589
wait 0
$C2HEALTH = Actor.Health($C2)
0225: $C1HEALTH = player $PLAYER_CHAR health
Actor.StorePos($PLAYER_ACTOR, $C1POSX, $C1POSY, $C1POSZ)
Actor.StorePos($C2, $C2POSX, $C2POSY, $C2POSZ)
$C2WANTED = Player.WantedLevel($PLAYER_CHAR)
Player.WantedLevel($PLAYER_CHAR) = $C1WANTED
Actor.DestroyInstantly($C2)
Actor.RemoveReferences($C2)
Actor.PutAt($PLAYER_ACTOR, $C2POSX, $C2POSY, $C2POSZ)
0352: set_actor $PLAYER_ACTOR skin_to 'PLAYER'
$CHARACTER = 0 // integer values
038B: load_requested_models
0353: refresh_actor $PLAYER_ACTOR
0222: set_player $PLAYER_CHAR health_to $C2HEALTH
023C: load_special_actor 1 'IGPHIL2'
038B: load_requested_models
wait 0
jump @SWITCH_737

:SWITCH_737
wait 10
if
023D:   special_actor 1 loaded
else_jump @SWITCH_737
wait 0
02C0: set $C1POSX $C1POSY $C1POSZ to_ped_path_coords_closest_to $C1POSX $C1POSY $C1POSZ
$C2 = Actor.Create(CivMale, #SPECIAL01, $C1POSX, $C1POSY, $C1POSZ)
if
  $C2WANTED > 0 // integer values
else_jump @SWITCH_873
0193: set_actor $C2 objective_to_act_like_ped
jump @SWITCH_828

:SWITCH_828
wait 0
Actor.Health($C2) = $C1HEALTH
wait 10
jump @SWITCH_250

:SWITCH_851
wait 0
009C: set_actor $C2 wander_path_to 0
wait 0
jump @SWITCH_566

:SWITCH_873
wait 0
009C: set_actor $C2 wander_path_to 0
wait 0
jump @SWITCH_828
 

 

Basically, in this code your main character is Tommy in his blue shirt and the second one is Phil with 1 arm. The code creates an AI Phil near you that runs on his own. When you press Action + Next Weapon, your character changes skin to Phil, and appears where the AI Phil was. The AI Phil gets deleted and an AI Tommy appears where YOU used to be. So far it stores each character's health and wanted level as well as their positions. If you press the keys again, it will switch the other way around (an integer variable controls which character you are currently using). Each character keeps his own wanted level. If one of them dies you can't change characters (I didn't make it reset their health back to 100% yet). If the AI character had a wanted level he runs, otherwise he walks.

It's an early WIP. To test it, I made Phil appear very close to you when the code starts (in the future I'd put him at his house and add more characters). It only works on foot (mainly since the keys you press don't work in a car and I haven't tested it otherwise). If one is inside an interior and the other isn't, it will be glitchy.

I haven't coded in SCM for ages so it's probably an ugly mess, and I have some questions:
-Can I somehow check if a character is entering a vehicle? Because if I press the keys when one is entering, the characters will get stuck floating in the air.  Edit: I added the code that checks if the player is controllable.

-Why does switching to Phil for the first time give him (you) a 1 star wanted level?

-Are there any other suggestions for this code? Later on, I want to make the AI ones behave in a more lifelike way if possible since you can run into each other on the street. For example, if one of the AI characters has a wanted level, or is just a psycho, I'd make him shoot at random peds. If they don't they could just walk or talk on the cellphone. And also smooth the switch between both (maybe with the screen fading or the camera moving from one to the other), as well as storing more info like which weapon each has. I also want to add some more characters from the game to this mod, later on. I keep thinking of more features so I'll update when I've managed to add some.

Thanks!

AbEWu.jpg


Silent
  • Silent

    Chief Fixing Officer

  • GTA Mods Staff
  • Joined: 01 Feb 2010
  • Poland
  • Contribution Award [Mods]
    Best Script/Plugin 2014 [SilentPatch]
    Most Respected 2014
    Most Helpful [Mods] 2014
    Most Helpful [GTA] 2013
    Most Helpful [Mods] 2013
    Most Talented [Modding] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Best Vehicle 2013 [III Aircraft]
    Most Helpful [Mods] 2012
    Modder of the Year 2012

#2

Posted 20 October 2013 - 09:23 AM

DON'T use global variables in your CLEO script.


Rainbow Party
  • Rainbow Party

  • BUSTED!
  • Joined: 16 Oct 2013

#3

Posted 20 October 2013 - 01:21 PM Edited by Rainbow Party, 20 October 2013 - 02:00 PM.

Oops... yes, that makes sense, thanks! But may I ask exactly why not?

And is there a way to write comments on Cleo scripts? I tried "// " but they disappear when I open it again.


Silent
  • Silent

    Chief Fixing Officer

  • GTA Mods Staff
  • Joined: 01 Feb 2010
  • Poland
  • Contribution Award [Mods]
    Best Script/Plugin 2014 [SilentPatch]
    Most Respected 2014
    Most Helpful [Mods] 2014
    Most Helpful [GTA] 2013
    Most Helpful [Mods] 2013
    Most Talented [Modding] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Best Vehicle 2013 [III Aircraft]
    Most Helpful [Mods] 2012
    Modder of the Year 2012

#4

Posted 20 October 2013 - 04:53 PM

Mainly because global variables in CLEO overwrite the main.scm ones, causing the game to mess up... badly.

 

Also, why are you recompiling your own scripts?


Rainbow Party
  • Rainbow Party

  • BUSTED!
  • Joined: 16 Oct 2013

#5

Posted 20 October 2013 - 06:16 PM Edited by Rainbow Party, 20 October 2013 - 06:17 PM.

Oh right, I thought so about the global ones, I'm using them mostly because local variables can only have numbers as names (right?) which is confusing when I'm writing it so I guess I'll change them when I'm done.

And I'm not really sure what you mean with your question :p


Silent
  • Silent

    Chief Fixing Officer

  • GTA Mods Staff
  • Joined: 01 Feb 2010
  • Poland
  • Contribution Award [Mods]
    Best Script/Plugin 2014 [SilentPatch]
    Most Respected 2014
    Most Helpful [Mods] 2014
    Most Helpful [GTA] 2013
    Most Helpful [Mods] 2013
    Most Talented [Modding] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Best Vehicle 2013 [III Aircraft]
    Most Helpful [Mods] 2012
    Modder of the Year 2012

#6

Posted 20 October 2013 - 06:55 PM

And I'm not really sure what you mean with your question :p


->

And is there a way to write comments on Cleo scripts? I tried "// " but they disappear when I open it again.


Rainbow Party
  • Rainbow Party

  • BUSTED!
  • Joined: 16 Oct 2013

#7

Posted 20 October 2013 - 07:33 PM Edited by Rainbow Party, 20 October 2013 - 07:33 PM.

Oh, I just recompile it so it automatically checks for mistakes.


Silent
  • Silent

    Chief Fixing Officer

  • GTA Mods Staff
  • Joined: 01 Feb 2010
  • Poland
  • Contribution Award [Mods]
    Best Script/Plugin 2014 [SilentPatch]
    Most Respected 2014
    Most Helpful [Mods] 2014
    Most Helpful [GTA] 2013
    Most Helpful [Mods] 2013
    Most Talented [Modding] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Best Vehicle 2013 [III Aircraft]
    Most Helpful [Mods] 2012
    Modder of the Year 2012

#8

Posted 20 October 2013 - 07:50 PM

Then compile, but don't decompile again. Work on the same .txt/.sc file all the time.


Rainbow Party
  • Rainbow Party

  • BUSTED!
  • Joined: 16 Oct 2013

#9

Posted 20 October 2013 - 08:34 PM Edited by Rainbow Party, 21 October 2013 - 02:55 PM.

Thanks. I'll keep working on it.

 

EDIT: Update

// This file was decompiled using VICESCM.INI published by GtaForums.com on 27.7.07

{$VERSION 2.2.0000}
{$CLEO .cs}

//-------------MAIN---------------
thread 'SWITCH'
wait 100
1@ = 0 // integer values
2@ = 0 // integer values
3@ = 0 // integer values
4@ = 0 // integer values
5@ = 250.899 // floating-point values
6@ = -1263.31 // floating-point values
7@ = 9.96706 // floating-point values
8@ = 0 // integer values
9@ = 0 // integer values
10@ = 0 // integer values
11@ = 0 // integer values
$C1WEAPON = 0 // integer values
$C2WEAPON = 0 // integer values
14@ = 0.0 // floating-point values
wait 500
jump @SWITCH_136

:SWITCH_136
wait 0
0054: store_player $PLAYER_CHAR position_to 2@ 3@ 4@
023C: load_special_actor 1 'IGPHIL2'
038B: load_requested_models
wait 0
if
023D:   special_actor 1 loaded
else_jump @SWITCH_136
wait 0
02C0: set 2@ 3@ 4@ to_ped_path_coords_closest_to 2@ 3@ 4@
$C2 = Actor.Create(CivMale, #SPECIAL01, 2@, 3@, 4@)
9@ = Actor.Health($C2)
wait 500
009C: set_actor $C2 wander_path_to 0
10@ = Player.WantedLevel($PLAYER_CHAR)
11@ = Player.WantedLevel($PLAYER_CHAR)
wait 100
jump @SWITCH_276

:SWITCH_276
wait 10
if
   Player.Defined($PLAYER_CHAR)
else_jump @SWITCH_1132
if
00E1:   key_pressed 0 4
else_jump @SWITCH_276
if
   not Actor.Dead($C2)
else_jump @SWITCH_276
wait 0
if and
8449:   not actor $C2 in_a_car
8449:   not actor $PLAYER_ACTOR in_a_car
   Player.Controllable($PLAYER_CHAR)
else_jump @SWITCH_276
wait 0
fade 0 200
wait 0
if
  1@ == 0 // integer values
else_jump @SWITCH_740
wait 300
9@ = Actor.Health($C2)
0470: $C1WEAPON = actor $PLAYER_ACTOR armed_weapon
0225: 8@ = player $PLAYER_CHAR health
Actor.StorePos($PLAYER_ACTOR, 2@, 3@, 4@)
Actor.StorePos($C2, 5@, 6@, 7@)
0509: 14@ = distance between point 2@ 3@ and point 5@ 6@
10@ = Player.WantedLevel($PLAYER_CHAR)
Player.WantedLevel($PLAYER_CHAR) = 11@
Actor.DestroyInstantly($C2)
Actor.RemoveReferences($C2)
0222: set_player $PLAYER_CHAR health_to 100
Actor.PutAt($PLAYER_ACTOR, 5@, 6@, 7@)
if
  14@ > 100.0 // floating-point values
else_jump @SWITCH_546
wait 1800
jump @SWITCH_546

:SWITCH_546
wait 200
0352: set_actor $PLAYER_ACTOR skin_to 'IGPHIL2'
01B8: set_player $PLAYER_CHAR armed_weapon_to $C2WEAPON
1@ = 1 // integer values
038B: load_requested_models
0353: refresh_actor $PLAYER_ACTOR
fade 1 300
0222: set_player $PLAYER_CHAR health_to 9@
023C: load_special_actor 1 'PLAYER'
038B: load_requested_models
wait 0
jump @SWITCH_626

:SWITCH_626
wait 10
if
023D:   special_actor 1 loaded
else_jump @SWITCH_626
wait 0
02C0: set 2@ 3@ 4@ to_ped_path_coords_closest_to 2@ 3@ 4@
$C2 = Actor.Create(CivMale, #SPECIAL01, 2@, 3@, 4@)
if
  10@ > 0 // integer values
else_jump @SWITCH_1088
0193: set_actor $C2 objective_to_act_like_ped
jump @SWITCH_717

:SWITCH_717
wait 0
Actor.Health($C2) = 8@
wait 10
jump @SWITCH_276

:SWITCH_740
wait 300
9@ = Actor.Health($C2)
0470: $C2WEAPON = actor $PLAYER_ACTOR armed_weapon
0225: 8@ = player $PLAYER_CHAR health
Actor.StorePos($PLAYER_ACTOR, 2@, 3@, 4@)
Actor.StorePos($C2, 5@, 6@, 7@)
0509: 14@ = distance between point 2@ 3@ and point 5@ 6@
11@ = Player.WantedLevel($PLAYER_CHAR)
Player.WantedLevel($PLAYER_CHAR) = 10@
Actor.DestroyInstantly($C2)
Actor.RemoveReferences($C2)
0222: set_player $PLAYER_CHAR health_to 100
Actor.PutAt($PLAYER_ACTOR, 5@, 6@, 7@)
if
  14@ > 100.0 // floating-point values
else_jump @SWITCH_894
wait 1800
jump @SWITCH_894

:SWITCH_894
wait 200
0352: set_actor $PLAYER_ACTOR skin_to 'PLAYER'
01B8: set_player $PLAYER_CHAR armed_weapon_to $C1WEAPON
1@ = 0 // integer values
038B: load_requested_models
0353: refresh_actor $PLAYER_ACTOR
fade 1 300
0222: set_player $PLAYER_CHAR health_to 9@
023C: load_special_actor 1 'IGPHIL2'
038B: load_requested_models
wait 0
jump @SWITCH_974

:SWITCH_974
wait 10
if
023D:   special_actor 1 loaded
else_jump @SWITCH_974
wait 0
02C0: set 2@ 3@ 4@ to_ped_path_coords_closest_to 2@ 3@ 4@
$C2 = Actor.Create(CivMale, #SPECIAL01, 2@, 3@, 4@)
if
  11@ > 0 // integer values
else_jump @SWITCH_1110
0193: set_actor $C2 objective_to_act_like_ped
jump @SWITCH_1065

:SWITCH_1065
wait 0
Actor.Health($C2) = 8@
wait 10
jump @SWITCH_276

:SWITCH_1088
wait 0
009C: set_actor $C2 wander_path_to 0
wait 0
jump @SWITCH_717

:SWITCH_1110
wait 0
009C: set_actor $C2 wander_path_to 0
wait 0
jump @SWITCH_1065

:SWITCH_1132
wait 0
Actor.DestroyInstantly($C2)
Actor.RemoveReferences($C2)
1@ = 0 // integer values
wait 0
jump @SWITCH_136



Velox the Aprendice
  • Velox the Aprendice

    Player Hater

  • Members
  • Joined: 06 Dec 2013

#10

Posted 06 December 2013 - 12:38 AM

Please Send The CS file my sanny builder have a problem:

 

Report:

 

MAIN size: 0

Maximum:225512

 

Largest Mission:0

maximun:3500

 

Largest Script:1164


Brinxster
  • Brinxster

    Texture Modder

  • Members
  • Joined: 12 Nov 2013
  • Indonesia

#11

Posted 15 December 2013 - 11:27 AM

which file type are required for that script? .txt script, .cs script, or both? :/


Aswin Animatior
  • Aswin Animatior

    The best Young Animator

  • Members
  • Joined: 01 Mar 2014
  • India

#12

Posted 02 March 2014 - 05:40 AM Edited by ZAZ, 02 March 2014 - 06:06 AM.

Please send me the .cs format
and a dog mod for gta vc

i need switch character like gta v for gta vc and dog mod
please agree this as a request
please!

---
use edit option
two posts merged to one by Zaz





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users