IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules Attention:

The Mod Showroom is only for posting previews/downloads of completed or near finished mods.
All help topics should be posted in the Editing Discussion forums. Help topics and mod requests posted here will be locked or binned. Thank you.
GTAGarage.com : Free mod hosting, attach your files and screenshots to your topics
GTAModding.com : A wiki for everything related to GTA modding, including documentation and tutorials

Pages: (2) [1] 2   ( Go to first unread post ) Reply to this topicStart new topicStart Poll

 [REL | CODE] Give n' Take

 Switching weapons with followers
 
MrTi  
Posted: Thursday, Jun 23 2005, 03:23
Quote Post


Crackhead
Group Icon
Group: Members
Joined: Jun 7, 2003

us.gif

XXXXX



Here's a simple code to give anyone following you your current weapon and ammo, you in turn lose that weapon, but you can also take back the weapon, or whatever weapon and ammo that they are carrying. Taking a weapon may be cheap because some carry unlimited ammo for their weapon. smile.gif

To give a weapon, aim at whoever is following you with the weapon you want to give and press Y.
To take a weapon, aim at the follower whose weapon you want and press N.

To cycle through the follower's weapons aim at the follower and hold either weapon switch buttons (Q or E).

This works with anybody that follows you and is considered in your "group".

CODE

004F: create_thread ££giventake

:giventake
0001: wait  0 ms
00D6: if  0  
0256:   player $PLAYER_CHAR defined
004D: jump_if_false ££giventake
0004: $i = 0
0004: $homie($i,7i) = 0

:giventake2
0001: wait  0 ms        
07AF: $gang = player $PLAYER_CHAR group
092B: $homie(0) = group $gang member 0  
092B: $homie(1) = group $gang member 1
092B: $homie(2) = group $gang member 2
092B: $homie(3) = group $gang member 3
092B: $homie(4) = group $gang member 4
092B: $homie(5) = group $gang member 5
092B: $homie(6) = group $gang member 6

:give1
0001: wait  0 ms
00D6: if  1
00E1:   key pressed  0  11
0457:   player $PLAYER_CHAR aiming at actor $homie($i,7i)
004D: jump_if_false ££take1
00D6: if  0  
00F2:   actor $homie($i,7i) near actor $PLAYER_ACTOR radius  5.0  5.0  0
004D: jump_if_false ££take1
04ED: load animation "MISC"

:give2
00D6: if  0
84EE:   NOT   animation "MISC" loaded    
004D: jump_if_false ££give3
0001: wait  0 ms
0002: jump ££give2

:give3  
04C4: create_coordinate $x $y $z from_actor $PLAYER_ACTOR offset  0.0  1.0  0.0
02CE: $z = ground_z $x $y $z
00A1: put actor $homie($i,7i) at $x $y $z
0172: $angle = actor $PLAYER_ACTOR z_angle
000B: $angle +=  180.0;; floating-point values
0173: set_actor $homie($i,7i) z_angle_to $angle
0605: unknown_action_sequence $PLAYER_ACTOR "PASS_RIFLE_PED" "MISC"  4.0  0  0  0  0 -1
0470: $gun = actor $PLAYER_ACTOR armed weapon unknown
041A: $ammo = actor $PLAYER_ACTOR weapon $gun ammo
0555: remove_weapon $gun from_actor $PLAYER_ACTOR
0605: unknown_action_sequence $homie($i,7i) "PASS_RIFLE_PLY" "MISC"  4.0  0  0  0  0 -1
01B2: give_actor $homie($i,7i) weapon $gun ammo $ammo;; Load the weapon model before using this  

:take1
0001: wait  0 ms
00D6: if  1
00E1:   key pressed  0  10
0457:   player $PLAYER_CHAR aiming at actor $homie($i,7i)
004D: jump_if_false ££switchnext1
00D6: if  0  
00F2:   actor $homie($i,7i) near actor $PLAYER_ACTOR radius  5.0  5.0  0
004D: jump_if_false ££loop1
04ED: load animation "MISC"

:take2
00D6: if  0
84EE:   NOT   animation "MISC" loaded    
004D: jump_if_false ££take3
0001: wait  0 ms
0002: jump ££take2

