Skip to content

Instantly share code, notes, and snippets.

@continue98
Created June 26, 2015 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save continue98/c92b445baee3578577c5 to your computer and use it in GitHub Desktop.
Save continue98/c92b445baee3578577c5 to your computer and use it in GitHub Desktop.
void cmd_save_objects (char *param)
{
FILE *flStolenObjects = NULL;
char filename[512];
snprintf( filename, sizeof(filename), "%s\\stolen_objects.txt", g_szWorkingDirectory);
flStolenObjects = fopen( filename, "a" );
if (flStolenObjects == NULL)return;
DWORD baseObjAddr;
float rotMatrix[3];
int objectscount = 0, radius = 0;
char comment[50];
const struct actor_info *actor_self = actor_info_get( ACTOR_SELF, 0 );
float dist[3] = { 0.0f, 0.0f, 0.0f };
strcpy(comment, "");
sscanf(param, "%d %[^\n]s", &radius, comment);
fprintf(flStolenObjects, "// ================= [SAMP OBJECTS STEALER BY MAZAHACKA] =================\n");
if(strlen(comment))fprintf(flStolenObjects, "// %s\n", comment);
for (int i = 0; i < SAMP_OBJECTS_MAX; i++ )
{
if ( g_SAMP->pPools->pPool_Object->iIsListed[i] != 1 )
continue;
if ( g_SAMP->pPools->pPool_Object->object[i] == NULL )
continue;
if ( g_SAMP->pPools->pPool_Object->object[i]->pGTAObject == NULL )
continue;
float pos[3];
vect3_copy( &g_SAMP->pPools->pPool_Object->object[i]->pGTAObject->base.matrix[4 * 3], pos );
if ( vect3_near_zero(pos) )
continue;
vect3_vect3_sub( &g_SAMP->pPools->pPool_Object->object[i]->pGTAObject->base.matrix[4 * 3], &actor_self->base.matrix[4 * 3], dist );
if(vect3_length(dist) > radius && radius)continue;
baseObjAddr = (DWORD)g_SAMP->pPools->pPool_Object->object[i];
rotMatrix[0] = *(float *)(baseObjAddr + 0xAC);
rotMatrix[1] = *(float *)(baseObjAddr + 0xB0);
rotMatrix[2] = *(float *)(baseObjAddr + 0xB4);
fprintf(flStolenObjects, "CreateObject(%d, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f); // object (%d)\n", g_SAMP->pPools->pPool_Object->object[i]->pGTAObject->base.model_alt_id, pos[0], pos[1], pos[2],
rotMatrix[0], rotMatrix[1], rotMatrix[2], i);
objectscount++;
}
fclose(flStolenObjects);
addMessageToChatWindow("%d objects saved to stolen_objects.txt file.", objectscount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment