You are viewing our Forum Archives. To view or take place in current topics click here.
Mw2 Pick Up Guns [Code Release]
Posted:

Mw2 Pick Up Guns [Code Release]Posted:

Nissan
  • Ultra Gifter
Status: Offline
Joined: Sep 20, 201211Year Member
Posts: 2,136
Reputation Power: 312
Status: Offline
Joined: Sep 20, 201211Year Member
Posts: 2,136
Reputation Power: 312
Well i'm not motivated to finish this project so i have decided to release the picking up guns :




i wasn't going to post this but hell with it. i haven't seen anyone post this so here it is :




void DistanceText(){
    for(int i = 0;i<18;i++){
        float*PlayerPosition = (float*)(getPlayerState(i) + 0x1C);
        if(DistanceText(PlayerPosition,Intervention) <5){
        setText(Hud[clientIndex].DistanceText, "Press [{+usereload}] To Swap Weapon To Intervention", 3, 1.2, 85, 150, 0x05, 1.0);
        break;
    }else{
            setText(Hud[clientIndex].DistanceText, "", 3, 1.2, 85, 150, 0x05, 1.0);
            break;
        }
    }
}





if(KeyDown(s, BUTTON_X)){
        float*PlayerPosition = (float*)(getPlayerState(clientIndex) + 0x1C);
        if(Distance(PlayerPosition, Intervention,KeyDown(s, "n 11")) < 5){
                float*PlayerPosition = (float*)(getPlayerState(clientIndex) + 0x1C);
                GiveWeap(clientIndex,"cheytac_fmj_xmags_mp",false,true,true, 7);
        }
    }





Things you will need to find yourself :

    XamInputGetStateAsm
    XamInputGetStateHook
    Vec3DistanceSq
    Distance





Im not going to give you everything use google its all easy to find.
and yes the code is really really bad i know i'm still learning so dont hate because the code is messy.

Enjoy it ;)

The following 4 users thanked Nissan for this useful post:

Reaper_TTG (08-17-2014), xChillest (08-16-2014), CPR (08-16-2014), 1993 (08-15-2014)
#2. Posted:
DarkVoyageModding
  • New Member
Status: Offline
Joined: Jul 17, 20149Year Member
Posts: 36
Reputation Power: 1
Status: Offline
Joined: Jul 17, 20149Year Member
Posts: 36
Reputation Power: 1
Very Nice Release my friend hh)
#3. Posted:
XeSao
  • New Member
Status: Offline
Joined: Aug 13, 20149Year Member
Posts: 8
Reputation Power: 0
Status: Offline
Joined: Aug 13, 20149Year Member
Posts: 8
Reputation Power: 0
RGHJTAGZ wrote
void DistanceText(){
    for(int i = 0;i<18;i++){
        float*PlayerPosition = (float*)(getPlayerState(i) + 0x1C);
        if(DistanceText(PlayerPosition,Intervention) <5){
        setText(Hud[clientIndex].DistanceText, "Press [{+usereload}] To Swap Weapon To Intervention", 3, 1.2, 85, 150, 0x05, 1.0);
        break;
    }else{
            setText(Hud[clientIndex].DistanceText, "", 3, 1.2, 85, 150, 0x05, 1.0);
            break;
        }
    }
}

if(KeyDown(s, BUTTON_X)){
        float*PlayerPosition = (float*)(getPlayerState(clientIndex) + 0x1C);
        if(Distance(PlayerPosition, Intervention,KeyDown(s, "n 11")) < 5){
                float*PlayerPosition = (float*)(getPlayerState(clientIndex) + 0x1C);
                GiveWeap(clientIndex,"cheytac_fmj_xmags_mp",false,true,true, 7);
        }
    }


Why are you using a break in that for loop ? It would only break the all client loop.
you are also defining PlayerPosition twice in the second function
But a good share i guess
#4. Posted:
Nissan
  • Ultra Gifter
Status: Offline
Joined: Sep 20, 201211Year Member
Posts: 2,136
Reputation Power: 312
Status: Offline
Joined: Sep 20, 201211Year Member
Posts: 2,136
Reputation Power: 312
XeSao wrote
RGHJTAGZ wrote
void DistanceText(){
    for(int i = 0;i<18;i++){
        float*PlayerPosition = (float*)(getPlayerState(i) + 0x1C);
        if(DistanceText(PlayerPosition,Intervention) <5){
        setText(Hud[clientIndex].DistanceText, "Press [{+usereload}] To Swap Weapon To Intervention", 3, 1.2, 85, 150, 0x05, 1.0);
        break;
    }else{
            setText(Hud[clientIndex].DistanceText, "", 3, 1.2, 85, 150, 0x05, 1.0);
            break;
        }
    }
}

