quarta-feira, 13 de dezembro de 2017

[Functions] source code functions

First in introduction might be in order 

I'm KiLLerboy_001 Pretty wel known in PS3's modding community for GTA 5 back in the days Memory editing
and menu creation 
  


Now recently i achieved a PC copy of GTA 5 and went to check out the menus just to see some missing features, These will be converted to C++ type of code. 
Since i cant install visual studio on my current copy of windows ( not sure why it just fails ) ill just share my code snippets hoping that somebody can include them.





Drive on water
Code:
//-----------------  Drive on water  -----------------
//Uses an extra bool called: FolowWaves, With this set to True it will Follow the waves perfectly When set on False it will Not
//
//Since both functions GET_WATER_HEIGHT_NO_WAVES & GET_WATER_HEIGHT only return a value over ocean or Alamo Sea.
//I also included a backdrop meaning if no current value is found it will always use the last found one.
//
//----------------------------------------------------
 
 
 
 
InitiateDrive()
{
   int WaterObject = CREATE_OBJECT("prop_huge_display_01",--------------------------
   SET_ENTITY_ROTATION(WaterObject,90,0,0,2,1)
   FREEZE_ENTITY_POSITION(WaterObject,1)
   SET_ENTITY_VISIBLE(WaterObject,0)
};
 
 
DriveLoop()
{
   Vector3 PlayerCoord = GET_ENTITY_COORDS(PLAYER_PED_ID(),1)
   float xPlane PlayerCoord.X
   float yPlane PlayerCoord.Y
   if (FolowWaves==true)
   {
      GET_WATER_HEIGHT(GET_ENTITY_COORDS(PLAYER_PED_ID()  ,1),float *NewZ)
      if (NewZ < -100)
      {
          float zPlane = LastZ
      }
      else
      {
         float zPlane = NewZ
         float LastZ = NewZ
      }
   }
   else
   {
      GET_WATER_HEIGHT_NO_WAVES(GET_ENTITY_COORDS(PLAYER  _PED_ID(),1),float *NewZ)
      if (NewZ < -100)
      {
          float zPlane = LastZ
      }
      else
      {
         float zPlane = NewZ
         float LastZ = NewZ
      }  
   }
   Vector3 Coord(xPlane, yPlane, zPlane)
   SET_ENTITY_COORDS(WaterObject,1,0,0,1)
};




Magic Carpet ( walk in air )
  

Code:
//-----------------  Magic Carpet  -----------------
//
//Nothing special Do check IS_CONTROL_PRESSED numbers though
//
//--------------------------------------------------
 
InitiateMagicCarpet()
{
   int MagicCarpetObject = CREATE_OBJECT("p_oil_slick_01",--------------------------
   FREEZE_ENTITY_POSITION(MagicCarpetObject,1)
   SET_ENTITY_VISIBLE(MagicCarpetObject,0)
};
 
MagicCarpetLoop()
{
   Vector3 PlayerCoord = GET_ENTITY_COORDS(PLAYER_PED_ID(),1)
   float xPlane PlayerCoord.X
   float yPlane PlayerCoord.Y
 
   float Normal = 1.0225
   float Down = 1.6
   float Up = 0.4
   float Vehicular 2000.0
 
   if (IS_PED_IN_ANY_VEHICLE(PLAYER_PED_ID(),0) //in Car
   {
      zPlane = PlayerCoord.Z - Vehicular
   }
   elseif (IS_CONTROL_PRESSED(2,36) == true )   //Down
   {
      zPlane = PlayerCoord.Z - Down
   }
   elseif (IS_CONTROL_PRESSED(2,26) == true )   //Up
   {
      zPlane = PlayerCoord.Z - Up
   }
   else                                         //Normal
   {
      zPlane = PlayerCoord.Z - Normal
   }
 
   Vector3 Coord(xPlane, yPlane, zPlane)
   SET_ENTITY_COORDS(MagicCarpetObject,1,0,0,1)
}




Sentry Gun (Spawns a gun that auto fires at targets and kills them in your name )
  

Code:
//-----------------  Sentry Gun  -----------------
//
//Includes a Variable TargetName[] that can be used to either display targeted players name or just "Vehicle"
//Configurable timeout on variable Called:Timeout
//Configurable weapon on variable Called:WeaponID  (https://www.*********.com/forums/threads/weapon-and-explosion-hashes-list.1045035/)
 
//You can switch Players as target with bool:PlayerTarget
//you can switch Vehicles as targets with bool:VehicleTarget
//Vehicles always get priority over players
//------------------------------------------------
 
 
float GetPointToPointRotation(Source,Target)
{
   return ATAN2((Target.y - Source.y),(Target.x - Source.x));
}
 
 
InitiateSentryGun()
{
   int SentryObject = CREATE_OBJECT("p_rcss_folded",--------------------------
   int Timeout = 500
   Timer = GET_GAME_TIMER() + Timeout
}
 
int GetClosestVehicle(Vector3 Coords,float Distance)
{
   Flag = 64;    
   Flag |= 65536;    
   Flag |= 2048;    
   Flag |= 1;    
   Flag |= 2;    
   Flag |= 4;  
   Flag |= 32;  
   Flag |= 16;    
   Flag |= 8;
   return GET_CLOSEST_VEHICLE(Coords,Distance,0,Flag)
}
 
SentryGunLoop()
{
   If (PlayerTarget == True )
   {
      int TargetID = GET_PLAYER_PED(GET_NEAREST_PLAYER_TO_ENTITY(Sentry  Object));
      char TargetName[] = GET_PLAYER_NAME(TargetID);
      if (TargetID == PLAYER_PED_ID())
      {
         //Dont Shoot Myself
      }
      else
      {
 
      }
   }
 
   If (VehicleTarget == True )
   {
      int TargetID = GetClosestVehicle(GET_ENTITY_COORDS(SentryObject,1  ),75);
      char TargetName[] = "Vehicle";
      if (IS_PED_IN_ANY_VEHICLE(PLAYER_PED_ID(),0) == True );
      {
         VehID = GET_VEHICLE_PED_IS_IN(PLAYER_PED_ID(),0);
         if (TargetID == VehID)
         {
            //Dont Shoot Myself
         }
         else
         {
         }
      }
      else
      {
 
      }
   }
   
   //Rotate and draw
   float Rotation = GetPointToPointRotation(SentryObject,TargetID) + 90
   SET_ENTITY_ROTATION(SentryObject,0,0,Rotation)
   DRAW_LINE(GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(S  entryObject,0,-0.2,0.57),GET_ENTITY_COORDS(TargetID,1),255,0,0,0)
 
   //Time to Kill
   if (GET_GAME_TIMER() >= Timer)
   {     SHOOT_SINGLE_BULLET_BETWEEN_COORDS(GET_OFFSET_FROM  _ENTITY_IN_WORLD_COORDS(SentryObject,0,-0.8,0.6),GET_ENTITY_COORDS(TargetID,1)250,0,Weapon  ID,PLAYER_PED_ID(),1,0,float 1.0)
        PLAY_SOUND_FROM_ENTITY(-1,"Remote_Sniper_Rifle_Fire",SentryObject,"",0,0)
   
        Timer = GET_GAME_TIMER() + Timeout  //500 Milisec between shots
   }
}




Rapid fire ( Turn anything into a minigun )
Code:
//-----------------  Rapid Fire  -----------------
 
 
#include <math.h>
 
RapidFireLoop()
{
   if ( (RapidfireActive == true) && (IS_PED_IN_ANY_VEHICLE(PLAYER_PED_ID(),1)==False) && (IS_CONTROL_PRESSED(2,199) && (GET_GAME_TIMER()>=Timeout) )
   {
      FromCoord = GET_PED_BONE_COORDS(PLAYER_PED_ID(),57005,0,0,0)
      ToCoord = GetCoordsInfrontOfCam(75)
      GET_CURRENT_PED_WEAPON(PLAYER_PED_ID,*WeaponID,0)
      SHOOT_SINGLE_BULLET_BETWEEN_COORDS(FromCoord,ToCoo  rd,250,0,WeaponID,PLAYER_PED_ID(),1,0,1)
      Timeout = GET_GAME_TIMER() + 50
   }
}
 
Vector3 GetCoordsInfrontOfCam(float distance)
{
   Vector3 GameplayCamRot = GET_GAMEPLAY_CAM_ROT(2);
   Vector3 GameplayCamCoord = GET_GAMEPLAY_CAM_COORD();
 
   float tan = Cos(GameplayCamRot.X) * distance);
   float xPlane = Sin(GameplayCamRot.Z * -1.0f) * tan) + GameplayCamCoord.X);
   float yPlane = Cos(GameplayCamRot.Z * -1.0f) * tan) + GameplayCamCoord.Y);
   float zPlane = Sin(GameplayCamRot.X) * distance) + GameplayCamCoord.Z);
 
   return new Vector3(xPlane, yPlane, zPlane);
}




