Thumbs upSome GTA 4 Source Codes

Posts 1–3 of 3 · Page 1 of 1
Some GTA 4 Source Codes
Feel Free to share more source codes in replies

Drunk Cam:
Code:
} 
   if(item_selected == 11){ 
      Cam cam; 
         GET_ROOT_CAM(&cam); 
         SET_DRUNK_CAM(cam, 1.0, 10000); 
      return;
Super Punch:
Code:
if(superpunch){ 
   int wep; 
   GET_CURRENT_CHAR_WEAPON(GetPlayerPed(),&wep); 
if(wep == WEAPON_UNARMED){ 
   if(IS_BUTTON_PRESSED(0,BUTTON_B)){ 
      WAIT(700); 
      GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS(GetPlayerPed(), 0, 0, 0, &x, &y, &z); 
      ADD_EXPLOSION(x, y+2, z, EXPLOSION_SHIP_DESTROY, 10, 0, 1, 0); 
   } 
}
Tazer Punch:
Code:
if(superpunch){ 
   int wep; 
   GET_CURRENT_CHAR_WEAPON(GetPlayerPed(),&wep); 
if(wep == WEAPON_UNARMED){ 
   if(IS_BUTTON_PRESSED(0,BUTTON_B)){ 
      WAIT(700); 
      GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS(GetPlayerPed(), 0, 0, 0, &x, &y, &z); 
      ADD_EXPLOSION(x, y+2, z, EXPLOSION_DIR_WATER_HYDRANT, 10, 0, 1, 0); 
   } 
}
Give Online Players Neon:
Code:
for(i = 0;i <= player_loop;i++){ 
                           if(is_whitelisted(i)) continue; 
                     if(DOES_CHAR_EXIST(players[i].ped)){ 
                           if(IS_CHAR_IN_ANY_CAR(players[i].ped)){ 
                              tick=0; 
                              GET_CAR_CHAR_IS_USING(players[i].ped,&cveh); 
                              GET_NETWORK_ID_FROM_VEHICLE(cveh,&nvid); 
                              if(network_control(nvid)){ 
                           CREATE_OBJECT(0x2F8AEA79,0,0,0,&lights,1); 
          WAIT(1); 
         ATTACH_OBJECT_TO_CAR(lights,cveh,0,0,0.2,-0.2,-190,0,160.20); 
         SET_OBJECT_LIGHTS(lights, true); 
         SET_OBJECT_VISIBLE(lights, true); 
         SET_OBJECT_INVINCIBLE(lights, 1); 
         CREATE_OBJECT(0x2F8AEA79,0,0,0,&lights,1); 
         WAIT(1); 
         ATTACH_OBJECT_TO_CAR(lights,cveh,0,0,0.2,-0.2,-190,0,160.20); 
         SET_OBJECT_LIGHTS(lights, true); 
         SET_OBJECT_VISIBLE(lights, true); 
         SET_OBJECT_INVINCIBLE(lights, 1); 
         CREATE_OBJECT(0x2F8AEA79,0,0,0,&lights,1); 
         WAIT(1); 
         ATTACH_OBJECT_TO_CAR(lights,cveh,0.0f,0,0.2,-0.2,-190,0,160.2); 
         SET_OBJECT_LIGHTS(lights, true); 
         SET_OBJECT_VISIBLE(lights, true); 
         SET_OBJECT_INVINCIBLE(lights, 1); 
         CREATE_OBJECT(0x2F8AEA79,0,0,0,&lights,1); 
         WAIT(1); 
         ATTACH_OBJECT_TO_CAR(lights,cveh,0.0f,0.2,-1.0,-0.2,-190,0,160.2); 
         SET_OBJECT_LIGHTS(lights, true); 
         SET_OBJECT_VISIBLE(lights, true); 
         SET_OBJECT_INVINCIBLE(lights, 1); 
         CREATE_OBJECT(0x2F8AEA79,0,0,0,&lights,1); 
         WAIT(1); 
         ATTACH_OBJECT_TO_CAR(lights,cveh,0.0f,0.2,1.2,-0.2,-190,0,160.2); 
         SET_OBJECT_LIGHTS(lights, true); 
         SET_OBJECT_VISIBLE(lights, true); 
         SET_OBJECT_INVINCIBLE(lights, 1); 
         CREATE_OBJECT(0x2F8AEA79,0,0,0,&lights,1);          
         WAIT(1); 
         ATTACH_OBJECT_TO_CAR(lights,cveh,0,0,0.2,-0.2,-190,0,160.20); 
         SET_OBJECT_LIGHTS(lights, true); 
         SET_OBJECT_VISIBLE(lights, true); 
         SET_OBJECT_INVINCIBLE(lights, 1); 
                           } 
                     } 
                     } 
                     } 
                           print("Orange Neons Given to Player");
give/take online players car god mode:
Code:
for(i = 0;i <= player_loop;i++){ 
         if(is_whitelisted(i)) continue; 
         if(DOES_CHAR_EXIST(players[i].ped)){ 
            if(IS_CHAR_IN_ANY_CAR(players[i].ped)){ 
               GET_CAR_CHAR_IS_USING(players[i].ped,&cveh); 
               GET_NETWORK_ID_FROM_VEHICLE(cveh,&nveh); 
               if(network_control(nveh)){ 
               SET_CAR_CAN_BE_DAMAGED(cveh,false); 
               SET_CAR_CAN_BE_VISIBLY_DAMAGED(cveh,false); 
               SET_CAN_BURST_CAR_TYRES(cveh,false); 
               } 
            } 
         } 
      } 
      print("Given all Players Vehicle God"); 
   } 
   if(item_selected == 3){ 
      for(i = 0;i <= player_loop;i++){ 
         if(is_whitelisted(i)) continue; 
         if(DOES_CHAR_EXIST(players[i].ped)){ 
            if(IS_CHAR_IN_ANY_CAR(players[i].ped)){ 
               GET_CAR_CHAR_IS_USING(players[i].ped,&cveh); 
               GET_NETWORK_ID_FROM_VEHICLE(cveh,&nveh); 
               if(network_control(nveh)){ 
               SET_CAR_CAN_BE_DAMAGED(cveh,true); 
               SET_CAR_CAN_BE_VISIBLY_DAMAGED(cveh,true); 
               SET_CAN_BURST_CAR_TYRES(cveh,true); 
               } 
            } 
         } 
      } 
      print("Taken all Players Vehicle God");
put object on online players:
Code:
for(i = 0;i <= player_loop;i++){ 
         if(is_whitelisted(i)) continue; 
         if(DOES_CHAR_EXIST(players[i].ped)){ 
         REQUEST_MODEL(0xB4A4DCCF); 
         while(!HAS_MODEL_LOADED(0xB4A4DCCF)) WAIT(0); 
         Object otmp; 
         CREATE_OBJECT(0xB4A4DCCF,0.0,0.0,0.0,&otmp,true); 
         ATTACH_OBJECT_TO_PED(otmp,players[i].ped,0,0.0,0.0,-0.11,0.0,0.0,3.0,false); 
         WAIT(10); 
         MARK_OBJECT_AS_NO_LONGER_NEEDED(&otmp); 
         print("Attached Bill Board to Player"); 
         } 
      } 
   }
Kiss Animation:
Code:
REQUEST_ANIMS("amb@dating"); 
      while(!HAVE_ANIMS_LOADED("amb@dating")) WAIT(0); 
      TASK_PLAY_ANIM_WITH_FLAGS(pPlayer,"girl_hug","amb@dating",8.0,0,0);//****
Striper Animation:
Code:
REQUEST_ANIMS("MISSSTRIPCLUBHI"); 
      while(!HAVE_ANIMS_LOADED("MISSSTRIPCLUBHI")) WAIT(0); 
      TASK_PLAY_ANIM_WITH_FLAGS(pPlayer,"Lap_Triangle_A3_Woman","MISSSTRIPCLUBHI",8.0,0,0); 
      return;
Busted Animation:
Code:
REQUEST_ANIMS("busted"); 
      while(!HAVE_ANIMS_LOADED("busted")) WAIT(0);    
      TASK_PLAY_ANIM_WITH_FLAGS(GetPlayerPed(),"idle_2_hands_up","busted",8.0,0,0x20); 
      return;
Unlock GTA 4 Achievements:
Code:
void UnlockAchievements()
{
    int i = 0;
    while(i < 66)
    {
        if(!HAS_ACHIEVEMENT_BEEN_PASSED(i)) AWARD_ACHIEVEMENT(i);
        i++;
    }
}
random colored cube to any chars head:
Code:
void CubeifyChar(Ped ped){
if(DOES_CHAR_EXIST(ped)){
uint cubes[6],rand;
Object otmp;
cubes[0] = 0x2718C626;
cubes[1] = 0xDD28B247;
cubes[2] = 0xCCEA11CA;
cubes[3] = 0xBB1F6E71;
cubes[4] = 0xA6E545FD;
cubes[5] = 0x5C5030D4;
GENERATE_RANDOM_INT_IN_RANGE(0,5,&rand);
 
CREATE_OBJECT(cubes[rand],0.0,0.0,0.0,&otmp,true);
 
ATTACH_OBJECT_TO_PED(otmp,ped,0x4B5,0.0,0.0,0.0,0.0,0.0,3.0,false);
WAIT(10);
MARK_OBJECT_AS_NO_LONGER_NEEDED(&otmp); //Free up some memory ;)
}
}
Teleport to Waypoint:
Code:
Blip wpblip;
Vector3 wpcoords;
float groundz;
 
void PrintText(char *text)
{
    PRINT_STRING_WITH_LITERAL_STRING_NOW("string", text, 5000, true);
}
 
void TeleportToWaypoint(void)
{
    wpblip = GET_FIRST_BLIP_INFO_ID(BLIP_WAYPOINT);
    if( DOES_BLIP_EXIST(wpblip) )
    {
        GET_BLIP_COORDS(wpblip, &wpcoords);
        SET_CHAR_COORDINATES(GetPlayerPed(), wpcoords.x, wpcoords.y, 0.0);
        SET_GAME_CAM_HEADING(0.0);
        REQUEST_COLLISION_AT_POSN(wpcoords.x, wpcoords.y, 0.0);
        LOAD_ALL_OBJECTS_NOW();
 
        GET_GROUND_Z_FOR_3D_COORD(wpcoords.x, wpcoords.y, 1000, &groundz);
        SET_CHAR_COORDINATES(GetPlayerPed(), wpcoords.x, wpcoords.y, groundz);
        SET_GAME_CAM_HEADING(0.0);
        PrintText("Successfully teleported to waypoint");
    }
    else PrintText("No waypoint set");
}
Rocket Helicopter:
Code:
float x, y, z, heliheading, helipitch, ped1_x, ped2_x, ped1_z, ped2_z, ped1_y, ped2_y;
Vehicle veh;
Ped rped, rped1;
#define RPEDAMMO 2
 
void RocketHeli(void)
{
    if ( IS_CHAR_IN_ANY_HELI(GetPlayerPed()) && IS_BUTTON_JUST_PRESSED(0, BUTTON_A) )
    {
        GET_CAR_CHAR_IS_USING(GetPlayerPed(), &veh);
        GET_CAR_COORDINATES(veh, &x, &y, &z);
        GET_OFFSET_FROM_CAR_IN_WORLD_COORDS(veh, -3, -0.3, -0.2, &ped1_x, &ped1_y, &ped1_z);
        CREATE_RANDOM_CHAR(ped1_x, ped1_y, ped1_z, &rped);
 
        GET_OFFSET_FROM_CAR_IN_WORLD_COORDS(veh, 3, -0.3, -0.2, &ped2_x, &ped2_y, &ped2_z);
        CREATE_RANDOM_CHAR(ped2_x, ped2_y, ped2_z, &rped1);
        WAIT(10);
 
        if ( DOES_CHAR_EXIST(rped) && DOES_CHAR_EXIST(rped1) )
        {
            GIVE_WEAPON_TO_CHAR(rped, WEAPON_RLAUNCHER, RPEDAMMO, 0);
            SET_CURRENT_CHAR_WEAPON(rped, WEAPON_RLAUNCHER, true);
            GIVE_WEAPON_TO_CHAR(rped1, WEAPON_RLAUNCHER, RPEDAMMO, 0);
            SET_CURRENT_CHAR_WEAPON(rped1, WEAPON_RLAUNCHER, true);
            GET_CAR_HEADING(veh, &heliheading);
            GET_CAR_PITCH(veh, &helipitch);
            SET_CAR_COLLISION(veh, false);
            FIRE_PED_WEAPON(rped, x+(60*SIN((-1*heliheading))), y+(60*COS((-1*heliheading))), z+helipitch);
            FIRE_PED_WEAPON(rped1, x+(60*SIN((-1*heliheading))), y+(60*COS((-1*heliheading))), z+helipitch);
            DELETE_CHAR(&rped);
            DELETE_CHAR(&rped1);
            WAIT(500);
            SET_CAR_COLLISION(veh, true);
        }
    }
}
Airstrike At Waypoint:
Code:
Void Function
 
 
void xmc_airstrike(void)
{
    if(DOES_BLIP_EXIST(GET_FIRST_BLIP_INFO_ID(BLIP_WAYPOINT))){
    Vector3 pos;
    float z;
    GET_BLIP_COORDS(GET_FIRST_BLIP_INFO_ID(BLIP_WAYPOINT),&pos);
    GET_GROUND_Z_FOR_3D_COORD(pos.x,pos.y,pos.z,&z);
    xmccreate_big_explosion(pos.x,pos.y,z);//adding 10.0f isn't tested
    xmcPrint("Launching Airstrike!");
    }
    else xmcPrint("You need to set a waypoint!");
}
 
 
 
Print Definition
 
#define xmcPrint(x) PRINT_STRING_WITH_LITERAL_STRING("string",x,2500,true)
Flip Online Player's Car Upright:
Code:
bool requestnet(uint netid)
{
    SET_NETWORK_ID_CAN_MIGRATE(netid, true);
    int Attempts = 0;
    while (!HAS_CONTROL_OF_NETWORK_ID(netid) && Attempts < 100)
    {
        REQUEST_CONTROL_OF_NETWORK_ID(netid);
        Attempts += 1;
        WAIT(50);
    }
    return REQUEST_CONTROL_OF_NETWORK_ID(netid);
}
 
void FlipCarOfPlayer(int veh)
{
    int netvehid;
    float heading, tx, ty, tz;
    GET_NETWORK_ID_FROM_VEHICLE(veh, &netvehid);
    if (requestnet(netvehid))
    {
        GET_CAR_COORDINATES(veh, &tx, &ty, &tz);
        GET_CAR_HEADING(veh, &heading);
        WAIT(0);
        SET_VEHICLE_QUATERNION(veh, 0, 0, 0, 0);
        SET_CAR_COORDINATES(veh, tx, ty, tz);
        SET_CAR_HEADING(veh, heading);
        Print("Players vehicle has been set upright.", 5000, 1);
    }
}
Bodyguard Spawner with Hitlist:
Code:
Ped gameped[12];
Group Bgroup;
Ped pPlayer = GetPlayerPed();
//This script will only work if using a menu based off Muskelprotze's Stash
 
//This will delete spawned guards one by one
void delete_spawnguards(void){
        GET_PLAYER_GROUP(GetPlayerIndex(), &Bgroup);
        uint test,guards;
        GET_GROUP_SIZE(Bgroup, &test, &guards);
        if(guards <= 0){
                print("No guards exist");
                return;
        }
        if(DOES_GROUP_EXIST(Bgroup)){
                for(i = 0;i <= 11; i++){
                        if(DOES_CHAR_EXIST(gameped[i])){
                                DELETE_CHAR(&gameped[i]);
                                print("1 was Guard Deleted");                                  
                                return;
                        }
                        if((i >= 11) || (i > 10)) return;
                }
        print("No guards exist");                      
        return;
        }
        return;
}
 
// This will spawn guards one by one and label them as gameped[#]
// So that they can be indivdually called as gameped[#] (upto 11)
// Example usage:
// spawnguards(MODEL_IG_DWAYNE, WEAPON_M4);
void spawnguards(uint model, uint weapon){
        GET_PLAYER_GROUP(GetPlayerIndex(), &Bgroup);
        if(!DOES_GROUP_EXIST(Bgroup)){
                CREATE_GROUP(0, Bgroup, true);
                SET_GROUP_LEADER(Bgroup, pPlayer);
                SET_GROUP_SEPARATION_RANGE(Bgroup, 9999.9);
                SET_GROUP_FORMATION(Bgroup, 2);
        }      
        uint test,guards;
        GET_GROUP_SIZE(Bgroup, &test, &guards);
        if(guards >= 11){
                print("Max guards (11) exceeded");
                return;
        }
        for(i = 0;i <= 11; i++){
                if(!DOES_CHAR_EXIST(gameped[i])){
                       
                        REQUEST_MODEL(model);
                        while (!HAS_MODEL_LOADED(model)) WAIT(0);
                        WAIT(100);
                       
                        GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS(pPlayer, 0, 2, 0, &x, &y, &z);
                       
                        CREATE_CHAR(26, model, x,y,z, &gameped[i], true);
                        WAIT(500);
                        SET_CHAR_RANDOM_COMPONENT_VARIATION(gameped[i]);
                        SET_GROUP_MEMBER(Bgroup, gameped[i]);
                        SET_CHAR_RELATIONSHIP_GROUP(gameped[i], 24);
                        SET_CHAR_RELATIONSHIP(gameped[i], 5, 0);
                        SET_CHAR_NEVER_LEAVES_GROUP(gameped[i], true);
                        SET_CHAR_ACCURACY(gameped[i], 100);
                        SET_CHAR_KEEP_TASK(gameped[i], true);
                        SET_SENSE_RANGE(gameped[i], 100.0);
                        SET_PED_GENERATES_DEAD_BODY_EVENTS(gameped[i], true);
                        SET_CHAR_SHOOT_RATE(gameped[i], 100);
                        SET_CHAR_WILL_DO_DRIVEBYS(gameped[i], true);
                        SET_CHAR_SIGNAL_AFTER_KILL(gameped[i], true);
                        SET_CHAR_WILL_USE_CARS_IN_COMBAT(gameped[i], true);
                        SET_CHAR_WILL_FLY_THROUGH_WINDSCREEN(gameped[i], false);
                        SET_CHAR_INVINCIBLE(gameped[i], true);
                        SET_CHAR_PROVIDE_COVERING_FIRE(gameped[i], true);
                        SET_CHAR_CANT_BE_DRAGGED_OUT(gameped[i], true);
                        SET_CHAR_STAY_IN_CAR_WHEN_JACKED(gameped[i], true);
                        SET_PED_DONT_DO_EVASIVE_DIVES(gameped[i], true);
                        SET_PED_PATH_MAY_DROP_FROM_HEIGHT(gameped[i], true);
                        SET_PED_PATH_MAY_USE_CLIMBOVERS(gameped[i], true);
                        SET_PED_PATH_MAY_USE_LADDERS(gameped[i], true);
                        UpdateWeaponOfPed(gameped[i], weapon);
                        SET_CURRENT_CHAR_WEAPON(gameped[i], weapon, true);
                       
                        print("Spawned Bodyguard");
                        return;
                }
        }
        return;
}
 
 
//This is a function that will send all the spawned guards to kill a certain player
if(DOES_CHAR_EXIST(players[index].ped)){
        GET_PLAYER_GROUP(GetPlayerIndex(), &Bgroup);
        if(DOES_GROUP_EXIST(Bgroup)){
                for(i = 0;i <= 11; i++){
                        if(DOES_CHAR_EXIST(gameped[i]) && DOES_CHAR_EXIST(players[index].ped)){
                                TASK_COMBAT(gameped[i], players[index].ped);
                                if((i >= 11) || (i > 10)){
                                        print("Sent all Guards after the Player");
                                        return;
                                }
                        }
                }
        }
}
Vehicle Spawner:
Code:
Vehicle CreateVehicle(uint iModel, float fX, float fY, float fZ)
{
        Vehicle pVehicle;
        CREATE_CAR(iModel, fX, fY, fZ, &pVehicle, true);
        MARK_MODEL_AS_NO_LONGER_NEEDED(iModel);
        return pVehicle;
}
Vehicle CreateVehicleAtYourLocation(uint iModel)
{
float v, h, qx, qy, qz, qw, x, y, z;
bool veh, replace;
uint colour[4], temp;
Vehicle pVehicle;
if (iModel == 0) replace = 1;else replace = 0;//create a car the same as yours(kick players out of your car) if 1st param is 0
GET_CAR_CHAR_IS_USING(GetPlayerPed(), &pVehicle);
if (!DOES_VEHICLE_EXIST(pVehicle)){
veh = 0;
if (!IS_MODEL_IN_CDIMAGE(iModel))return INVALID_HANDLE;
if (!IS_THIS_MODEL_A_VEHICLE(iModel)) return INVALID_HANDLE;
REQUEST_MODEL(iModel);
while(!HAS_MODEL_LOADED(iModel))WAIT(0);
GET_CHAR_COORDINATES(GetPlayerPed(), &x, &y, &z);
GET_CHAR_HEADING(GetPlayerPed(), &h);
GET_CHAR_SPEED(GetPlayerPed(), &v);
for (temp=0;temp<4;temp++){
if (GET_CURRENT_EPISODE()==2)
GENERATE_RANDOM_INT_IN_RANGE(0, 136, &colour[temp]);
else
GENERATE_RANDOM_INT_IN_RANGE(0, 133, &colour[temp]);
}
}
else{
veh = 1;
 
if (replace){
GET_CAR_MODEL(pVehicle, &iModel);
GET_CAR_COLOURS(pVehicle, &colour[0], &colour[1]);
GET_EXTRA_CAR_COLOURS(pVehicle, &colour[2], &colour[3]);}
else
for (temp=0;temp<4;temp++){
if (GET_CURRENT_EPISODE()==2)
GENERATE_RANDOM_INT_IN_RANGE(0, 136, &colour[temp]);
else
GENERATE_RANDOM_INT_IN_RANGE(0, 133, &colour[temp]);}
 
if (!IS_MODEL_IN_CDIMAGE(iModel))return INVALID_HANDLE;
if (!IS_THIS_MODEL_A_VEHICLE(iModel)) return INVALID_HANDLE;
REQUEST_MODEL(iModel);
while(!HAS_MODEL_LOADED(iModel))WAIT(0);
 
GET_VEHICLE_QUATERNION(pVehicle, &qx, &qy, &qz, &qw);
GET_CAR_COORDINATES(pVehicle, &x, &y, &z);
GET_CAR_SPEED(pVehicle, &v);
 
if (!IS_NETWORK_SESSION())
DELETE_CAR(&pVehicle);
 
else
 
{int netid, count;
GET_NETWORK_ID_FROM_VEHICLE(pVehicle, &netid);
while(!HAS_CONTROL_OF_NETWORK_ID(netid) && count < 20){REQUEST_CONTROL_OF_NETWORK_ID(netid);count++;WAIT(50);}
 
if (DOES_VEHICLE_EXIST(pVehicle) && HAS_CONTROL_OF_NETWORK_ID(netid))DELETE_CAR(&pVehicle);}
}// ^^check to prevent freezing if car is deleted while attempting to gain control^^
 
 pVehicle = CreateVehicle(iModel, x, y, z);
 
 WAIT(0);
 
 if (!DOES_VEHICLE_EXIST(pVehicle))return INVALID_HANDLE;//check to make sure car was created
 
 WARP_CHAR_INTO_CAR(GetPlayerPed(), pVehicle);
 
 if (!veh)//check if you were in a vehicle before
 SET_CAR_HEADING(pVehicle, h);
 else
 SET_VEHICLE_QUATERNION(pVehicle, qx, qy, qz, qw);
 
 CHANGE_CAR_COLOUR(pVehicle, colour[0], colour[1]);
 SET_EXTRA_CAR_COLOURS(pVehicle, colour[2], colour[3]);
 SET_CAR_COORDINATES(pVehicle, x, y, z);//if you spawn it in midair, it should stay in midair
 SET_CAR_FORWARD_SPEED(pVehicle, v);
 
 return pVehicle;
}
all of these are in the xmc 3.0 source....
Quote Originally Posted by ENBFaith View Post
all of these are in the xmc 3.0 source....
i didnt know what xmc is but then i googled it and no i didnt took it from there.
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?