if(KeyDown(s, BUTTON_X)){
        float*PlayerPosition = (float*)(getPlayerState(clientIndex) + 0x1C);
        if(Distance(PlayerPosition, Intervention,KeyDown(s, "n 11")) < 5){
                float*PlayerPosition = (float*)(getPlayerState(clientIndex) + 0x1C);
                GiveWeap(clientIndex,"cheytac_fmj_xmags_mp",false,true,true, 7);
        }
    }


Why are you using a break in that for loop ? It would only break the all client loop.
you are also defining PlayerPosition twice in the second function
But a good share i guess


thanks and i tried it alot of ways and thats the only way i could get to work so i just struck with it lol feel free to change it so its better
#5. Posted:
DynastyMods
  • Junior Member
Status: Offline
Joined: Aug 08, 20149Year Member
Posts: 70
Reputation Power: 5
Status: Offline
Joined: Aug 08, 20149Year Member
Posts: 70
Reputation Power: 5
I've known RGHJTAGZ for a while now, he's probably one of the best people on TTG. He's amazing, my idol. I'd love to become like him! This is again, another great release! Keep it up, maybe I'll take off where you left? ;)
#6. Posted:
Fwizbee
  • 2 Million
Status: Offline
Joined: Dec 02, 201013Year Member
Posts: 321
Reputation Power: 23
Status: Offline
Joined: Dec 02, 201013Year Member
Posts: 321
Reputation Power: 23
Good Release
Thanks for helping out the Community.
#7. Posted:
XeSao
  • New Member
Status: Offline
Joined: Aug 13, 20149Year Member
Posts: 8
Reputation Power: 0
Status: Offline
Joined: Aug 13, 20149Year Member
Posts: 8
Reputation Power: 0
Spawn the Elem when you connect:

setText(Hud[Client].DistanceText, "", 3, 1.2, 85, 150, 0x5, 1.0);

void DistanceWeapon(float *WeaponPosition, char *Weapon, char *WeaponInfo)
{
   for(int i=0;i<18;i++)
   {
      if(Vec3DistanceSq(WeaponPosition, (float*)(PlayerState(i) + 0x1C)) < 5*5 && !Hud[i].DistanceText->elem.text)
      {
         Hud[i].DistanceText->elem.text = G_LocalizedStringIndex(va("Press [{+userload}] To Swap Weapon To %s", WeaponInfo));
         if(Key_IsDown(i) & BUTTON_X)
         {
            GiveWeap(i, Weapon ,false,true,true, 7);
         }
      }
      else
      {
         if(Hud[i].DistanceText->elem.text != 0)
            Hud[i].DistanceText->elem.text = 0;
      }
   }
}

I wrote this in notepad
You can also just put it in the XamLoop

Edit: I noticed that i did something wrong. But i got it fixed now
How to use:
float Position[3] = { 305, 455, 237 };
DistanceWeapon(&Position, "cheytac_mp", "Intervention");
#8. Posted:
Nissan
  • Ultra Gifter
Status: Offline
Joined: Sep 20, 201211Year Member
Posts: 2,136
Reputation Power: 312
Status: Offline
Joined: Sep 20, 201211Year Member
Posts: 2,136
Reputation Power: 312
XeSao wrote Spawn the Elem when you connect:

setText(Hud[Client].DistanceText, "", 3, 1.2, 85, 150, 0x5, 1.0);

void DistanceWeapon(float *WeaponPosition, char *Weapon, char *WeaponInfo)
{
   for(int i=0;i<18;i++)
   {
      if(Vec3DistanceSq(WeaponPosition, (float*)(PlayerState(i) + 0x1C)) < 5*5 && !Hud[i].DistanceText->elem.text)
      {
         Hud[i].DistanceText->elem.text = G_LocalizedStringIndex(va("Press [{+userload}] To Swap Weapon To %s", WeaponInfo));
         if(Key_IsDown(i) & BUTTON_X)
         {
            GiveWeap(i, Weapon ,false,true,true, 7);
         }
      }
      else
      {
         if(Hud[i].DistanceText->elem.text != 0)
            Hud[i].DistanceText->elem.text = 0;
      }
   }
}

