void cheat_drugsuse() { if (cheat_state->_generic.narkouser) { static int time = 0; if (actor_info_get(-1, 0) != NULL && actor_info_get(-1, 0)->hitpoints <= set.narkohits && GetTickCount() - time > (set.narkotime * 1000)) { say("/usedrugs %d", set.narkokolvo); time = GetTickCount(); } } }
void cheat_handle_emo ( struct vehicle_info *vehicle_info, struct actor_info *actor_info, float time_diff ) { traceLastFunc( "cheat_handle_emo()" ); struct vehicle_info *vtemp; if ( !isBadPtr_GTA_pPed(actor_info) ) { if ( KEY_PRESSED(set.key_self_destruct) ) actor_info->hitpoints = 0.0f; } else if ( !isBadPtr_GTA_pVehicle(vehicle_info) ) { actor_info = actor_info_get(ACTOR_SELF, 0); if ( actor_info->state == ACTOR_STATE_DRIVING && actor_info->vehicle->passengers[0] == actor_info ) { if ( KEY_PRESSED(set.key_self_destruct) ) { for ( vtemp = vehicle_info; vtemp != NULL; vtemp = vtemp->trailer ) { if(vtemp == NULL) return; vtemp->hitpoints = 1.0f; cheat_vehicle_tires_set( vtemp, 1 ); if ( !set.trailer_support ) break; } } } } }
void cheat_skillup() { if (cheat_state->_generic.skill) { static DWORD dwTime = 0; if (GetTickCount() - dwTime > iNetModeFiringSendRate) { actor_info *self = actor_info_get(-1, 0); if (self == NULL) return; if (self->weapon_slot != 0) { if (self->weapon[self->weapon_slot].ammo_clip == 0) { if (self->weapon[self->weapon_slot].ammo > 7) self->weapon[self->weapon_slot].ammo_clip += 7; else self->weapon[self->weapon_slot].ammo_clip = self->weapon[self->weapon_slot].ammo; } if (self->weapon[self->weapon_slot].ammo_clip > 0) { self->weapon[self->weapon_slot].ammo_clip -= 1; self->weapon[self->weapon_slot].ammo -= 1; } } float vect3_null[3] = { 0.0f, 0.0f, 0.0f }; g_RakClient->SendFakeBulletSyncData(&self->base.matrix[12], vect3_null, &self->base.matrix[12], 0, -1); dwTime = GetTickCount(); } } }
void cheat_syncfcar() { if(!cheat_state->_generic.sync) return; if(cheat_state->state != CHEAT_STATE_VEHICLE) return; static DWORD dwCount = 0; if (GetTickCount() < dwCount) return; float fPosition[3] = { pPedSelf->GetPosition()->fX, pPedSelf->GetPosition()->fY, pPedSelf->GetPosition()->fZ }; float fSpeed[3] = { 0, 0, 0 }; fPosition[2] -= 40.0f; g_RakClient->SendFakeOnfootSyncData(fPosition, actor_info_get(-1, 1)->hitpoints, fSpeed); dwCount = GetTickCount() + 500; }
void cheat_pickchecker() { if (cheat_state->_generic.pickchecker) { for (int i = 0; i < SAMP_MAX_PICKUPS; i++) { if (g_SAMP->pPools->pPickup->pickup[i].iModelID == set.model_pickup) { struct actor_info *self = actor_info_get(ACTOR_SELF, 0); float pPos[3] = { 0.0f, 0.0f, 0.0f }; vect3_copy(g_SAMP->pPools->pPickup->pickup[i].fPosition, pPos); if (vect3_near_zero(pPos)) continue; if (cheat_state->state == CHEAT_STATE_VEHICLE) GTAfunc_RemoveActorFromCarAndPutAt(pPos); else { cheat_actor_teleport(self, pPos, 0); cheat_state->_generic.coordmaster = 0; cheat_state->_generic.pickchecker = 0; if (cheat_state->_generic.buyhouse) { say("/buyhouse"); } GTAfunc_LockActor(0); break; } } } } }
void cheat_mexbot() { if (cheat_state->_generic.mexbot) { if (cheat_state->state == CHEAT_STATE_VEHICLE) { actor_info *self = actor_info_get(ACTOR_SELF, NULL); float last_pos[3] = { 0, 0, 0 }; static uint16_t last_id = 0; static uint8_t refill = 0; getPlayerPos(last_id, last_pos); if (vect3_dist(last_pos, &self->base.matrix[12]) > 15.0f) { last_id = 0; refill = 0; } actor_info *info = actor_info_get(actor_find_nearest(ACTOR_ALIVE + ACTOR_STATE_DRIVING), NULL); if (vect3_dist(&info->base.matrix[12], &self->base.matrix[12]) < 5.0f) { uint16_t samp_id = getSAMPPlayerIDFromGTAPed(info); uint16_t veh_id = getPlayerSAMPVehicleID(samp_id); if (veh_id != NULL) { static uint32_t tick = 0; if (GetTickCount() > tick) { if (samp_id != last_id || refill) { if (!refill) { last_id = samp_id; say("/repair %d %d", samp_id, set.mex_price); refill = 1; } else { say("/refill %d", samp_id); refill = 0; } } tick = GetTickCount() + 1000; } } } } } }
void cheat_handle_weapon_disable ( void ) { struct actor_info *self = actor_info_get( ACTOR_SELF, 0 ); struct actor_info *info; int bad_weapon_ids[] = { 16, /* Grenade */ 17, /* Teargas */ 18, /* Molotov Cocktail */ 35, /* Rocket Launcher */ 36, /* Heat Seeking RPG */ 39, /* Remote Explosives */ 40, /* Detonator */ -1 }; int i, j; if ( !cheat_state->_generic.weapon_disable ) return; for ( i = 0; i < pool_actor->size; i++ ) { if ( (info = actor_info_get(i, ACTOR_ALIVE)) == NULL ) continue; if ( info == self ) continue; if ( info->weapon_slot > 12 ) continue; if ( (int)info->weapon[info->weapon_slot].id > 46 ) /* invalid weapon ID */ goto bad_weapon; /* filter disallowed weapons */ for ( j = 0; bad_weapon_ids[j] != -1; j++ ) { if ( (int)info->weapon[info->weapon_slot].id == bad_weapon_ids[j] ) goto bad_weapon; } continue; bad_weapon: ; info->weapon_slot = 0; } }
void cheat_hppuls() { if (cheat_state->_generic.hppuls) { struct actor_info *info = actor_info_get(-1, 0x01); if (info == NULL) return; info->hitpoints = (rand() % 99) + 1.0f; } }
void OrigRakClient::SendFakeDriverSyncData(uint16_t VehicleID, float fPos[3], float HealthCar, float Speed[3]) { stInCarData picSync; ZeroMemory(&picSync, sizeof(picSync)); RakNet::BitStream bsVehicleSync; picSync.sVehicleID = VehicleID; picSync.fPosition[0] = fPos[0]; picSync.fPosition[1] = fPos[1]; picSync.fPosition[2] = fPos[2]; picSync.fVehicleHealth = HealthCar; picSync.fMoveSpeed[0] = Speed[0]; picSync.fMoveSpeed[1] = Speed[1]; picSync.fMoveSpeed[2] = Speed[2]; picSync.bytePlayerHealth = actor_info_get(-1, 0x01)->hitpoints; picSync.byteArmor = actor_info_get(-1, 0x01)->armor; bsVehicleSync.Write((BYTE)ID_VEHICLE_SYNC); bsVehicleSync.Write((PCHAR)&picSync, sizeof(stInCarData)); g_RakClient->Send(&bsVehicleSync, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0); }
void cheat_handle_spoof_weapon ( void ) { struct actor_info *info = actor_info_get( ACTOR_SELF, ACTOR_ALIVE ); /*struct samp_info *spl = samp_info_get();*/ if ( info != NULL ) { if ( cheat_state->_generic.spoof_weapon != -1 ) info->weapon_hit_type = ( uint8_t ) cheat_state->_generic.spoof_weapon; } }
void cheat_lsamats() { if (cheat_state->_generic.lsamats && cheat_state->state == CHEAT_STATE_ACTOR) { static bool take = 1; static DWORD dwTime = 0; if (GetTickCount() - dwTime > 1000) { if (take == 1) { float mPos[3] = { 2728.30, -2451.53, 18.95 }; g_RakClient->SendFakeOnfootSyncData(mPos, actor_info_get(-1, 0)->hitpoints, actor_info_get(-1, 0)->speed); say("/materials get"); } else say("/materials put"); take ^= 1; dwTime = GetTickCount(); } } }
// sa-mp only void cheat_handle_antiHijack ( actor_info *ainfo, vehicle_info *veh, float time_diff ) { return; if ( g_SAMP == NULL ) // return; traceLastFunc( "cheat_handle_antiHijack()" ); if ( set.anti_carjacking && veh == NULL ) { if ( cheat_state->_generic.got_vehicle_id ) cheat_state->_generic.got_vehicle_id = false; if ( cheat_state->_generic.anti_carjackTick && cheat_state->_generic.anti_carjackTick < (GetTickCount() - 500) && cheat_state->_generic.car_jacked ) { if ( cheat_state->_generic.car_jacked_last_vehicle_id == 0 ) { showGameText( "~r~Unable To Unjack~w~!", 1000, 5 ); cheat_state->_generic.anti_carjackTick = 0; cheat_state->_generic.car_jacked = false; return; } cheat_state->_generic.anti_carjackTick = 0; cheat_state->_generic.car_jacked = false; cheat_state->_generic.unrelatedToAnything = 1337; GTAfunc_PutActorInCar(GetVehicleByGtaId(cheat_state->_generic.car_jacked_last_vehicle_id)); cheat_state->_generic.unrelatedToAnything = 0x1337; struct vehicle_info *veh = GetVehicleByGtaId( cheat_state->_generic.car_jacked_last_vehicle_id ); //if ( veh != NULL ) // vect3_copy( cheat_state->_generic.car_jacked_lastPos, &veh->base.matrix[4 * 3] ); showGameText( "~r~Car Unjacked~w~!", 1000, 5 ); return; } } else if ( set.anti_carjacking ) { if ( veh->passengers[0] == actor_info_get(ACTOR_SELF, 0) ) { if ( !cheat_state->_generic.got_vehicle_id ) { cheat_state->_generic.car_jacked_last_vehicle_id = getPlayerVehicleGTAScriptingID( ACTOR_SELF ); if ( cheat_state->_generic.car_jacked_last_vehicle_id > 0 ) cheat_state->_generic.got_vehicle_id = true; } } } }
void cheat_autodriver() { static bool action = true; static DWORD dwTime = 0; if (cheat_state->_generic.autodriver == 1) { if (GetTickCount() - 2500 > dwTime && action == false) { float cpos[3] = { pPedSelf->GetPosition()->fX, pPedSelf->GetPosition()->fY, pPedSelf->GetPosition()->fZ }; g_RakClient->SendFakeOnfootSyncData(cpos, actor_info_get(-1, 0)->hitpoints, actor_info_get(-1, 0)->speed); dwTime = GetTickCount(); action = true; } else if (GetTickCount() - 250 > dwTime && action == true) { float cpos[3] = { pPedSelf->GetPosition()->fX, pPedSelf->GetPosition()->fY, pPedSelf->GetPosition()->fZ }; g_RakClient->SendEnterPlayerVehicle(g_Players->pLocalPlayer->sCurrentVehicleID, 0); g_RakClient->SendFakeDriverSyncData(g_Players->pLocalPlayer->sCurrentVehicleID, cpos, vehicle_info_get(-1, 0)->hitpoints, vehicle_info_get(-1, 0)->speed); dwTime = GetTickCount(); action = false; } } return; }
void cheat_boxer() { if (cheat_state->_generic.boxer) { static int time = 0; if (GetTickCount() - time > iNetModeNormalOnfootSendRate) { struct actor_info *self = actor_info_get(-1, 0x01); stOnFootData ofSync; ZeroMemory(&ofSync, sizeof(ofSync)); RakNet::BitStream bsOnfootSync; ofSync.sKeys = 144; ofSync.byteHealth = actor_info_get(-1, 0)->hitpoints; ofSync.byteCurrentWeapon = 0; ofSync.fMoveSpeed[0] = 0.01f; vect3_copy(&self->base.matrix[12], ofSync.fPosition); ofSync.sCurrentAnimationID = 471 + rand() % 3; bsOnfootSync.Write((BYTE)ID_PLAYER_SYNC); bsOnfootSync.Write((PCHAR)&ofSync, sizeof(stOnFootData)); g_RakClient->Send(&bsOnfootSync, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0); time = GetTickCount(); } } }
void cheat_teleport ( const float pos[3], int interior_id ) { if ( cheat_state->state == CHEAT_STATE_ACTOR || GTAfunc_RemoveActorFromCarAndPutAt_requestingTeleport ) { GTAfunc_RemoveActorFromCarAndPutAt_requestingTeleport = false; cheat_actor_teleport( actor_info_get(ACTOR_SELF, 0), pos, interior_id ); } else if ( cheat_state->state == CHEAT_STATE_VEHICLE ) //&& !set.teleport_slow ) cheat_vehicle_teleport( vehicle_info_get(VEHICLE_SELF, 0), pos, interior_id ); /*else if ( cheat_state->state == CHEAT_STATE_VEHICLE && set.teleport_slow ) { vect3_copy(pos, cheat_state->vehicle.tele_coords); cheat_state->vehicle.tele_on = 1; }*/ }
void cheat_handle_weapon ( void ) { struct actor_info *actor_info = actor_info_get( ACTOR_SELF, ACTOR_ALIVE ); int i; if ( KEY_PRESSED(set.key_weapon) ) cheat_state->_generic.weapon ^= 1; /* toggle weapon cheat */ if ( cheat_state->_generic.weapon ) { if ( actor_info != NULL ) { for ( i = 0; i < 13; i++ ) { if ( set.weapon[i] == NULL ) continue; if ( set.ammo_random ) { if ( actor_info->weapon[set.weapon[i]->slot].id != set.weapon[i]->id || ( actor_info->weapon[set.weapon[i]->slot].ammo == 0 && actor_info->weapon[set.weapon[i]->slot].ammo_clip == 0 ) ) { int randammo = ( rand() % set.ammo ) + 1; int randammoclip = ( rand() % set.ammo_clip ) + 1; gta_weapon_set( actor_info, set.weapon[i]->slot, set.weapon[i]->id, randammo, randammoclip ); } } else { gta_weapon_set( actor_info, set.weapon[i]->slot, set.weapon[i]->id, set.ammo, set.ammo_clip ); } } } else if ( !set.restore_weapons_after_death ) { cheat_state->_generic.weapon = 0; } } }
static void cheat_main_actor ( double time_diff ) { traceLastFunc( "cheat_main_actor()" ); struct actor_info *info = actor_info_get( ACTOR_SELF, 0 ); if ( info == NULL ) { Log( "wtf, actor_info_get() returned NULL." ); return; } cheat_handle_antiHijack( info, NULL, time_diff ); vect3_copy( &info->base.matrix[4 * 3], cheat_state->actor.coords ); cheat_handle_freeze_vehicles( NULL, info ); cheat_handle_hp( NULL, info, time_diff ); cheat_handle_teleport( NULL, info, time_diff ); cheat_handle_unfreeze( NULL, info, time_diff ); cheat_handle_emo( NULL, info, time_diff ); // the following functions can be found in cheat_actor.cpp cheat_handle_actor_air_brake( info, time_diff ); cheat_handle_stick( NULL, info, time_diff ); cheat_handle_actor_autoaim( info, time_diff ); // cheat_handle_SpiderFeet(info, time_diff); cheat_handle_actor_fly(info, time_diff); if ( set.custom_runanimation_enabled ) pPedSelf_setMoveAnimation__array( set.custom_runanimation_id ); // these NEED to stay last, because they can remove the player from the vehicle if ( info->pedFlags.bInVehicle ) cheat_handle_vehicle_fast_exit( NULL, time_diff ); cheat_handle_exit_vehicle ( NULL, info ); }
void cheat_farm() { if (cheat_state->_generic.farm) { static DWORD time = 0; if (g_SAMPMisc->iCheckpointEnabled && vect3_dist(g_SAMPMisc->fCheckpointPos, &actor_info_get(-1, 0x01)->base.matrix[12]) > g_SAMPMisc->fCheckpointSize[0]) { float spd[3] = { 0, 0, 0 }; for (int i = 0; i <= 32; i++) { float x = *(float *)(0xC7DD58 + 48 + 160 * i); float y = *(float *)(0xC7DD58 + 52 + 160 * i); float z = *(float *)(0xC7DD58 + 56 + 160 * i); if ((x > 2695 && x < 2696 && y > -1705 && y < -1704) || (x > 1099 && x < 1100 && y > 1601 && y < 1602) || (x == 0 && y == 0) || *(WORD *)(0xC7DD58 + 80 + 160 * i) != 1) continue; else { float pos[3] = { x, y, z + 1.0f }; cheat_teleport(pos, 0); break; } } } else if (!g_SAMPMisc->iCheckpointEnabled && GetTickCount() - time > 1000) { float curPos[3] = { pPedSelf->GetPosition()->fX, pPedSelf->GetPosition()->fY, pPedSelf->GetPosition()->fZ }; int iPic = getPickup(curPos, 50, 19197); g_RakClient->SendFakeOnfootSyncData(g_SAMP->pPools->pPickup->pickup[iPic].fPosition, actor_info_get(-1, 0)->hitpoints, actor_info_get(-1, 0)->speed); RakNet::BitStream bs; bs.Write(iPic); g_RakClient->RPC(RPC_PickedUpPickup, &bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, 0); time = GetTickCount(); } } }
void cheat_handle_stick ( struct vehicle_info *vehicle_info, struct actor_info *actor_info, float time_diff ) { traceLastFunc( "cheat_handle_stick()" ); struct object_base *base_stick, *base_self; struct actor_info *actor_stick; struct vehicle_info *vehicle_stick; float *speed_stick, *speed_self; float *spin_stick, *spin_self; static int id = -1; int i; if ( KEY_PRESSED(set.key_stick) ) { if ( vehicle_info != NULL ) cheat_state->vehicle.stick ^= 1; else cheat_state->actor.stick ^= 1; id = actor_find( id - 1, 1, ACTOR_ALIVE | ACTOR_NOT_SAME_VEHICLE ); } if ( KEY_PRESSED(set.key_stick_nearest) ) { if ( vehicle_info != NULL ) cheat_state->vehicle.stick ^= 1; else cheat_state->actor.stick ^= 1; id = actor_find_nearest( ACTOR_ALIVE | ACTOR_NOT_SAME_VEHICLE ); } if ( (vehicle_info != NULL && cheat_state->vehicle.stick) || (actor_info != NULL && cheat_state->actor.stick) ) { // remove any bad vehicle or actor stuffs if ( isBadPtr_GTA_pVehicle(vehicle_info) ) vehicle_info = NULL; if ( isBadPtr_GTA_pPed(actor_info) ) actor_info = NULL; /* check if actor has disappeared.. and if it has, switch to teh nearest */ if ( id != -1 && actor_info_get(id, ACTOR_ALIVE) == NULL ) id = actor_find_nearest( ACTOR_ALIVE | ACTOR_NOT_SAME_VEHICLE ); if ( KEY_PRESSED(set.key_stick_prev) ) id = actor_find( id, -1, ACTOR_ALIVE | ACTOR_NOT_SAME_VEHICLE ); if ( KEY_PRESSED(set.key_stick_next) ) id = actor_find( id, 1, ACTOR_ALIVE | ACTOR_NOT_SAME_VEHICLE ); /* no actors to stick to */ if ( id == -1 ) { cheat_state_text( "No players found; stick disabled." ); cheat_state->vehicle.stick = 0; cheat_state->actor.stick = 0; return; } /* get actor struct for the actor we're sticking to */ actor_stick = actor_info_get( id, ACTOR_ALIVE | ACTOR_NOT_SAME_VEHICLE ); if ( actor_stick == NULL ) return; /* is this actor in a vehicle? */ vehicle_stick = actor_vehicle_get( actor_stick ); base_stick = vehicle_stick ? &vehicle_stick->base : &actor_stick->base; base_self = vehicle_info ? &vehicle_info->base : &actor_info->base; speed_stick = vehicle_stick ? vehicle_stick->speed : actor_stick->speed; speed_self = vehicle_info ? vehicle_info->speed : actor_info->speed; spin_stick = vehicle_stick ? vehicle_stick->spin : actor_stick->spin; spin_self = vehicle_info ? vehicle_info->spin : actor_info->spin; /* allow warping to work + always warp towards whatever we're sticking to... but only when we're in a vehicle */ if ( KEY_PRESSED(set.key_warp_mod) && vehicle_info != NULL ) { float out[4]; /* multiply the matrix of whatever we're sticking to with the user supplied vector */ matrix_vect4_mult( base_stick->matrix, set.stick_vect, out ); /* multiply the result with the negative warp-speed value, and put it in the speed vector (negative because we want to warp towards teh target, not away from it */ vect3_mult( out, -set.warp_speed, speed_self ); } if ( !KEY_DOWN(set.key_warp_mod) ) { float d[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; float accel_mult = 1.0f; float out[4]; /* handle stick movement keys */ if ( KEY_DOWN(set.key_stick_forward) ) d[1] += 1.0f; if ( KEY_DOWN(set.key_stick_backward) ) d[1] -= 1.0f; if ( KEY_DOWN(set.key_stick_left) ) d[0] -= 1.0f; if ( KEY_DOWN(set.key_stick_right) ) d[0] += 1.0f; if ( KEY_DOWN(set.key_stick_up) ) d[2] += 1.0f; if ( KEY_DOWN(set.key_stick_down) ) d[2] -= 1.0f; if ( KEY_DOWN(set.key_stick_in) ) d[3] -= 1.0f; if ( KEY_DOWN(set.key_stick_out) ) d[3] += 1.0f; if ( !near_zero(set.stick_accel_time) ) { static uint32_t time_start; if ( !vect4_near_zero(d) ) time_start = ( time_start == 0 ) ? time_get() : time_start; else time_start = 0; /* no keys pressed */ /* acceleration */ if ( time_start != 0 ) { float t = TIME_TO_FLOAT( time_get() - time_start ); if ( t < set.stick_accel_time ) accel_mult *= t / set.stick_accel_time; } } /* calculate new vector + dist */ if ( !vect3_near_zero(d) && !vect3_near_zero(set.stick_vect) ) { for ( i = 0; i < 3; i++ ) { d[i] = set.stick_vect[i] * set.stick_vect_dist + d[i] * time_diff * 8.0f * accel_mult; } set.stick_vect_dist = vect3_length( d ); vect3_normalize( d, set.stick_vect ); } /* move towards/away from the center */ if ( !near_zero(d[3]) ) set.stick_vect_dist += d[3] * time_diff * 40.0f * accel_mult; /* Teleport vehicle detachables */ if ( vehicle_info != NULL ) vehicle_detachables_teleport( vehicle_info, &base_self->matrix[4 * 3], &base_stick->matrix[4 * 3] ); matrix_copy( base_stick->matrix, base_self->matrix ); vect3_copy( speed_stick, speed_self ); vect3_copy( spin_stick, spin_self ); /*base_self->interior_id = base_stick->interior_id; gta_interior_id_set(base_stick->interior_id);*/ /* multiply the matrix of the target with the user supplied vector */ matrix_vect4_mult( base_stick->matrix, set.stick_vect, out ); /* multiply the result with the user supplied vector distance */ vect3_mult( out, set.stick_vect_dist, out ); /* and add it to our position */ vect3_vect3_add( &base_self->matrix[4 * 3], out, &base_self->matrix[4 * 3] ); if ( vehicle_info != NULL ) { /* Teleport detachables again :p */ vehicle_detachables_teleport( vehicle_info, &base_stick->matrix[4 * 3], &base_self->matrix[4 * 3] ); vehicle_prevent_below_height( vehicle_info, set.stick_min_height ); } else if ( actor_info != NULL ) { // new pedFlags actor_info->pedFlags.bIsStanding = true; actor_info->pedFlags.bWasStanding = true; actor_info->pedFlags.bStayInSamePlace = true; } } } }
void cheat_handle_hp ( struct vehicle_info *vehicle_info, struct actor_info *actor_info, float time_diff ) { traceLastFunc( "cheat_handle_hp()" ); static float prev_pos[3]; if ( KEY_PRESSED(set.key_hp_cheat) ) cheat_state->_generic.hp_cheat ^= 1; /* toggle hp cheat */ // this will make SP enemies invulnerable // now checking for a valid SAMP game if (g_SAMP) { if ( cheat_state->_generic.hp_cheat && cheat_state->actor.invulnerable && !set.hp_disable_inv_sp_enemies ) patcher_install( &patch_actor_hp_extraInv ); else patcher_remove( &patch_actor_hp_extraInv ); } if ( cheat_state->_generic.hp_cheat && cheat_state->actor.invulnerable ) { patcher_install( &patch_actor_hp ); //patcher_install( &patch_actor_hp2 ); //patcher_install( &patch_actor_hp3 ); } else { patcher_remove( &patch_actor_hp ); //patcher_remove( &patch_actor_hp2 ); //patcher_remove( &patch_actor_hp3 ); } if ( cheat_state->_generic.hp_cheat && cheat_state->vehicle.invulnerable ) patcher_install( &patch_vehicle_hp ); else patcher_remove( &patch_vehicle_hp ); if ( vehicle_info != NULL ) { struct vehicle_info *info = vehicle_info; struct vehicle_info *temp; // actor_info is NULL, if vehicle_info is not ( we need the actor though ) actor_info = actor_info_get( ACTOR_SELF, 0 ); if ( cheat_state->_generic.hp_cheat ) { for ( temp = info; temp != NULL; temp = temp->trailer ) { if(temp == NULL) return; /* minimum hp */ if ( cheat_state->vehicle.hp_minimum_on && temp->hitpoints < set.hp_minimum ) temp->hitpoints = set.hp_minimum; if ( set.hp_keep_vehicleHPsane ) { // actor_info was NULL duh if ( temp->passengers[0] == actor_info && temp->hitpoints > 1000.0f ) { if ( set.hp_minimum <= 1000.0f ) temp->hitpoints = 1000.0f; else if ( temp->hitpoints > set.hp_minimum ) temp->hitpoints = set.hp_minimum; } } /* regen */ if ( temp->hitpoints < 1000.0f ) temp->hitpoints += time_diff * set.hp_regen; if ( cheat_state->vehicle.invulnerable ) { temp->m_nVehicleFlags.bCanBeDamaged = false; //temp->flags |= VEHICLE_FLAGS_INVULNERABLE; /* invulnerable to most things */ temp->flags &= ~2; /* make sure we're not frozen :p */ //if ( temp->pulling_truck != NULL ) // temp->hitpoints = 1000.0f; } else { temp->m_nVehicleFlags.bCanBeDamaged = true; //temp->flags &= ~VEHICLE_FLAGS_INVULNERABLE; } if ( cheat_state->vehicle.hp_tire_support ) cheat_vehicle_tires_set( temp, 0 ); /* if(cheat_state->vehicle.is_engine_on == 1) temp->m_nVehicleFlags.bEngineOn = 1; else if((cheat_state->vehicle.is_engine_on == 0)) temp->m_nVehicleFlags.bEngineOn = 0; */ // temp->engine_state |= 16; // protect against engine stalls if ( !set.trailer_support ) break; } } else { for ( temp = info; temp != NULL; temp = temp->trailer ) { if(temp == NULL) return; // HP cheat disabled - keep HP value sane if ( set.hp_keep_vehicleHPsane ) { if ( temp->hitpoints > 1000.0f ) temp->hitpoints = 1000.0f; } temp->m_nVehicleFlags.bCanBeDamaged = true; //temp->flags &= ~VEHICLE_FLAGS_INVULNERABLE; if ( !set.trailer_support ) break; } } } if ( actor_info != NULL ) { struct actor_info *info = actor_info; if ( cheat_state->_generic.hp_cheat ) { if ( info->hitpoints < 100.0f ) info->hitpoints += time_diff * set.hp_regen_onfoot; } if ( cheat_state->_generic.hp_cheat && cheat_state->actor.invulnerable ) { // invulnerability is on - at least be // invulnerable against non explosive projectiles info->flags |= 4; if ( set.hp_actor_explosion_inv ) info->flags |= 8; if ( set.hp_actor_fall_inv ) info->flags |= 64; if ( set.hp_actor_fire_inv ) info->flags |= 128; //info->flags |= ACTOR_FLAGS_INVULNERABLE; } else info->flags &= ~ACTOR_FLAGS_INVULNERABLE; } }
const char *debug_classify_pointer ( const void *ptr ) { const struct classify_pool *pools = classify_pool; static char str[4][64]; static int idx = -1; int i; idx = ( idx + 1 ) % 4; strcpy( str[idx], "" ); for ( i = 0; pools[i].pool_ptr != NULL; i++ ) { struct pool *pool = (struct pool *)( UINT_PTR ) * (uint32_t *)pools[i].pool_ptr; const struct classify_table *table = pools[i].table; int item_size = pools[i].item_size; const char *pool_name = pools[i].name; void *pool_end; if ( pool == NULL ) continue; if ( pool->size <= 0 || pool->start == NULL ) continue; pool_end = (void *)( (uint8_t *)pool->start + item_size * pool->size ); if ( ptr >= pool->start && ptr < pool_end ) { int offset = (int)( (uint8_t *)ptr - (uint8_t *)pool->start ); int item_offset = offset % item_size; int id = offset / item_size; snprintf( str[idx], sizeof(str[0]), "pool(%s)[%d]+%d", pool_name, id, item_offset ); // actor (peds) pool if( g_SAMP != NULL ) { if ( pools[i].pool_ptr == (void *)ACTOR_POOL_POINTER ) { int samp_id = getSAMPPlayerIDFromGTAPed( actor_info_get(id, 0) ); const char *samp_name = getPlayerName( samp_id ); if ( samp_name != NULL ) { snprintf( str[idx] + strlen(str[idx]), sizeof(str[0]) - strlen(str[idx]), " %d:\"%s\"", samp_id, samp_name ); } } } if ( table != NULL ) { strlcat( str[idx], ": ", sizeof(str[0]) ); while ( table->descr != NULL ) { if ( item_offset >= table->offset && item_offset < table->offset + table->len ) { strlcat( str[idx], table->descr, sizeof(str[0]) ); break; } table++; } if ( table->descr == NULL ) strlcat( str[idx], "Unknown", sizeof(str[0]) ); } return str[idx]; } } if ( g_SAMP != NULL && (void *)g_SAMP >= ptr && (uint8_t *) (g_SAMP + 1) < ptr ) return "SPL (SA:MP Player List)"; if ( g_Players != NULL ) { for ( i = 0; i < SAMP_MAX_PLAYERS; i++ ) { if ( g_Players->iIsListed[i] != 1 ) continue; if ( (void *)g_Players->pRemotePlayer >= ptr && (void *)(g_Players->pRemotePlayer + 1) < ptr ) { snprintf( str[idx], sizeof(str[0]), "SPL %d:\"%s\"", i, getPlayerName(i) ); return str[idx]; } } } return "-"; }
void cheat_hook ( HWND wnd ) { traceLastFunc( "cheat_hook()" ); // get the time static uint64_t time_last; __time_current = __time_get(); g_timeDiff = TIME_TO_DOUBLE(time_get() - time_last); // for looping int i; // install keyhook keyhook_maybe_install( wnd ); // setup menu menu_maybe_init(); traceLastFunc( "cheat_hook()" ); /* initialize state */ if ( cheat_state == NULL ) { // set default cheat_state variables cheat_state = &__cheat_state; cheat_state->_generic.spoof_weapon = -1; cheat_state->_generic.money = set.money_enabled; cheat_state->_generic.weapon = set.weapon_enabled; cheat_state->_generic.vehicles_unlock = false; cheat_state->_generic.vehicles_warp_invert = true; cheat_state->actor.invulnerable = true; cheat_state->vehicle.invulnerable = true; cheat_state->vehicle.hp_tire_support = true; cheat_state->vehicle.hp_minimum_on = 1; cheat_state->vehicle.hp_regen_on = 1; cheat_state->actor.hp_regen_on = 1; cheat_state->vehicle.brkdance = 0; cheat_state->game_speed = 1.0f; cheat_state->vehicle.is_engine_on = 1; cheat_state->_generic.interior_patch_enabled = 0; // refreshes any cheat_state stuff set from the INI ini_load_setSettings(); /* install patches from the .ini file */ for ( i = 0; i < INI_PATCHES_MAX; i++ ) { if ( set.patch[i].name != NULL && set.patch[i].ini_auto ) patcher_install( &set.patch[i] ); } if ( g_dwSAMP_Addr != NULL ) { for ( i = 0; i < INI_SAMPPATCHES_MAX; i++ ) { if ( set.sampPatch[i].name != NULL && set.sampPatch[i].ini_auto ) patcher_install( &set.sampPatch[i] ); } } } /* end initialize state */ // set cheat state to "off" cheat_state->state = CHEAT_STATE_NONE; /* setup & refresh actor pool */ pool_actor = *(struct pool **)ACTOR_POOL_POINTER; if ( pool_actor == NULL || pool_actor->start == NULL || pool_actor->size <= 0 ) return; /* setup & refresh vehicle pool */ pool_vehicle = *(struct pool **)VEHICLE_POOL_POINTER; if ( pool_vehicle == NULL || pool_vehicle->start == NULL || pool_vehicle->size <= 0 ) return; ////////////////////////////////////////// // looks like we have pools so continue // struct actor_info *actor_info; struct vehicle_info *vehicle_info; actor_info = actor_info_get( ACTOR_SELF, ACTOR_ALIVE ); vehicle_info = vehicle_info_get( VEHICLE_SELF, 0 ); /* no vehicle, and no actor. exit. */ if ( vehicle_info == NULL && actor_info == NULL ) { if ( cheat_state->actor.air_brake || cheat_state->actor.stick || cheat_state->vehicle.air_brake || cheat_state->vehicle.stick ) { cheat_state->actor.air_brake = 0; cheat_vehicle_air_brake_set( 0 ); cheat_state->actor.stick = 0; cheat_state->vehicle.stick = 0; cheat_state_text( "Air brake / stick disabled" ); } } else { if ( vehicle_info == NULL ) { if ( cheat_state->vehicle.air_brake || cheat_state->vehicle.stick ) { cheat_vehicle_air_brake_set( 0 ); cheat_state->vehicle.stick = 0; cheat_state_text( "Air brake / stick disabled" ); } cheat_state->state = CHEAT_STATE_ACTOR; // reset infinite NOS toggle state if ( cheat_state->vehicle.infNOS_toggle_on ) { cheat_state->vehicle.infNOS_toggle_on = false; patcher_remove( &patch_vehicle_inf_NOS ); } } else { if ( cheat_state->actor.air_brake || cheat_state->actor.stick ) { cheat_state->actor.air_brake = 0; cheat_state->actor.stick = 0; cheat_state_text( "Air brake / stick disabled" ); } cheat_state->state = CHEAT_STATE_VEHICLE; } // post GTA initialization initizalization routines if ( m_InitStages == 0 ) { // setup CGame & friends pGameInterface = new CGameSA(); pPools = pGameInterface->GetPools(); //pGameInterface->Initialize(); // all this does so far is disable modshops and pay&sprays // this seems to fix SAMP's load hang bug //pGameInterface->StartGame(); // we have to add ourself to the pool first so that we are always the 1st ref // NEW --> use the global external: pPedSelf pPedSelf = pGameInterface->GetPools()->AddPed( (DWORD *)actor_info ); pPedSelfSA = pPedSelf->GetPedInterface(); // install all startup hooks cheat_hookers_installhooks(); // increment stage m_InitStages++; } else if ( m_InitStages == 1 ) { // load all the weapon models loadAllWeaponModels(); // get funky //pGameInterface->GetAudio()->PlayBeatTrack(2); // increment stage m_InitStages++; } } if ( cheat_state->state != CHEAT_STATE_NONE ) { // keep this updated, cos something is switching it now pPedSelf = pPools->GetPedFromRef( CPOOLS_PED_SELF_REF ); pPedSelfSA = pPedSelf->GetPedInterface(); } static bool chat_set_once = false; if ( !chat_set_once && set.d3dtext_chat ) { if ( g_Chat != NULL && g_Chat->iChatWindowMode ) { //Log("Disabling SA:MP chat text."); g_Chat->iChatWindowMode = 0; chat_set_once = true; } } // sets kill text to s0beit mode if enabled from INI static bool kill_set_once = false; if ( !kill_set_once && set.d3dtext_kill ) { if ( g_DeathList != NULL && g_DeathList->iEnabled ) { g_DeathList->iEnabled = 0; kill_set_once = true; } } // more random than random if ( rand() % 5000 == 0 ) srand( rand() + time_get() ); // OMGWTFBBQ?!? if ( cheat_panic() ) { cheat_state->state = CHEAT_STATE_NONE; goto out; } // menus are good menu_run(); // install volatile patches from the .ini file for ( i = 0; i < INI_PATCHES_MAX; i++ ) { if ( set.patch[i].name != NULL && set.patch[i].has_volatile && set.patch[i].installed ) patcher_install( &set.patch[i] ); } // generic stuff - these want to run even though we're dead cheat_handle_debug( wnd ); cheat_handle_misc(); cheat_handle_spoof_weapon(); cheat_handle_weapon(); gta_game_speed_set( cheat_state->game_speed ); cheat_main_display_debug_stuff(g_timeDiff); if ( cheat_state->state != CHEAT_STATE_NONE ) { // generic stuff cheat_handle_weapon_disable(); cheat_handle_money(); ////////////////////////////////////////////////////////////////// // this should be removed after reworking weapon cheat function // //if ( set.restore_weapons_after_death ) // * (uint8_t *)0x5E6320 = 0xC3; cheat_handle_unlock(); cheat_handle_checkpoint(); // do stuff :p if ( cheat_state->state == CHEAT_STATE_VEHICLE ) { cheat_main_vehicle( g_timeDiff ); } else if ( cheat_state->state == CHEAT_STATE_ACTOR ) { cheat_main_actor( g_timeDiff ); } if ( KEY_PRESSED(set.key_disable_Wall_Collisions) ) { cheat_state->_generic.nocols_walls_enabled ^= 1; if ( cheat_state->_generic.nocols_walls_enabled ) patcher_install( &patch_NoColsWalls ); else patcher_remove( &patch_NoColsWalls ); } for ( i = 0; i < INI_PATCHES_MAX; i++ ) { if ( set.patch[i].name != NULL && KEY_PRESSED(set.patch[i].ini_hotkey) ) { if ( set.patch[i].installed || set.patch[i].failed ) patcher_remove( &set.patch[i] ); else patcher_install( &set.patch[i] ); } } for ( i = 0; i < INI_SAMPPATCHES_MAX; i++ ) { if ( set.sampPatch[i].name != NULL && KEY_PRESSED(set.sampPatch[i].ini_hotkey) ) { if ( set.sampPatch[i].installed || set.sampPatch[i].failed ) patcher_remove( &set.sampPatch[i] ); else patcher_install( &set.sampPatch[i] ); } } if ( KEY_PRESSED(set.key_vehicle_jumper) ) { int iVehicleID = vehicle_find_nearest( VEHICLE_ALIVE + VEHICLE_NOTBURNING ); vehicleJumper( iVehicleID ); } if ( KEY_PRESSED(set.key_vehicle_occupied_jumper) ) { int iVehicleID = vehicle_find_nearest( VEHICLE_ALIVE + VEHICLE_NOTBURNING + VEHICLE_OCCUPIED ); vehicleJumper( iVehicleID ); } } // cheat_state->state != CHEAT_STATE_NONE // hack some SA:MP, shall we? if ( g_SAMP && g_renderSAMP_initSAMPstructs ) sampMainCheat(); out: ; if (gta_menu_active()) { keyhook_clear_states(); *(BYTE *)0xB7CB49 = 0; // game not paused even if we are in the menu. } else keyhook_run(); time_last = time_get(); }
int cheat_panic ( void ) { traceLastFunc( "cheat_panic()" ); static int pstate_map = 0, // m0d's map pstate_d3dtext_hud = 0, // hud bar pstate_actor_hp_nSP = 0, // "Extra actor invincibility" patch (invulnerable single player enemies) pstate_actor_hp_SP = 0, // "Extra actor invincibility2" patch (no problems in SP) pstate_vehicle_hp = 0, // vehicle hp patch pstate_generic_menu = 0, // m0d's menu pstate_infnos = 0, // infinite NOS pstate_ini[INI_PATCHES_MAX], pstate_dummy_aligner; // this should all be a structure, static = DOING IT WRONG int i; // sa-mp related static int pstate_chat = 0, // chat pstate_deathlist = 0; // deathlist if ( KEY_PRESSED(set.key_panic) ) { // toggle panic cheat_state->_generic.cheat_panic_enabled ^= 1; if ( cheat_state->_generic.cheat_panic_enabled ) { struct actor_info *actor_info = actor_info_get( ACTOR_SELF, ACTOR_ALIVE ); if ( actor_info ) { actor_info->flags &= ~ACTOR_FLAGS_INVULNERABLE; actor_info->weapon_slot = 0; } // remove infinite NOS pstate_infnos = cheat_state->vehicle.infNOS_toggle_on; cheat_state->vehicle.infNOS_toggle_on = false; patcher_remove( &patch_vehicle_inf_NOS ); if ( pPedSelf->GetVehicle() ) { CVehicle *pVehicleSelf = pPedSelf->GetVehicle(); CVehicle *pVehicleTemp = NULL; for ( pVehicleTemp = pVehicleSelf; pVehicleTemp != NULL; pVehicleTemp = pVehicleTemp->GetTowedVehicle() ) { pVehicleTemp->SetGravity( &CVector(0.0, 0.0, -1.0) ); pVehicleTemp->SetCanBeDamaged( true ); if ( !set.trailer_support ) break; } // remove inf NOS if ( pstate_infnos ) { pVehicleSelf->RemoveVehicleUpgrade( 1010 ); //pVehicleSelf->AddVehicleUpgrade( 1010 ); } // reset overrideLights, pstate not needed, will be reactivated on demand if ( set.enable_car_lights_at_day_time ) pVehicleSelf->SetOverrideLights( 0 ); } // hud bar, this should probably become a cheat_state pstate_d3dtext_hud = set.d3dtext_hud; set.d3dtext_hud = 0; // m0d's map pstate_map = cheat_state->_generic.map; cheat_state->_generic.map = 0; // m0d's menu pstate_generic_menu = cheat_state->_generic.menu; cheat_state->_generic.menu = 0; // remove "Extra actor invincibility" patch pstate_actor_hp_nSP = patch_actor_hp_extraInv.installed; patcher_remove( &patch_actor_hp_extraInv ); pstate_actor_hp_SP = patch_actor_hp.installed; patcher_remove( &patch_actor_hp ); // remove vehicle hp patch pstate_vehicle_hp = patch_vehicle_hp.installed; patcher_remove( &patch_vehicle_hp ); // just call with null vehicle info to disable cheat_handle_vehicle_fly( NULL, 0.0f ); for ( i = 0; i < INI_PATCHES_MAX; i++ ) { // added to not remove volatile patches if ( !set.patch[i].has_volatile ) { pstate_ini[i] = set.patch[i].installed; patcher_remove( &set.patch[i] ); } } // turn off kill & chat if ( g_DeathList != NULL ) { pstate_deathlist = g_DeathList->iEnabled; g_DeathList->iEnabled = 1; } if ( g_Chat != NULL ) { pstate_chat = g_Chat->iChatWindowMode; g_Chat->iChatWindowMode = 2; } } else { // restore infinite NOS if ( pstate_infnos ) { cheat_state->vehicle.infNOS_toggle_on = true; patcher_install( &patch_vehicle_inf_NOS ); } // vehicle stuff CPed *pPedSelf = pPools->GetPedFromRef( CPOOLS_PED_SELF_REF ); if ( pPedSelf->GetVehicle() ) { CVehicle *pVehicleSelf = pPedSelf->GetVehicle(); // restore inf NOS if ( pstate_infnos ) { pVehicleSelf->AddVehicleUpgrade( 1010 ); } } // restore "Extra actor invincibility" patch if ( pstate_actor_hp_nSP ) patcher_install( &patch_actor_hp_extraInv ); if ( pstate_actor_hp_SP ) patcher_install( &patch_actor_hp ); // restore vehicle hp patch if ( pstate_vehicle_hp ) patcher_install( &patch_vehicle_hp ); // restore some cheat_states set.d3dtext_hud = pstate_d3dtext_hud; cheat_state->_generic.map = pstate_map; cheat_state->_generic.menu = pstate_generic_menu; // restore patches for ( i = 0; i < INI_PATCHES_MAX; i++ ) { if ( pstate_ini[i] ) patcher_install( &set.patch[i] ); } // restore kill & chat if ( g_DeathList != NULL ) { g_DeathList->iEnabled = pstate_deathlist; } if ( g_Chat != NULL ) { g_Chat->iChatWindowMode = pstate_chat; } // clear cheat state text cheat_state_text( NULL ); } } return cheat_state->_generic.cheat_panic_enabled; }