Show talking players
Code:
//-----------------  Talking players  -----------------
//
// Just enable TalkingPlayers Bool and make sure that Talking[] text gets added onscreen somewhere
//-----------------------------------------------------
 
 
 
TalkingPlayerLoop()
{
   if (TalkingPlayers==true)
   {
      for (int i = 0; i < 32; ++i)
      {
         if (NETWORK_IS_PLAYER_TALKING(i) == true )
         {
            char Talking[] = GET_PLAYER_NAME(i)
            //Add code here to make the Talking[] entry be pushed to screen
         }
         i++;
      }
   }
}




Dragon mode ( Fire breather )
Code:
//-----------------  Dragon Mode  -----------------
//
// Just enable DragonMode Bool
//-----------------------------------------------------
 
 
FireManModeLoop()
{
   if ( DragonMode == true )
   {
      Vector3 Mouth = GET_PED_BONE_COORDS(PLAYER_PED_ID(), 39317, 0.1f , 0.0f, 0.0f)
      _ADD_SPECFX_EXPLOSION(Mouth.x,Mouth.y,Mouth.z, EXPLOSION_DIR_FLAME, EXPLOSION_DIR_FLAME, 1.0f, true, true, 0.0f)
   }
}




Object Removal + advanced gravity gun
Code:
// REQUiRMENTS
 
 
Vector3 GetCoordsInfrontOfCam(float distance)
{
   Vector3 GameplayCamRot = GET_GAMEPLAY_CAM_ROT(2);
   Vector3 GameplayCamCoord = GET_GAMEPLAY_CAM_COORD();
 
   float tan = Cos(GameplayCamRot.X) * distance);
   float xPlane = Sin(GameplayCamRot.Z * -1.0f) * tan) + GameplayCamCoord.X);
   float yPlane = Cos(GameplayCamRot.Z * -1.0f) * tan) + GameplayCamCoord.Y);
   float zPlane = Sin(GameplayCamRot.X) * distance) + GameplayCamCoord.Z);
 
   return new Vector3(xPlane, yPlane, zPlane);
}
 
 
 
