void cheat_cpmaster() { if (cheat_state->_generic.cpm) { float checkPos[3] = { 0, 0, 0 }; float playerPos[3] = { pPedSelf->GetPosition()->fX, pPedSelf->GetPosition()->fY, pPedSelf->GetPosition()->fZ }; static int iTime = 0; if ((int)GetTickCount() - iTime > set.coord_time) { if (g_SAMPMisc->iRaceCheckpointEnabled) { vect3_copy(g_SAMPMisc->vecRaceCheckpointPos, checkPos); checkPos[2] += set.cpm_offset; float lenX = checkPos[0] - playerPos[0]; float lenY = checkPos[1] - playerPos[1]; float lenXY = sqrt(pow(lenX, 2) + pow(lenY, 2)); float sinA = lenX / lenXY, cosA = lenY / lenXY; if (vect3_dist(checkPos, playerPos) > set.coord_dist) { playerPos[0] += sinA * set.coord_dist; playerPos[1] += cosA * set.coord_dist; playerPos[2] = checkPos[2] - 40.0f; } else vect3_copy(checkPos, playerPos); cheat_teleport(playerPos, 0); } iTime = GetTickCount(); } struct vehicle_info *info = vehicle_info_get(-1, 0x01); if (info != NULL) vehicleUnflip(info); } }
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_coordmaster() { if (!cheat_state->_generic.coordmaster) return; if(vehicle_info *info = vehicle_info_get(-1, 1)) vehicleUnflip(info); static DWORD dwCount = 0; if (GetTickCount() < dwCount) return; float fPosition[3] = { pPedSelf->GetPosition()->fX, pPedSelf->GetPosition()->fY, pPedSelf->GetPosition()->fZ }; float fDist = vect3_dist(fPosition, set.coord_target); if (fDist > set.coord_dist) { float fDistXY = vect2_dist(fPosition, set.coord_target); float fDistSin = (set.coord_target[0] - fPosition[0]) / fDistXY; float fDistCos = (set.coord_target[1] - fPosition[1]) / fDistXY; fPosition[0] += fDistSin * set.coord_dist; fPosition[1] += fDistCos * set.coord_dist; if (set.coord_height != fPosition[2]) { if (set.coord_height - fPosition[2] > set.coord_dist * 0.5f) { float fK = set.coord_height > fPosition[2] ? 0.5f : -0.5f; fPosition[2] += set.coord_dist * fK; } else fPosition[2] = set.coord_height; } else if (fDistXY < set.coord_dist) { float fK = set.coord_target[2] > fPosition[2] ? 0.5f : -0.5f; fPosition[2] += set.coord_dist * fK; } } else { vect3_copy(set.coord_target, fPosition); Log("[RAKBOT] Вы достигли места назначения!"); cheat_state->_generic.coordmaster = 0; } cheat_teleport(fPosition, gta_interior_id_get()); GTAfunc_LockActor(cheat_state->_generic.coordmaster ? 1 : 0); dwCount = GetTickCount() + set.coord_time; }
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_vehicle_recording ( struct vehicle_info *info, float time_diff ) { char buffer[512]; float set_speed[3]; float set_spin[3]; if ( info == NULL || !set.recording_activated ) return; traceLastFunc( "cheat_handle_vehicle_recording()" ); // recording key if ( KEY_PRESSED(set.key_recording_record) ) { if ( rec_state == RECORDING_RECORD ) { rec_maxNum = rec_index; rec_state = RECORDING_OFF; return; } else if ( rec_state == RECORDING_OFF ) { rec_state = RECORDING_RECORD; rec_maxNum = 0; rec_index = 0; rec_playNext = 0.0f; } } if ( KEY_PRESSED(set.key_recording_continueAfterFinish) ) rec_continueAfterFin ^= 1; // play keys if ( (KEY_PRESSED(set.key_recording_play) || KEY_PRESSED(set.key_recording_customSpeed) || KEY_PRESSED(set.key_recording_rev) || KEY_PRESSED(set.key_recording_rev_customSpeed)) ) { // if record playing if ( rec_state >= RECORDING_PLAY ) { rec_state = RECORDING_OFF; return; } else if ( rec_state == RECORDING_OFF ) { // something to play? if ( rec_maxNum <= 0 ) { rec_state = RECORDING_OFF; return; } rec_index = 0; rec_playNext = 0.0f; if ( KEY_PRESSED(set.key_recording_play) ) rec_state = RECORDING_PLAY; else if ( KEY_PRESSED(set.key_recording_customSpeed) ) rec_state = RECORDING_PLAY_CUSTOMSPEED; else if ( KEY_PRESSED(set.key_recording_rev) ) { rec_index = (rec_maxNum-1); rec_state = RECORDING_PLAY_REV; } else if ( KEY_PRESSED(set.key_recording_rev_customSpeed) ) { rec_index = (rec_maxNum-1); rec_state = RECORDING_PLAY_REV_CUSTOMSPEED; } // user set a maximum distance to entry point? if ( set.recording_maxDistToEntryPoint > 0.0f ) { // check if current selected index is in maxRange, else look for a point closest // to the selected beginning, which is in the maxRange if ( vect3_dist(rec_pos[rec_index], &info->base.matrix[4*3]) > set.recording_maxDistToEntryPoint ) { int i = rec_index; int rec_index_new = -1; // not a entry point we want (too far), lets find a better one while ( i >= 0 && i < rec_maxNum ) { if ( vect3_dist(rec_pos[i], &info->base.matrix[4*3]) <= set.recording_maxDistToEntryPoint ) { rec_index_new = i; break; } if ( rec_state == RECORDING_PLAY_REV || rec_state == RECORDING_PLAY_REV_CUSTOMSPEED ) i--; else i++; } // nothing close enough found if ( rec_index_new == -1 ) { rec_state = RECORDING_OFF; cheat_state_text( "Too far from route - maxDist: %0.2f", set.recording_maxDistToEntryPoint ); } else rec_index = rec_index_new; } } } } if ( rec_state == RECORDING_RECORD ) { pD3DFont->PrintShadow( 99, 250, D3DCOLOR_ARGB(255, 255, 0, 0), "Vehicle Recording" ); if ( (TIME_TO_FLOAT(time_get()) - rec_playNext) < 0.0f ) return; vect3_copy( &info->base.matrix[4*3+0], rec_pos[rec_index] ); vect3_copy( &info->base.matrix[4*0+0], &rec_angle[rec_index][0] ); vect3_copy( &info->base.matrix[4*1+0], &rec_angle[rec_index][3] ); vect3_copy( info->spin, rec_spin[rec_index] ); vect3_copy( info->speed, rec_speed[rec_index] ); rec_index++; rec_playNext = TIME_TO_FLOAT(time_get()) + TIME_TO_FLOAT((float)MSEC_TO_TIME(REC_DEFAULT_WAITTIME)); if ( rec_index == (REC_ARRAYSIZE-1) ) { rec_maxNum = rec_index; rec_state = RECORDING_OFF; } } // >= because only play states should follow after RECORDING_PLAY else if ( rec_state >= RECORDING_PLAY ) { // deactivate playing records while air brakeing/sticking if ( cheat_state->vehicle.air_brake || cheat_state->vehicle.stick ) { rec_state = RECORDING_OFF; return; } // move into some better place (maybe hud?) _snprintf_s( buffer, sizeof(buffer)-1, "Vehicle Play Record%s%s", (rec_state == RECORDING_PLAY_REV || rec_state == RECORDING_PLAY_REV_CUSTOMSPEED) ? " (Rev)" : "", rec_continueAfterFin ? " (Continuously)" : "" ); _snprintf_s( buffer, sizeof(buffer)-1, "%s%s", buffer, (rec_state == RECORDING_PLAY_REV_CUSTOMSPEED || rec_state == RECORDING_PLAY_CUSTOMSPEED) ? " (Custom Speed)" : "" ); pD3DFont->PrintShadow( 99, 250, D3DCOLOR_ARGB(255, 0, 255, 0), buffer ); // will need overtime variable for data row skipping float overtime = (TIME_TO_FLOAT(time_get()) - rec_playNext); // do nothing, if the planned next-frame time wasn't reached yet if ( overtime < 0.0f ) return; vect3_copy( rec_pos[rec_index], &info->base.matrix[4*3+0] ); vect3_copy( &rec_angle[rec_index][0], &info->base.matrix[4*0+0] ); vect3_copy( &rec_angle[rec_index][3], &info->base.matrix[4*1+0] ); vect3_copy( rec_spin[rec_index], set_spin ); vect3_copy( rec_speed[rec_index], set_speed ); // multiply speed/spin (for ff mode) and set the playNextTick if ( rec_state == RECORDING_PLAY_CUSTOMSPEED || rec_state == RECORDING_PLAY_REV_CUSTOMSPEED ) { vect3_mult( set_spin, set.recording_play_customSpeed, set_spin ); vect3_mult( set_speed, set.recording_play_customSpeed, set_speed ); // custom speed multiplier faster/higher than possible to play one by one? // if its not the first point (rec_playNext still default) skip a few if ( overtime > 0.0f && rec_playNext != 0.0f ) { // (now-plannedArrival) = overtime -> plannedArrival is way back in the past [so we gotta skip // some of the rows to keep up with the recording/show it 'fluent' (or at least somehow timed correct)] // determine how many data rows we gotta skip ((now-plannedArrival)/timePerRow) float skipAble = overtime / (float)(TIME_TO_FLOAT((float)MSEC_TO_TIME(REC_DEFAULT_WAITTIME))/set.recording_play_customSpeed); if ( skipAble > 1.0f ) { int skipAFew = ceil(skipAble); if ( skipAFew > 0 && rec_state >= RECORDING_PLAY_REV ) rec_index -= skipAFew; else if ( skipAFew > 0 ) rec_index += skipAFew; } } // calculate the time for the next data row rec_playNext = TIME_TO_FLOAT(time_get()) + (TIME_TO_FLOAT((float)MSEC_TO_TIME(REC_DEFAULT_WAITTIME))/set.recording_play_customSpeed ); } else { // in case REC_DEFAULT_WAITTIME is too low, or this code is running on a slow computer // (or player tabbed/paused the game and refocuses the gta window) if ( overtime > 0.0f && rec_playNext != 0.0f ) { // determine how many data rows we gotta skip float skipAble = overtime / (float)(TIME_TO_FLOAT(MSEC_TO_TIME(REC_DEFAULT_WAITTIME))); if ( skipAble > 1.0f ) { int skipAFew = ceil(skipAble); if ( skipAFew > 0 && rec_state >= RECORDING_PLAY_REV ) rec_index -= skipAFew; else if ( skipAFew > 0 ) rec_index += skipAFew; } } rec_playNext = TIME_TO_FLOAT(time_get()) + TIME_TO_FLOAT(MSEC_TO_TIME(REC_DEFAULT_WAITTIME)); } // inverse speed/spin (for rev mode) and set rec_index if ( rec_state >= RECORDING_PLAY_REV ) { vect3_mult( set_spin, -1.0f, set_spin ); vect3_mult( set_speed, -1.0f, set_speed ); rec_index--; // reached end of recording if ( rec_index <= 0 ) { if ( !rec_continueAfterFin ) rec_state = RECORDING_OFF; else { if ( set.recording_maxDistToEntryPoint > 0.0f ) { // deactivate, if new starting position is too far from this point if ( vect3_dist(rec_pos[rec_index], rec_pos[(rec_maxNum-1)]) > set.recording_maxDistToEntryPoint ) rec_state = RECORDING_OFF; } rec_index = (rec_maxNum-1); } } } else { rec_index++; // reached end of recording if ( (rec_index >= (REC_ARRAYSIZE-1) || rec_index >= rec_maxNum) ) { if ( !rec_continueAfterFin ) rec_state = RECORDING_OFF; else { if ( set.recording_maxDistToEntryPoint > 0.0f ) { // deactivate, if new starting position is too far from this point if ( vect3_dist(rec_pos[rec_index], rec_pos[0]) > set.recording_maxDistToEntryPoint ) rec_state = RECORDING_OFF; } rec_index = 0; } } } // copy new speed/spin after it has been adjusted for ff/rev mode vect3_copy( set_spin, info->spin ); vect3_copy( set_speed, info->speed ); } else { rec_state = RECORDING_OFF; } }
void cheat_handle_freeze_vehicles ( struct vehicle_info *vehicle_info, struct actor_info *actor_info ) { traceLastFunc( "cheat_handle_freeze_vehicles()" ); static struct freeze_info *freeze; struct vehicle_info *info; float *pos; int i; if ( KEY_PRESSED(set.key_vehicles_freeze) ) { cheat_state->_generic.vehicles_freeze ^= 1; if ( !cheat_state->_generic.vehicles_freeze && freeze != NULL ) memset( freeze, 0, pool_vehicle->size * sizeof(struct freeze_info) ); } if ( vehicle_info != NULL ) pos = &vehicle_info->base.matrix[4 * 3]; else if ( actor_info != NULL ) pos = &actor_info->base.matrix[4 * 3]; else return; if ( freeze == NULL ) /* XXX free on exit */ { freeze = (struct freeze_info *)malloc( pool_vehicle->size * sizeof(struct freeze_info) ); if ( freeze == NULL ) return; memset( freeze, 0, pool_vehicle->size * sizeof(struct freeze_info) ); } if ( cheat_state->_generic.vehicles_freeze ) { for ( i = 0; i < pool_vehicle->size; i++ ) { if ( (info = vehicle_info_get(i, VEHICLE_ALIVE)) == NULL || info == vehicle_info ) { if ( info == vehicle_info && freeze[i].set ) cheat_vehicle_air_brake_set( 1 ); /* entered a frozen vehicle */ freeze[i].set = 0; continue; } if ( freeze[i].set ) { matrix_copy( freeze[i].matrix, info->base.matrix ); vect3_mult( info->speed, 0.0f, info->speed ); vect3_mult( info->spin, 0.0f, info->spin ); } if ( vehicle_contains_trailer(vehicle_info, info) ) { freeze[i].set = 0; continue; } if ( vect3_dist(pos, &info->base.matrix[4 * 3]) >= 80.0f ) { freeze[i].set = 0; continue; } if ( freeze[i].set ) { continue; } matrix_copy( info->base.matrix, freeze[i].matrix ); freeze[i].set = 1; } } }