:take3
04C4: create_coordinate $x $y $z from_actor $PLAYER_ACTOR offset  0.0  1.0  0.0
02CE: $z = ground_z $x $y $z
00A1: put actor $homie($i,7i) at $x $y $z
0172: $angle = actor $PLAYER_ACTOR z_angle
000B: $angle +=  180.0;; floating-point values
0173: set_actor $homie($i,7i) z_angle_to $angle  
0605: unknown_action_sequence $homie($i,7i) "PASS_RIFLE_PED" "MISC"  4.0  0  0  0  0 -1
0470: $gun = actor $homie($i,7i) armed weapon unknown
041A: $ammo = actor $homie($i,7i) weapon $gun ammo
0555: remove_weapon $gun from_actor $homie($i,7i)
0605: unknown_action_sequence $PLAYER_ACTOR "PASS_RIFLE_PLY" "MISC"  4.0  0  0  0  0 -1
01B2: give_actor $PLAYER_ACTOR weapon $gun ammo $ammo;; Load the weapon model before using this

:switchnext1  
0001: wait  0 ms
00D6: if  1
00E1:   key pressed  0  7
0457:   player $PLAYER_CHAR aiming at actor $homie($i,7i)
004D: jump_if_false ££switchback1                

:switchnext2
0001: wait  0 ms
0008: $weapon +=  1;; integer values
00D6: if  0
0028:   $weapon >=  42;; integer values
004D: jump_if_false ££switchnext3
0004: $weapon = 0

:switchnext3
00D6: if  0
0491:   actor $homie($i,7i) has_weapon $weapon  
004D: jump_if_false ££switchnext2  
01B9: set_actor $homie($i,7i) armed_weapon_to $weapon  

:switchback1  
0001: wait  0 ms
00D6: if  1
00E1:   key pressed  0  5
0457:   player $PLAYER_CHAR aiming at actor $homie($i,7i)
004D: jump_if_false ££loop1                

:switchback2
0001: wait  0 ms
000E: $weapon -=  1;; integer values
00D6: if  0
8029:   NOT   $weapon >=  0;; integer values
004D: jump_if_false ££switchback3
0004: $weapon = 42

:switchback3
00D6: if  0
0491:   actor $homie($i,7i) has_weapon $weapon  
004D: jump_if_false ££switchback2  
01B9: set_actor $homie($i,7i) armed_weapon_to $weapon

:loop1  
0008: $i +=  1;; integer values  
00D6: if  0
0028:   $i >=  7;; integer values
004D: jump_if_false ££giventake2
0004: $i = 0
0002: jump ££giventake2


This post has been edited by MrTi on Thursday, Aug 18 2005, 02:48
PM
  Top
 

 
bajajahehehe  
Posted: Thursday, Jun 23 2005, 04:41
Quote Post


Punk-ass Bitch
Group Icon
Group: Members
Joined: Jun 19, 2005

jolly-roger.gif

XXXXX



cool but doesn't seem to work though...

This post has been edited by bajajahehehe on Thursday, Jun 23 2005, 05:50
PM
  Top
 

 
ICE COLD KILLA  
Posted: Thursday, Jun 23 2005, 09:48
Quote Post


Tssss
Group Icon
Group: Members
Joined: Nov 21, 2004

jolly-roger.gif

XXXXX



Where do u have to put that code??
PM
  Top
 

 
Opius  
Posted: Thursday, Jun 23 2005, 10:58
Quote Post


General
Group Icon
Group: Members
Joined: Jun 27, 2002

au.gif

Member Award




Very nice, but your code isn't exactly optimized. You could have just two checks, with each 'homey' as part of an array, with it looping through the array.
Untested example psuedo-code:

CODE
:giventake
0001: wait  0 ms            
00D6: if  0
0256:   player $PLAYER_CHAR defined  
004D: jump_if_false ££giventake
07AF: $gang = player $PLAYER_CHAR group
092B: $homie(0) = group $gang member 0  
092B: $homie(1)= group $gang member 1
092B: $homie(2)= group $gang member 2
092B: $homie(3)= group $gang member 3
092B: $homie(4)= group $gang member 4
092B: $homie(5)= group $gang member 5
092B: $homie(6)= group $gang member 6

