This will be a rather long thread since i created a few functions in my days.
Since these are converted from ASM ( Scripting language )
Some of these might need reworking but youll get the idea..
First are some basic Required Functions
GetCoordsInfrontOfCam
[HIDE]
Vector3 GetCoordsInfrontOfCam(float distance) //GetCoordAimingAhead { vector3 GameplayCamRot = CAM::GET_GAMEPLAY_CAM_ROT(2); vector3 GameplayCamCoord = CAM::GET_GAMEPLAY_CAM_COORD(); float tan = cos(GameplayCamRot.y) * distance; float xPlane = (sin(GameplayCamRot.z * -1.0f) * tan) + GameplayCamCoord.y; float yPlane = (cos(GameplayCamRot.z * -1.0f) * tan) + GameplayCamCoord.y; float zPlane = (sin(GameplayCamRot.y) * distance) + GameplayCamCoord.z; vector3 Output; Output.x = xPlane; Output.y = yPlane; Output.z = zPlane; return Output; }
[/HIDE]
Create Object
[HIDE]
object Create_Object(const char* ObjectName, Vector3 Coordinates) { int ObjectHash = GAMEPLAY::GET_HASH_KEY(ObjectName); if (STREAMING::IS_MODEL_IN_CDIMAGE(ObjectHash)) { if (STREAMING::IS_MODEL_VALID(ObjectHash)) { do { STREAMING::REQUEST_MODEL(ObjectHash); } while (! STREAMING::HAS_MODEL_LOADED(ObjectHash)) if (STREAMING::HAS_MODEL_LOADED(ObjectHash)) { return = OBJECT::CREATE_OBJECT(ObjectHash, Coordinates.x,Coordinates.y,Coordinates.z, 1, 1, 0, 0, 1); } else { // Error model didnt load properly. } } } }
[/HIDE]
Now for the Fun / effective stuff
Advanced Flying Car
[HIDE]
//----------------- 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)) //Forward { float Speed = GET_ENTITY_SPEED(Vehid) + 0.5 SET_VEHICLE_FORWARD_SPEED(Vehid,Speed) } if ( (IS_CONTROL_PRESSED(2,196) && ( ! IS_VEHICLE_ON_ALL_WHEELS(Vehid) ) //Turn 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) && ( ! IS_VEHICLE_ON_ALL_WHEELS(Vehid) ) //Turn 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) } } }
[/HIDE]
Object Removal + Advanced Gravity Gun
[HIDE]
//----------------- Remove targetted Objects ----------------- // // Just enable RemoveObjects Bool and shoot an object to remove it ( Client Sided ) // Requires// //----------------------------------------------------- RemoveObjectsLoop() { if ( (RemoveObjects == true) && (IS_CONTROL_PRESSED(2,199) ) { GET_ENTITY_PLAYER_IS_FREE_AIMING_AT(PLAYER_ID(),*EntityID) 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(),*EntityID) 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(10),1,0,0,1) } } } }[MEDIA=pastebin]8mjesvm0[/MEDIA]
[/HIDE]
Breath Fire ( Dragon Mode )
[HIDE]
//----------------- 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) } }
[/HIDE]
Never raise mental state ( includes random timer = harder to detect )
[HIDE]
[HASHTAG]#include[/HASHTAG] /* srand, rand */ [HASHTAG]#include[/HASHTAG] /* time */ NeverRaiseMentalLoop() { if ( (NeverRaiseMental==true) && (GAMEPLAY::GET_GAME_TIMER() >= Timer) ) { STATS::STAT_SET_FLOAT(GAMEPLAY::GET_HASH_KEY("MP0_PLAYER_MENTAL_STATE"),0.1,1) srand (time(NULL)); Timer = (GAMEPLAY::GET_GAME_TIMER() + rand() % 10000 + 5000) // between 5 or 10 secs timeout } }
[/HIDE]
Talking Players
[HIDE]
//----------------- Talking players ----------------- // // Just enable TalkingPlayers Bool and make sure that Talking cahr* gets added onscreen somewhere //----------------------------------------------------- [HASHTAG]#include[/HASHTAG] TalkingPlayerLoop() { if (TalkingPlayers) { for (int i = 0; i= < 32; ++i) { if (NETWORK::NETWORK_IS_PLAYER_TALKING(i) == true ) { char* Talking = GET_PLAYER_NAME(i); //Add code here to make the Talking entry be pushed to screen } } } }
[/HIDE]
Rapid Fire ( Any and every gun turns into minigun doesnt require ammo )
[HIDE]
//----------------- Rapid Fire ----------------- // // RapidfireActive Bool used for activation // RFBetweenRounds can be changed through menu to change time between rounds // //------------------------------------------------ [HASHTAG]#include[/HASHTAG] int RFTimeout; int RFBetweenRounds = 50; RapidFireLoop() { hash WeaponID; if ( (RapidfireActive == true) && (PED::IS_PED_ON_FOOT(PLAYER::pLAYER_PED_ID()) && (PED::IS_PED_SHOOTING(PlayerPed)) && (GAMEPLAY::GET_GAME_TIMER()>=RFTimeout) ) { Vector3 FromCoord = PED::GET_PED_BONE_COORDS(PLAYER::pLAYER_PED_ID(),57005,0,0,0); Vector3 ToCoord = GetCoordsInfrontOfCam(75); WEAPON::GET_CURRENT_PED_WEAPON(PLAYER::pLAYER_PED_ID(),&WeaponID,0); GAMEPLAY::SHOOT_SINGLE_BULLET_BETWEEN_COORDS(FromCoord.x,FromCoord.y,FromCoord.z,ToCoord.x,ToCoord.y,ToCoord.z,250,0,WeaponID,PLAYER::pLAYER_PED_ID(),1,0,1); int RFTimeout = GAMEPLAY::GET_GAME_TIMER() + RFBetweenRounds; } }
[/hide]
Sentry Gun ( Auto firing / killing turret )
[Hide]
//----------------- 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 ( http://www.se7ensins.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 //------------------------------------------------ //Create Variables object SentryID = 0; int Timeout = 500; // Time between shots. int Timer; object TargetID= 0; float Rotation = 0; bool PlayerTarget = true; bool VehicleTarget = true; hash WeaponID= GET_HASH_KEY("WEAPON_MG"); // this can be changed to any weapon offcourse // REQUIRED FUNCTIONS ---------------------------------------- float GetHeadingFromCoords(Vector3 Source, Vector3 Target); { return ATAN2((Target.y - Source.y),(Target.x - Source.x)); } object GetClosestVehicle(Vector3 Coords,float Distance); { Flag = 64; Flag |= 65536; Flag |= 2048; Flag |= 1; Flag |= 2; Flag |= 4; Flag |= 32; Flag |= 16; Flag |= 8; Flag |= 71; return GET_CLOSEST_VEHICLE(Coords.x,Coords.y,Coords.z,Distance,0,Flag) } /---------------------------------------------------------------- SentryGunLoop() /This need to be looped { object MagicCarpetObject; vector3 PlayerCoord = ENTITY::GET_ENTITY_COORD(playerPed,1); if ((! ENTITY::DOES_ENTITY_EXIST(SentryID)) && (SentryActive)) { SentryID = Create_Object("p_oil_slick_01",PlayerCoord.x,PlayerCoord.y,PlayerCoord.z); Timer = GAMEPLAY::GET_GAME_TIMER() + Timeout; } else if ((ENTITY::DOES_ENTITY_EXIST(SentryID)) && (SentryActive)) { If (PlayerTarget) { TargetID= PLAYER::GET_PLAYER_PED(ENTITY::GET_NEAREST_PLAYER_TO_ENTITY(SentryID)); char TargetName[] = PLAYER::GET_PLAYER_NAME(TargetID); if (TargetID == playerPed()); // Dont Shoot Myself Check { TargetID = 0; // Clear me as target } } If (VehicleTarget) { TargetID= GetClosestVehicle(ENTITY::GET_ENTITY_COORDS(SentryID,1),75); char TargetName[] = VEHICLE::GET_DISPLAY_NAME_FROM_VEHICLE_MODEL(ENTITY::GET_ENTITY_MODEL(TargetID)) if (PED::IS_PED_IN_ANY_VEHICLE(playerPed,0) == True ); { object VehID = GET_VEHICLE_PED_IS_IN(playerPed,0); if (TargetID == VehID); // Dont Shoot My Car check { TargetID = 0; // Clear My car as target } } } //Rotate and draw if (ENTITY::DOES_ENTITY_EXIST(TargetID)) { vector3 from = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(SentryID,0f,-0.2f,0.57f); vector3 to = ENTITY::GET_ENTITY_COORDS(TargetID,true); GRAPHICS::DRAW_LINE(from.x,from.y,from.z,to.x,to.y,to.z, 255, 0, 0, 0); Rotation = GetHeadingFromCoords(from.x,from.y,from.z,to.x,to.y,to.z) + 90f; SET_ENTITY_ROTATION(SentryID, 0, 0, Rotation); } //Time to Kill if (GET_GAME_TIMER() >= Timer) { vector3 from = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(SentryObject,0,-0.8,0.6); vector3 to = ENTITY::GET_ENTITY_COORDS(TargetID,true); SHOOT_SINGLE_BULLET_BETWEEN_COORDS(from.x,from.y,from.z,to.x,to.y,to.z250,0,WeaponID,playerPed,1,0,1.0) PLAY_SOUND_FROM_ENTITY(-1,"Remote_Sniper_Rifle_Fire",SentryID,"",0,0) Timer = GET_GAME_TIMER() + Timeout; } } }
[/HIDE]
Magic Carpet
[HIDE]
MagicCarpetLoop() { char* prop = "p_oil_slick_01" hash ObjHash = GAMEPLAY::GET_HASH_KEY(prop); object MagicCarpetObject = OBJECT::GET_CLOSEST_OBJECT_OF_TYPE(PlayerCoord.x,PlayerCoord.y,PlayerCoord.z,100,ObjHash,1,0,1); vector3 PlayerCoord = ENTITY::GET_ENTITY_COORD(playerPed,1); if ((! ENTITY::DOES_ENTITY_EXIST(MagicCarpetObject)) && (MagicCarpet)) { object MagicCarpetObject = Create_Object(prop,PlayerCoord.x,PlayerCoord.y,PlayerCoord.z) ENTITY::FREEZE_ENTITY_POSITION(MagicCarpetObject,1); ENTITY::SET_ENTITY_VISIBLE(MagicCarpetObject,0); } else if ((ENTITY::DOES_ENTITY_EXIST(MagicCarpetObject)) && (MagicCarpet)) { float Normal = 1.0225; float Down = 1.60; float Up = 0.40; float Vehicular = 50.0; if (PED::IS_PED_IN_ANY_VEHICLE(playerPed,0) //Move below ground when in car { zPlane = PlayerCoord.z - Vehicular; } else if (CONTROLS::IS_CONTROL_PRESSED(2,36)) //Down INPUT_DUCK |G|L3 { zPlane = PlayerCoord.z - Down; } else if (CONTROLS::IS_CONTROL_PRESSED(2,26)) //Up INPUT_LOOK_BEHIND |C|R3 { zPlane = PlayerCoord.z - Up; } else //Normal { zPlane = PlayerCoord.z - Normal; } Vector3 Coord = CombineVector(PlayerCoord.x, PlayerCoord.y, zPlane); ENTITY::SET_ENTITY_COORDS(MagicCarpetObject,Coord.x,Coord.y,Coord.z,1,0,0,1); } }
[/HIDE]
Drive on water
[HIDE]
DriveLoop() { char* prop = "prop_huge_display_01" hash ObjHash = GAMEPLAY::GET_HASH_KEY(prop); vector3 PlayerCoord = ENTITY::GET_ENTITY_COORDS(playerPed,1); object WaterObject = OBJECT::GET_CLOSEST_OBJECT_OF_TYPE(PlayerCoord.x,PlayerCoord.y,PlayerCoord.z,300,ObjHash,1,0,1); float Newz; bool FolowWaves = true; // for now well just force this to true WATER::GET_WATER_HEIGHT(PlayerCoord.x,PlayerCoord,y,PlayerCoord,z,&NewZ) if (NewZ >= -1000) { // Don't Do Shit if no water is found. } else if ((! ENTITY::DOES_ENTITY_EXIST(WaterObject)) && (DriveOnWater)) { object WaterObject = Create_Object(prop,PlayerCoord.x,PlayerCoord.y,PlayerCoord.z); ENTITY::SET_ENTITY_ROTATION(WaterObject,90,0,0,2,true); ENTITY::FREEZE_ENTITY_POSITION(WaterObject,1); ENTITY::SET_ENTITY_VISIBLE(WaterObject,0); } else if ((ENTITY::DOES_ENTITY_EXIST(WaterObject)) && (DriveOnWater)) { if (FolowWaves==true) { WATER::GET_WATER_HEIGHT(PlayerCoord.x,PlayerCoord.y,PlayerCoord.z,&NewZ) } else { WATER::GET_WATER_HEIGHT_NO_WAVES(PlayerCoord.x,PlayerCoord.y,PlayerCoord.z,&NewZ) NewZ = (NewZ + 0.5); // without this youll drown in the waves :p } Vector3 Coord = CombineVector(PlayerCoord.x, PlayerCoord.y, NewZ); ENTITY::SET_ENTITY_COORDS(WaterObject,Coord.x,Coord.y,Coord,z,1,0,0,1); } }
[/HIDE]
Thats it for now guys,
F.Y.I i also have a way of loading the heists IPL's in single player.
Be sure to check out my Pastebin aswwell for a Ful list of IPL's and some other usefull GTA 5 info.