Ejemplo n.º 1
0
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;
					}
				}
			}
		}
	}
}
Ejemplo n.º 2
0
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 "-";
}