:give1
0001: wait  0 ms
00D6: if  1
00E1:   key pressed  0  11
0457:   player $PLAYER_CHAR aiming at actor $homie($i);
004D: jump_if_false take1
0470: $gun = actor $PLAYER_ACTOR armed weapon unknown
041A: $ammo = actor $PLAYER_ACTOR weapon $gun ammo
01B2: give_actor $homie($i)weapon $gun ammo $ammo;; Load the weapon model before using this
0555: remove_weapon $gun from_actor $PLAYER_ACTOR
0002: jump ££loop1

:take1
0001: wait  0 ms
00D6: if  1
00E1:   key pressed  0  10
0457:   player $PLAYER_CHAR aiming at actor $homie($i)
004D: jump_if_false ££loop1  
0470: $gun = actor $homie($i)armed weapon unknown
041A: $ammo = actor $homie($i)weapon $gun ammo
01B2: give_actor $PLAYER_ACTOR weapon $gun ammo $ammo;; Load the weapon model before using this
0555: remove_weapon $gun from_actor $homie1

:loop1
00D6: if  0
$i == 6
004D: jump_if_false ££loop2
$i = 0
0002: jump giventake

:loop2
$i += 1
0002: jump giventake
Users WebsitePM
  Top
 

 
MrTi  
Posted: Thursday, Jun 23 2005, 17:48
Quote Post


Crackhead
Group Icon
Group: Members
Joined: Jun 7, 2003

us.gif

XXXXX



I tested it again, and it works for me.

To add the code, what I do is i put the
004F: create_thread ££giventake
with the rest of the create_threads

and i put my code at the very end of main, right above Mission 0.

Also to Opius, I tried the array approach, but I just didn't get it to work. dontgetit.gif

This post has been edited by MrTi on Thursday, Jun 23 2005, 21:00
PM
  Top
 

 
bajajahehehe  
Posted: Friday, Jun 24 2005, 04:16
Quote Post


Punk-ass Bitch
Group Icon
Group: Members
Joined: Jun 19, 2005

jolly-roger.gif

XXXXX



k works now like it
but the mp5 doesnt show up anymore when you shoot it but the dff and txd file in gta3 are still there. fix?
PM
  Top
 

 
officer purlaski  
Posted: Tuesday, Jun 28 2005, 22:14
Quote Post


Player Hater
Group Icon
Group: Members
Joined: Jun 27, 2005

XXXXX



can you just post your edited main.scm because i dont know how to put this code in therefore i cant use a great code
Users WebsitePMMSN
  Top
 

 
MrTi  
Posted: Wednesday, Jun 29 2005, 04:36
Quote Post


Crackhead
Group Icon
Group: Members
Joined: Jun 7, 2003

us.gif

XXXXX



heres my new more optimized code using arrays.
CODE
:giventake
0001: wait  0 ms
00D6: if  0  
0256:   player $PLAYER_CHAR defined
004D: jump_if_false ££giventake
0004: $i = 0
0004: $homie($i,7i) = 0

:giventake2
0001: wait  0 ms        
07AF: $gang = player $PLAYER_CHAR group
092B: $homie(0) = group $gang member 0  
092B: $homie(1) = group $gang member 1
092B: $homie(2) = group $gang member 2
092B: $homie(3) = group $gang member 3
092B: $homie(4) = group $gang member 4
092B: $homie(5) = group $gang member 5
092B: $homie(6) = group $gang member 6

:give1
0001: wait  0 ms
00D6: if  1
00E1:   key pressed  0  11
0457:   player $PLAYER_CHAR aiming at actor $homie($i,7i)
004D: jump_if_false ££take1
00D6: if  0  
00F2:   actor $homie($i,7i) near actor $PLAYER_ACTOR radius  5.0  5.0  0
004D: jump_if_false ££take1
04ED: load animation "MISC"

:give2
00D6: if  0
84EE:   NOT   animation "MISC" loaded    
004D: jump_if_false ££give3
0001: wait  0 ms
0002: jump ££give2

:give3  
04C4: create_coordinate $x $y $z from_actor $PLAYER_ACTOR offset  0.0  1.0  0.0
02CE: $z = ground_z $x $y $z
00A1: put actor $homie($i,7i) at $x $y $z
0172: $angle = actor $PLAYER_ACTOR z_angle
000B: $angle +=  180.0 ;; floating-point values
0173: set_actor $homie($i,7i) z_angle_to $angle
0605: unknown_action_sequence $PLAYER_ACTOR "PASS_RIFLE_PED" "MISC"  4.0  0  0  0  0 -1
0470: $gun = actor $PLAYER_ACTOR armed weapon unknown
041A: $ammo = actor $PLAYER_ACTOR weapon $gun ammo
0555: remove_weapon $gun from_actor $PLAYER_ACTOR
0605: unknown_action_sequence $homie($i,7i) "PASS_RIFLE_PLY" "MISC"  4.0  0  0  0  0 -1
01B2: give_actor $homie($i,7i) weapon $gun ammo $ammo;; Load the weapon model before using this  

