예제 #1
0
파일: netgame.cpp 프로젝트: jovazxc/samp
BOOL CNetGame::SetNextScriptFile(char *szFile)
{
	//char szCurGameModeConsoleVar[64];
	char szConfigFileName[64];
	char *szTemp;
	int  iConfigRepeatCount=0;

	if(NULL == szFile) { 
		// rotate by config

		if(m_iCurrentGameModeRepeat || !m_bFirstGameModeLoaded) { 
			// repeats of this script, cycle to the current
			//m_iCurrentGameModeIndex++;
			m_iCurrentGameModeIndex--;
		}
		
		//m_iCurrentGameModeIndex--;
		szTemp = this->GetNextScriptFile();
		if (szTemp == NULL) return false;

		//logprintf("szTemp is %s\n",szTemp);

		sscanf(szTemp,"%s%d",szConfigFileName,&iConfigRepeatCount);

		// set it and verify the file is readable
		sprintf(szGameModeFile,"gamemodes/%s.amx",szConfigFileName);

		//logprintf("Set szGameModeFile to %s\n",szGameModeFile);

		if(!CanFileBeOpenedForReading(szGameModeFile)) {
			return FALSE;
		}

		if(!m_iCurrentGameModeRepeat) {
			m_iCurrentGameModeRepeat = iConfigRepeatCount;
		}

		m_iCurrentGameModeRepeat--;

		//logprintf("Repeat is %d ConfigRepeat is %d\n",m_iCurrentGameModeRepeat,iConfigRepeatCount);

		m_bFirstGameModeLoaded = TRUE;

		return TRUE;

	} else {
		// set the script from szFile
		
		// set it and verify the file is readable
		sprintf(szGameModeFile,"gamemodes/%s.amx",szFile);

		if(!CanFileBeOpenedForReading(szGameModeFile)) {
			return FALSE;
		}

		m_iCurrentGameModeRepeat = 0;

		return TRUE;
	}
}
예제 #2
0
BOOL CNetGame::setNextGamemodeFile(char* gamemodeStr)
{
	char szConfigFileName[64];
	char* szTemp;
	int  iConfigRepeatCount=0;

	if(gamemodeStr == NULL) 
	{ 
		if(this->currentGameModeRepeat || !this->isFirstGameModeLoad) 
		{ 
			this->currentGameModeIndex--;
		}
		
		szTemp = this->getNextGamemodeFile();
		if (szTemp == NULL) return false;

		sscanf(szTemp, "%s%d", szConfigFileName, &iConfigRepeatCount);

		sprintf(currentGamemodeFile, "gamemodes/%s.amx", szConfigFileName);

		if(!CanFileBeOpenedForReading(currentGamemodeFile))
			return FALSE;

		if(!this->currentGameModeRepeat)
			this->currentGameModeRepeat = iConfigRepeatCount;

		this->currentGameModeRepeat--;

		this->isFirstGameModeLoad = TRUE;

		return TRUE;

	} 
	else
	{
		
		sprintf(currentGamemodeFile, "gamemodes/%s.amx", gamemodeStr);

		if(!CanFileBeOpenedForReading(currentGamemodeFile))
			return FALSE;

		this->currentGameModeRepeat = 0;

		return TRUE;
	}
}