SA-MP Forums Archive
Automatically Load Missions - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Automatically Load Missions (/showthread.php?tid=596207)



Automatically Load Missions - AlexuTzVs - 14.12.2015

Код:
new MISIUNESEARA[] = { 1, 3, 5, 7, 9, 2, 4, 5, 8, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 43, 39 };

public LoadMission(playerid,name[])
{
	if(IsPlayerConnected(playerid))
	{
		new strFromFile2[128];
		new missionname[64];
		format(missionname, sizeof(missionname), "missions/%s.mis",name);
		new File: file = fopen(missionname, io_read);
		if (file)
		{
		    new key[ 256 ] , val[ 256 ];
		    new Data[ 256 ];
		    while ( fread( file , Data , sizeof( Data ) ) )
			{
				key = ini_GetKey( Data );
				if( strcmp( key , "Title" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kTitle], val, 0, strlen(val), 255); }
				if( strcmp( key , "Maker" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kMaker], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text1" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText1], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text2" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText2], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text3" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText3], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text4" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText4], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text5" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText5], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text6" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText6], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text7" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText7], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text8" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText8], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text9" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText9], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text10" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText10], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text11" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText11], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text12" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText12], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text13" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText13], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text14" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText14], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text15" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText15], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text16" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText16], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text17" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText17], val, 0, strlen(val), 255); }
				if( strcmp( key , "Text18" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kText18], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText1" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText1], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText2" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText2], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText3" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText3], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText4" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText4], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText5" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText5], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText6" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText6], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText7" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText7], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText8" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText8], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText9" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText9], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText10" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText10], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText11" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText11], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText12" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText12], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText13" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText13], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText14" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText14], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText15" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText15], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText16" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText16], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText17" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText17], val, 0, strlen(val), 255); }
				if( strcmp( key , "GText18" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayMission[kGText18], val, 0, strlen(val), 255); }
				if( strcmp( key , "CP1X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP1][0] = floatstr( val ); }
				if( strcmp( key , "CP1Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP1][1] = floatstr( val ); }
				if( strcmp( key , "CP1Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP1][2] = floatstr( val ); }
				if( strcmp( key , "CP2X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP2][0] = floatstr( val ); }
				if( strcmp( key , "CP2Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP2][1] = floatstr( val ); }
				if( strcmp( key , "CP2Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP2][2] = floatstr( val ); }
				if( strcmp( key , "CP3X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP3][0] = floatstr( val ); }
				if( strcmp( key , "CP3Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP3][1] = floatstr( val ); }
				if( strcmp( key , "CP3Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP3][2] = floatstr( val ); }
				if( strcmp( key , "CP4X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP4][0] = floatstr( val ); }
				if( strcmp( key , "CP4Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP4][1] = floatstr( val ); }
				if( strcmp( key , "CP4Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP4][2] = floatstr( val ); }
				if( strcmp( key , "CP5X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP5][0] = floatstr( val ); }
				if( strcmp( key , "CP5Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP5][1] = floatstr( val ); }
				if( strcmp( key , "CP5Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP5][2] = floatstr( val ); }
				if( strcmp( key , "CP6X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP6][0] = floatstr( val ); }
				if( strcmp( key , "CP6Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP6][1] = floatstr( val ); }
				if( strcmp( key , "CP6Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP6][2] = floatstr( val ); }
				if( strcmp( key , "CP7X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP7][0] = floatstr( val ); }
				if( strcmp( key , "CP7Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP7][1] = floatstr( val ); }
				if( strcmp( key , "CP7Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP7][2] = floatstr( val ); }
				if( strcmp( key , "CP8X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP8][0] = floatstr( val ); }
				if( strcmp( key , "CP8Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP8][1] = floatstr( val ); }
				if( strcmp( key , "CP8Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP8][2] = floatstr( val ); }
				if( strcmp( key , "CP9X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP9][0] = floatstr( val ); }
				if( strcmp( key , "CP9Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP9][1] = floatstr( val ); }
				if( strcmp( key , "CP9Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP9][2] = floatstr( val ); }
				if( strcmp( key , "CP10X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP10][0] = floatstr( val ); }
				if( strcmp( key , "CP10Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP10][1] = floatstr( val ); }
				if( strcmp( key , "CP10Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP10][2] = floatstr( val ); }
				if( strcmp( key , "CP11X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP11][0] = floatstr( val ); }
				if( strcmp( key , "CP11Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP11][1] = floatstr( val ); }
				if( strcmp( key , "CP11Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP11][2] = floatstr( val ); }
				if( strcmp( key , "CP12X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP12][0] = floatstr( val ); }
				if( strcmp( key , "CP12Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP12][1] = floatstr( val ); }
				if( strcmp( key , "CP12Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP12][2] = floatstr( val ); }
				if( strcmp( key , "CP13X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP13][0] = floatstr( val ); }
				if( strcmp( key , "CP13Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP13][1] = floatstr( val ); }
				if( strcmp( key , "CP13Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP13][2] = floatstr( val ); }
				if( strcmp( key , "CP14X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP14][0] = floatstr( val ); }
				if( strcmp( key , "CP14Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP14][1] = floatstr( val ); }
				if( strcmp( key , "CP14Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP14][2] = floatstr( val ); }
				if( strcmp( key , "CP15X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP15][0] = floatstr( val ); }
				if( strcmp( key , "CP15Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP15][1] = floatstr( val ); }
				if( strcmp( key , "CP15Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP15][2] = floatstr( val ); }
				if( strcmp( key , "CP16X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP16][0] = floatstr( val ); }
				if( strcmp( key , "CP16Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP16][1] = floatstr( val ); }
				if( strcmp( key , "CP16Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP16][2] = floatstr( val ); }
				if( strcmp( key , "CP17X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP17][0] = floatstr( val ); }
				if( strcmp( key , "CP17Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP17][1] = floatstr( val ); }
				if( strcmp( key , "CP17Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP17][2] = floatstr( val ); }
				if( strcmp( key , "CP18X" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP18][0] = floatstr( val ); }
				if( strcmp( key , "CP18Y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP18][1] = floatstr( val ); }
				if( strcmp( key , "CP18Z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kCP18][2] = floatstr( val ); }
				if( strcmp( key , "Number" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kNumber] = strval( val ); }
				if( strcmp( key , "Reward" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kReward] = strval( val ); }
				if( strcmp( key , "Toggle" , true ) == 0 ) { val = ini_GetValue( Data ); PlayMission[kToggle] = strval( val ); }
			}
			fclose(file);
			format(strFromFile2, sizeof(strFromFile2), "%s Mission Loaded.",name);
			SendClientMessage(playerid, COLOR_GREEN,strFromFile2);
			format(strFromFile2, sizeof(strFromFile2), "Mission Available: %s, By : %s | Reward: $%s",PlayMission[kTitle],PlayMission[kMaker],FormatMoneys(PlayMission[kReward]));
			SendClientMessageToAll(COLOR_GREEN, strFromFile2);
			MissionPlayable = PlayMission[kNumber];
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREEN,"Mission File not found.");
		}
	}
	return 1;
}
forward setmis(playerid);
public setmis(playerid)
{
		new hour,minute,second;
		gettime(hour,minute,second);
		if (hour == 11 && minute == 00 && second == 00)
		{
  			new rand = random(sizeof(MISIUNESEARA));
			LoadMission(playerid,MISIUNESEARA[rand]);
			return 1;
		}
		if (hour == 13 && minute == 00 && second == 00)
		{
  			new rand = random(sizeof(MISIUNESEARA));
  			SendClientMessageToAll(COLOR_WHITE, "Misiunea de la ora 13:00 a fost activata.");
			LoadMission(playerid,MISIUNESEARA[rand]);
			return 1;
		}
		if (hour == 19 && minute == 00 && second == 00)
		{
			new rand = random(sizeof(MISIUNESEARA));
			LoadMission(playerid,MISIUNESEARA[rand]);
			return 1;
		}

		return 1;
}
Is not working at 11 A.M is not Loading the mission


Re: Automatically Load Missions - AlexuTzVs - 14.12.2015

Bump


Re: Automatically Load Missions - AlexuTzVs - 15.12.2015

Bump - No-one ?


Re: Automatically Load Missions - AlexuTzVs - 16.12.2015

Bump


Re: Automatically Load Missions - Ritzy2K - 16.12.2015

11 am what?


Re: Automatically Load Missions - AlexuTzVs - 16.12.2015

It's setup to Load a Mission at 11 A.M[CLOCK] but is not working


Re: Automatically Load Missions - jamesbond007 - 16.12.2015

removed


Re: Automatically Load Missions - prineside - 16.12.2015

You should read this: https://en.wikipedia.org/wiki/Debug_code
Then you'll be able to determine why your code has wrong behaviour.

People don't want to read and run that heap of code just to say "why it's not working at 11am", because you are able to solve that problem by yourself. You need to know how to debug your code.


Re: Automatically Load Missions - AlexuTzVs - 17.12.2015

I need help that's why i came here because i couldn't find a solution


Re: Automatically Load Missions - AlexuTzVs - 18.12.2015

Bump