:take1
0001: wait  0 ms
00D6: if  1
00E1:   key pressed  0  10
0457:   player $PLAYER_CHAR aiming at actor $homie($i,7i)
004D: jump_if_false ££loop1
00D6: if  0  
00F2:   actor $homie($i,7i) near actor $PLAYER_ACTOR radius  5.0  5.0  0
004D: jump_if_false ££loop1
04ED: load animation "MISC"

:take2
00D6: if  0
84EE:   NOT   animation "MISC" loaded    
004D: jump_if_false ££take3
0001: wait  0 ms
0002: jump ££take2

:take3
04C4: create_coordinate $x $y $z from_actor $PLAYER_ACTOR offset  0.0  1.0  0.0
02CE: $z = ground_z $x $y $z
00A1: put actor $homie($i,7i) at $x $y $z
0172: $angle = actor $PLAYER_ACTOR z_angle
000B: $angle +=  180.0 ;; floating-point values
0173: set_actor $homie($i,7i) z_angle_to $angle  
0605: unknown_action_sequence $homie($i,7i) "PASS_RIFLE_PED" "MISC"  4.0  0  0  0  0 -1
0470: $gun = actor $homie($i,7i) armed weapon unknown
041A: $ammo = actor $homie($i,7i) weapon $gun ammo
0555: remove_weapon $gun from_actor $homie($i,7i)
0605: unknown_action_sequence $PLAYER_ACTOR "PASS_RIFLE_PLY" "MISC"  4.0  0  0  0  0 -1
01B2: give_actor $PLAYER_ACTOR weapon $gun ammo $ammo;; Load the weapon model before using this

:loop1  
0008: $i +=  1;; integer values  
00D6: if  0
0038:   $i ==  7 ;; integer values
004D: jump_if_false ££giventake2
0004: $i = 0
0002: jump ££giventake2

i added an animation where it shows u giving the weapon, and i also made it that u cant give them the weapon from far away, so u have to get close. why? because i want it to be realistic colgate.gif

@officer purlaski
i'm too lazy to find a place to host it, so give me your email and i'll just send it to u.
PM
  Top
 

 
.:Shady:.  
Posted: Friday, Jul 8 2005, 16:18
Quote Post


...
Group Icon
Group: Members
Joined: Feb 22, 2003

XXXXX



Is there any way to change the buttons from "Y" and "N" to maybe left and right? I'm just wondering because I'd like to use this mod on Xbox and of course, the Xbox doesn't have "Y" and "N" keys smile.gif This looks like a really nice mod, though. Good work.
PMMSN
  Top
 

 
greddy5643  
Posted: Friday, Jul 8 2005, 23:27
Quote Post


Red Goose
Group Icon
Group: Members
Joined: May 15, 2005

us.gif

XXXXX



It uses yes/no buttons which is y/n by default on the pc for xbox those buttons would be right/left on dpad
PM
  Top
 

 
.:Shady:.  
Posted: Saturday, Jul 9 2005, 01:00
Quote Post


...
Group Icon
Group: Members
Joined: Feb 22, 2003

XXXXX



Thanks, greddy. I had no idea. Now to test this out on "Da Box."

EDIT: Okay, the mod works on the Xbox, but there's a small problem that isn't necessarily the mod's fault. I've noticed that once you've recruited a person and let go of the aim button, you can't aim at him anymore. But if you recruit a person and keep the aim button down, you can give or take a weapon one time. This is kinda disappointing when you wanna take something back, but maybe there's a way around this?

This post has been edited by .:Shady:. on Saturday, Jul 9 2005, 02:36
PMMSN
  Top
 

 
poohead  
Posted: Saturday, Jul 9 2005, 02:57
Quote Post


the gran poo-bah
Group Icon
Group: Members
Joined: Jun 23, 2003

cd.gif

XXXXX



