Beispiel #1
0
// native bool:ArrayResize(Array:which, newsize);
static cell AMX_NATIVE_CALL ArrayResize(AMX* amx, cell* params)
{
	CellArray* vec = HandleToVector(amx, params[1]);

	if (vec == NULL)
	{
		return 0;
	}

	if (!vec->resize(params[2]))
	{
		LogError(amx, AMX_ERR_NATIVE, "Unable to resize array to \"%u\"", params[2]);
		return 0;
	}

	return 1;
}
Beispiel #2
0
// native bool:ArrayResize(Array:which, newsize);
static cell AMX_NATIVE_CALL ArrayResize(AMX* amx, cell* params)
{
	CellArray* vec = ArrayHandles.lookup(params[1]);

	if (!vec)
	{
		LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", params[1]);
		return 0;
	}

	if (!vec->resize(params[2]))
	{
		LogError(amx, AMX_ERR_NATIVE, "Unable to resize array to \"%u\"", params[2]);
		return 0;
	}

	return 1;
}
Beispiel #3
0
static cell_t ResizeArray(IPluginContext *pContext, const cell_t *params)
{
	CellArray *array;
	HandleError err;
	HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);

	if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) 
		!= HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
	}

	if (!array->resize(params[2]))
	{
		return pContext->ThrowNativeError("Unable to resize array to \"%u\"", params[2]);
	}

	return 1;
}
Beispiel #4
0
static cell_t CreateArray(IPluginContext *pContext, const cell_t *params)
{
	if (!params[1])
	{
		return pContext->ThrowNativeError("Invalid block size (must be > 0)");
	}

	CellArray *array = new CellArray(params[1]);

	if (params[2])
	{
		array->resize(params[2]);
	}
	
	Handle_t hndl = handlesys->CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
	if (!hndl)
	{
		delete array;
	}

	return hndl;
}