//-----------------  Remove targetted Objects  -----------------
//
// Just enable RemoveObjects Bool and shoot an object to remove it ( Client Sided )
//
//-----------------------------------------------------
 
 
RemoveObjectsLoop()
{
   if ( (RemoveObjects == true) && (IS_CONTROL_PRESSED(2,199) )
   {
      GET_ENTITY_PLAYER_IS_FREE_AIMING_AT(PLAYER_ID(),*E  ntityID)
      if (IS_ENTITY_AN_OBJECT(EntityID) == true )
      {
         DELETE_ENTITY(*EntityID)
      }
   }
}
 
 
//-----------------  Gravity gun ( Pickup and launch )  -----------------
//
// Just enable GravityGun Bool and shoot an object to pick it up shoot again to launch it
//
// When object is picked up it makes it see through and undoes this when launched ( object moves infront of you when picked up )
// ObjectHash[] can be used to display Hash of picked up object ( usefull for spawning uknown object Best display this in lower left under radar )
//
//-----------------------------------------------------
 
Bool Pickup = true
 
GravityGunLoop()
{
   if (GravityGun == true)
   {
      if ( (Pickup == true) && (IS_CONTROL_PRESSED(2,199) )
      {
         Pickup = false
         GET_ENTITY_PLAYER_IS_FREE_AIMING_AT(PLAYER_ID(),*E  ntityID)
         if (IS_ENTITY_A_PED(EntityID) == true)
         {
            if (IS_PED_IN_ANY_VEHICLE(EntityID,0))
            {
               EntityID = GET_VEHICLE_PED_IS_IN(EntityID,0)
            }
         }
         SET_ENTITY_ALPHA(EntityID,200)
      }
      elseif ( (Pickup == false) && (IS_CONTROL_PRESSED(2,199) )
      {
         Pickup = true
         if (IS_ENTITY_A_PED(EntityID) == true )
         {
            SET_ENTITY_DYNAMIC(EntityID,1)
            Vector3 Rotation = GET_ENTITY_ROTATION(EntityID,2)
            SET_ENTITY_ROTATION(EntityID,GET_GAMEPLAY_CAM_ROT(  2),2,1)
            APPLY_FORCE_TO_ENTITY(EntityID,1,0,150,0,0,0,0,0,1  ,1,1,0,1)
            SET_ENTITY_ROTATION(EntityID,Rotation,2,1)
            SET_ENTITY_ALPHA(EntityID,255)
         }
      }
      else
      {
         if (DOES_ENTITY_EXIST(EntityID)==true)
         {
            Char ObjectHash[] = GET_ENTITY_MODEL(EntityID)
            SET_ENTITY_COORDS(EntityID,GetCoordsInfrontOfCam(1  0),1,0,0,1)
         }
      }
   }
}




Advanced Flying car( Has rudder rotation like planes )
Code:
//-----------------  Flying Car  -----------------
//
// Just enable the FlyingCar Bool
//
// Double check the Numerics for IS_CONTROL_PRESSED
//-----------------------------------------------------
 
FlyingCarLoop ()
{
   if (IS_PED_IN_ANY_VEHICLE(PLAYER_PED_ID,0))
   {
      int Vehid = GET_VEHICLE_PED_IS_IN(PLAYER_PED_ID,0)
     
      if (IS_CONTROL_PRESSED(2,67) ==true ) //Forward
      {
         float Speed = GET_ENTITY_SPEED(Vehid) + 0.5
         SET_VEHICLE_FORWARD_SPEED(Vehid,Speed)
      }
 
      if ( (IS_CONTROL_PRESSED(2,196) ==true) && ( ! IS_VEHICLE_ON_ALL_WHEELS(Vehid) ) //Left
      {
         Vector3 Rot = GET_ENTITY_ROTATION(Vehid,2)
         Rot.z = Rot.z + 1.0
         newRot Vector3(Rot.x, Rot.y, Rot.z)
         SET_ENTITY_ROTATION(Vehid,newRot,2,1)
      }
 
      if ( (IS_CONTROL_PRESSED(2,197) ==true) && ( ! IS_VEHICLE_ON_ALL_WHEELS(Vehid) ) //Right
      {
         Vector3 Rot = GET_ENTITY_ROTATION(Vehid,2)
         Rot.z = Rot.z - 1.0
         newRot Vector3(Rot.x, Rot.y, Rot.z)
         SET_ENTITY_ROTATION(Vehid,newRot,2,1)
      }
   }
}

If You saw any other interesting thing in the video just asks me about it and i will supply like the Plane_crash_trench Plane object coords + rotation etc any other info youll need ill supply.

Also be sure to check out my pastebin https://pastebin.com/u/KiLLerBoy_001 has a lot of snippets / extra info there



P.S: All i asks is to be creditted for these here snippets if you chose on using them even be it partially


just some fun ( Alien egg money ) 

0 comentários:

Postar um comentário