I wrote this in notepad
You can also just put it in the XamLoop

Edit: I noticed that i did something wrong. But i got it fixed now
How to use:
float Position[3] = { 305, 455, 237 };
DistanceWeapon(&Position, "cheytac_mp", "Intervention");


i'm still learning so my code isn't the best but thanks for re-righting it to make it better
#9. Posted:
UnknownC0der
  • New Member
Status: Offline
Joined: Aug 10, 20149Year Member
Posts: 21
Reputation Power: 1
Status: Offline
Joined: Aug 10, 20149Year Member
Posts: 21
Reputation Power: 1

int BG_GetWeaponDef(int weapId)
{
      return *(int*)(0x8255A320 + (weapId * 4));
}

int getWorldXModel(int weapId, int variant=0)
{
     return *(int*)(BG_GetWeaponDef(weapId) + (0x1D0+(variant*4)));
}

char*getWeaponModel(char*weaponName, int variant=0)
{
     return (char*)(getWorldXModel(G_GetWeaponIndexForName(weaponName), variant));
}

float distance(float*v1, float*v2)
{
   return sqrt((v1[0]-v2[0])*(v1[0]-v2[0])+(v1[1]-v2[1])*(v1[1]-v2[1])+(v1[2]-v2[2])*(v1[2]-v2[2]));
}

int spawnWeapon(char*weaponName, float*origin)
{
     int weap = G_Spawn();
     *(short*)(weap + 0x172) = *(short*)(weap + 0x174) = 0x11E4;
     for(int i = 0, f = 0; i < 3; i++, f += 4)
     {
            *(float*)(weap+(0x138+f)) = oriign[i];
     }
     *(short*)(weap + 0x168) = G_ModelIndex(getWeaponModel(weaponName));
     sp_script_model(weap);
     return weap;
}


Then you can just do a simple distance check between a players origin, and the weapons origin. Checking if distance is less than 50 is when the player is pretty much on top if not around a small radius of the location. Then you can simply give the weapon, give ammo for that weapon and then switch to the weapon. You could have add a boolean parameter for if you want to delete the weapon after it's been taken, You can just call G_FreeEntity since it has support for all types of entities.
#10. Posted:
DarkVoyageModding
  • New Member
Status: Offline
Joined: Jul 17, 20149Year Member
Posts: 36
Reputation Power: 1
Status: Offline
Joined: Jul 17, 20149Year Member
Posts: 36
Reputation Power: 1
UnknownC0der wrote

int BG_GetWeaponDef(int weapId)
{
      return *(int*)(0x8255A320 + (weapId * 4));
}

int getWorldXModel(int weapId, int variant=0)
{
     return *(int*)(BG_GetWeaponDef(weapId) + (0x1D0+(variant*4)));
}

char*getWeaponModel(char*weaponName, int variant=0)
{
     return (char*)(getWorldXModel(G_GetWeaponIndexForName(weaponName), variant));
}

float distance(float*v1, float*v2)
{
   return sqrt((v1[0]-v2[0])*(v1[0]-v2[0])+(v1[1]-v2[1])*(v1[1]-v2[1])+(v1[2]-v2[2])*(v1[2]-v2[2]));
}

int spawnWeapon(char*weaponName, float*origin)
{
     int weap = G_Spawn();
     *(short*)(weap + 0x172) = *(short*)(weap + 0x174) = 0x11E4;
     for(int i = 0, f = 0; i < 3; i++, f += 4)
     {
            *(float*)(weap+(0x138+f)) = oriign[i];
     }
     *(short*)(weap + 0x168) = G_ModelIndex(getWeaponModel(weaponName));
     sp_script_model(weap);
     return weap;
}


Then you can just do a simple distance check between a players origin, and the weapons origin. Checking if distance is less than 50 is when the player is pretty much on top if not around a small radius of the location. Then you can simply give the weapon, give ammo for that weapon and then switch to the weapon. You could have add a boolean parameter for if you want to delete the weapon after it's been taken, You can just call G_FreeEntity since it has support for all types of entities.


oh look its Kyza on TTG now lol!
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.