u can host it at gtagarage, it seems very good biggrin.gif
PM
  Top
 

 
9ine  
Posted: Saturday, Jul 9 2005, 03:48
Quote Post


Random Quote
Group Icon
Group: Members
Joined: Nov 1, 2004

XXXXX



hey i know this isnt the right place to post this, but ive made a topic about this and people ignored it. the reason i choose to ask in this thread specifically is because u made a mod that involves switching peds guns. my question is do u know how i can set the guns that grove street families carry. like instead of a pistol is there a way to make it an ak47 without editing the scm files. again im really sorry for posting this here but i really was hoping somebody could answer this.
PM
  Top
 

 
Lorodrins  
Posted: Saturday, Jul 9 2005, 08:26
Quote Post


Player Hater
Group Icon
Group: Members
Joined: Jul 9, 2005

XXXXX



I can't this code get to work!!!
I put this code with SAMB 0.33 in main.scm, right above Mission 0
But when I compile it he give me an error:
004D: JUMP_IF_FALSE??GIVENTAKE
PARAMETER 1 not set

Help!I'm a newbie lol.gif
PM
  Top
 

 
.:Shady:.  
Posted: Tuesday, Jul 12 2005, 18:50
Quote Post


...
Group Icon
Group: Members
Joined: Feb 22, 2003

XXXXX



QUOTE (.:Shady:. @ Jul 8 2005, 18:00)
Thanks, greddy. I had no idea. Now to test this out on "Da Box."

EDIT: Okay, the mod works on the Xbox, but there's a small problem that isn't necessarily the mod's fault. I've noticed that once you've recruited a person and let go of the aim button, you can't aim at him anymore. But if you recruit a person and keep the aim button down, you can give or take a weapon one time. This is kinda disappointing when you wanna take something back, but maybe there's a way around this?

Is anyone else having this problem or is it just me?
PMMSN
  Top
 

 
DevelopeR  
Posted: Wednesday, Jul 13 2005, 07:06
Quote Post


Player Hater
Group Icon
Group: Members
Joined: Jul 11, 2005

XXXXX



Where can I add this code? In the end of decompiled main.scm? Or...?

This post has been edited by DevelopeR on Thursday, Jul 14 2005, 04:35
PM
  Top
 

 
poohead  
Posted: Thursday, Jul 14 2005, 16:57
Quote Post


the gran poo-bah
Group Icon
Group: Members
Joined: Jun 23, 2003

cd.gif

XXXXX



can u switch it with missions with sweet and ryder and big smoke and sh*t? like the robbin uncle sam mission, ryder has a dinky pistol, it b awsome to switch it with like a shot gun or somtin devil.gif
PM
  Top
 

 
dankstatus  
Posted: Saturday, Jul 23 2005, 02:15
Quote Post


Square Civilian
Group Icon
Group: Members
Joined: May 27, 2005

XXXXX



OK i have the mission builder but I have no idea where to put the code? I read his post about it and it didnt work for me.. I dont know what to do.. I can open the main.scm and edit it but I dont know what to do from there.. please help
PM
  Top
 

 
Dan!  
Posted: Saturday, Jul 23 2005, 02:23
Quote Post


Stinky Cheese Robot
Group Icon
Group: Members
Joined: Jul 30, 2004

XXXXX



QUOTE (.:Shady:. @ Jul 12 2005, 18:50)
QUOTE (.:Shady:. @ Jul 8 2005, 18:00)
Thanks, greddy.  I had no idea.  Now to test this out on "Da Box."

EDIT: Okay, the mod works on the Xbox, but there's a small problem that isn't necessarily the mod's fault.  I've noticed that once you've recruited a person and let go of the aim button, you can't aim at him anymore.  But if you recruit a person and keep the aim button down, you can give or take a weapon one time.  This is kinda disappointing when you wanna take something back, but maybe there's a way around this?

Is anyone else having this problem or is it just me?

As far as I know you can't aim at people you've recruited. You can always "unrecruit" them and then recruit them and give n' take again, though.
PM
  Top
 

 
dankstatus  
Posted: Saturday, Jul 23 2005, 02:24
Quote Post


Square Civilian
Group Icon
Group: Members
Joined: May 27, 2005

XXXXX



Dan, do you know anything about my question? Thnx
PM
  Top
 

 

0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)

0 Members:

Pages: (2) [1] 2 

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG