bool CGamemodeManager::Load(char* gmFile)
{
	if (this->gmIsInit)
		Unload();

	FILE* f = fopen(gmFile, "rb");
	if (!f) return false;
	fclose(f);

	memset((void*)&(this->gmAMX), 0, sizeof(AMX));
	this->gmSleepTime = 0.0f;
	strcpy(szGameModeFileName, gmFile);

	int err = aux_LoadProgram(&(this->gmAMX), szGameModeFileName);
	if (err != AMX_ERR_NONE)
	{
		AMXPrintError(this, &(this->gmAMX), err);
		logprintf("Failed to load '%s' script.", szGameModeFileName);
		return false;
	}

	amx_CoreInit(&(this->gmAMX));
	amx_FloatInit(&(this->gmAMX));
	amx_StringInit(&(this->gmAMX));
	amx_FileInit(&(this->gmAMX));
	amx_TimeInit(&(this->gmAMX));
	//amx_DGramInit(&(this->gmAMX));
	amx_CustomInit(&(this->gmAMX));
	amx_sampDbInit(&(this->gmAMX));

	__Plugins->DoAmxLoad(&(this->gmAMX));

	this->gmIsInit = true;

	int tmp;
	if (!amx_FindPublic(&(this->gmAMX), "OnGameModeInit", &tmp))
		amx_Exec(&(this->gmAMX), (cell*)&tmp, tmp);

	__NetGame->filterscriptsManager->OnGameModeInit();

	cell ret = 0;
	err = amx_Exec(&(this->gmAMX), &ret, AMX_EXEC_MAIN);
	if (err == AMX_ERR_SLEEP)
	{
		this->gmIsSleeping = true;
		this->gmSleepTime = ((float)ret / 1000.0f);
	}
	else if (err != AMX_ERR_NONE)
	{
		this->gmIsSleeping = false;
		AMXPrintError(this, &(this->gmAMX), err);
	}

	return true;
}
bool CNetwork::LoadScript(char *filename) {
    size_t memsize = aux_ProgramSize(filename);
    if(memsize == 0) {
        printf("Script file not found or corrupted\n");
        return false;
    }
	memset((void*)&inimod_amx, 0, sizeof(AMX));
    void * program = malloc(memsize);

    if (program == NULL) {
        printf("Memory allocation for script failed\n");
        return false;
    }
    if(!LoadProgram(filename,program)) {
        printf("Loading script into Abstract Machine failed\n");
        return false;
    }
	amx_CoreInit(&inimod_amx);
	amx_FloatInit(&inimod_amx);
	amx_StringInit(&inimod_amx);
	//amx_FileInit(&inimod_amx);
	amx_TimeInit(&inimod_amx);
    return true;
}