
//	VIETCONG 1
//	GG (Gun Game) script - compatible with synchronized objects
//	made by Ando
// v2.2

/*
	______________DESCRIPTION:
GG (Gun Game) script

Gun Game - fight with everybody. No teams.
Every kill give you new level and new weapon. Who reaches to highest level is winner.



	______________TUTORIAL FOR EDITOR
ENDRULE: Points  min:22 max:22 default:22
RECOVERY POINT:		GG or waypoint name "GG_'nr'"


//	NOTES:
- custom recover point id = 27. Added to editor after batch 1.7 
- added fade for restart
- show player in different color (on/off option in script)
- show players count when "TAB" is pressed (on/off option in script)
- added fade to "Mission completed"
- cleaned
- one definition fix
- "leaving player reset" fix

*/

#include <inc\sc_global.h>
#include <inc\sc_def.h>

#define SHOW_PLAYER_COLOR			1
#define SHOW_PLAYERS_COUNT			1

#define FADE_TIME					0.8
#define RESTART_TIMER				3	//time before actual restart
#define BEGIN_TIMER					3	//

//________________________________Global Variables for MP objects___
//global variable system for object synchro
#define GVAR_SERVER			600 	//	server  ( dont add SC_MP_Gvar_SetSynchro for that) 0 - not server, 1 - server
#define GVAR_COUNT			601 	//  count of object variables ( dont add SC_MP_Gvar_SetSynchro for that)
#define GVAR_USE_start		602 		//start		Global variable

//________________________________Global Variables__________________
#define GVAR_GPHASE			500		// important to use  game phase and channel 500 for synchronised objects 
#define GVAR_WINNER			501
#define GVAR_PLAYERS		300
#define GVAR_PL_POINTS		400

//________________________________Game phases_______________________
#define GPHASE_BEGIN				1	//objects are restarting
#define GPHASE_WAIT_PLAYERS			2	//wait plaiers if needed and respawn for start
#define GPHASE_START_GAME			3	//fade on and spawn
#define GPHASE_GAME					4	//game
#define GPHASE_MISSION_COMPLETED	6


//________________________________Recover___________________________
#define RECOVER_TIME	5.0f		// time to recover player after killed
#define NORECOV_TIME	3.0f		// disable time of recoverplace after recovering someone there
#define REC_WPNAME		"GG_%d"
#define REC_MAX			64

//#define RECOVER_POINT_ID	27			//custom recower point id.
#ifndef SC_MP_RESPAWN_GG
#define	SC_MP_RESPAWN_GG	27			// GG - 27
#endif

#ifndef GVAR_MP_MISSIONTYPE_GG	
#define	GVAR_MP_MISSIONTYPE_GG	18
#endif

//__________________________________________________________________

	





#define LIST_COUNT					22		// count of weapons
int	WEAP_LIST[LIST_COUNT]		= {	10,	//2206 –	Revolver 38
									8,	//2208 –	Tokarev
									15,	//2212 –	SKS Simonov
									9,	//2207 –	Makarov
									7,	//2205 –	Colt M1911

									22,	//2218 –	S&W model 39
									6,	//2204 –	PPS-41
									19,	//2215 –	US-M3
									11,	//2209 –	Remington 870
									23,	//2219 –	PPS-43

									21,	//2217 –	Thompson
									1,	//2201 -	M16
									2,	//2202 -	AK47
									4,	//2203 –	M1 Garand
									25,	//2220 –	M1 Carbine

									17,	//2213 –	M60
									12,	//2210 –	Winchester 70
									14,	//2211 –	SVD Dragunov
									26,	//2221 –	Mosin-Nagant
									28,	//2223 –	Baikal IZH-43

									59,	//2234 -	Grenade
									29 };//2224 -	Knife
// weapon list for TAB info
char	*WEAP_NAME_LIST[LIST_COUNT]		= {	"Revolver 38",
											"Tokarev",
											"SKS Simonov",
											"Makarov",
											"Colt M1911",

											"S&W model 39",
											"PPS-41",
											"US-M3",
											"Remington 870",
											"PPS-43",

											"Thompson",
											"M16",
											"AK47",
											"M1 Garand",
											"M1 Carbine",

											"M60",
											"Winchester 70",
											"SVD Dragunov",
											"Mosin-Nagant",
											"Baikal IZH-43",

											"Grenade",
											"Knife" };



//___________________________

dword gPhase =			GPHASE_BEGIN;
float gPhase_timer =	BEGIN_TIMER;
//___________________________

ushort *player_s; 



dword			cur_handle;
dword			PC_handle;
dword			killer_handle;

s_SC_P_Create	get_weap_inf;



int last_weap=-1;
int cur_weap=0;
int row;
int pl_slot;
int PL_points;
int CUR_PL_points;


dword gRecs = 0;
s_SC_MP_Recover gRec[REC_MAX];
float gRecTimer[REC_MAX];
BOOL player_added;
BOOL weap_removed=FALSE;


dword gEndRule;
dword gEndValue;
float gTime;
float delay_timer;

dword gPlayersConnected = 0;


BOOL    fade_off = TRUE;
float	client_fade_timer = RESTART_TIMER;
float	fade_off_timer;
float	complete_f_timer=0;

BOOL  EnumPls;



BOOL SRV_CheckEndRule(float time){
	int frags;
	dword win_pl;
	BOOL completed=FALSE;

	switch(gEndRule){
		case SC_MP_ENDRULE_TIME:
			if (gPlayersConnected>0) gTime += time;
				SC_MP_EndRule_SetTimeLeft(gTime,gPlayersConnected>0);
				if (gTime>gEndValue) completed=TRUE;
			break;
		case SC_MP_ENDRULE_FRAGS:
			win_pl = SC_MP_GetMaxFragsPl(&frags);
			if (win_pl){
				if (frags>=gEndValue)completed=TRUE;
			}
			break;
		case SC_MP_ENDRULE_POINTS:
			win_pl = SC_MP_GetMaxPointsPl(&frags);
			if (win_pl){
				if (frags>=gEndValue)completed=TRUE;
				
			}
			break;
		default:
			//SC_message("EndRule unsopported: %d",gEndRule);
			break;
	}// switch(gEndRule)
	if(completed){	
		if(gPhase!=GPHASE_MISSION_COMPLETED){
			if(win_pl){
				SC_sgi(GVAR_WINNER,SC_MP_GetHandleofPl(win_pl));
			}
			gPhase=GPHASE_MISSION_COMPLETED;
			SC_sgi(GVAR_GPHASE,gPhase);
			SC_MP_LoadNextMap();
			return TRUE;
		}
	}
	return FALSE;
}// void SRV_CheckEndRule(float time)
int ScriptMain(s_SC_NET_info *info){
	char txt[32];
	dword i;
	int j,k;
	int max_point;
	s_SC_MP_Recover *precov;
	s_SC_MP_hud hudinfo;
	s_SC_MP_EnumPlayers enum_pl[64];
	s_SC_MP_SRV_settings SRVset;
	s_SC_HUD_MP_icon icon[3];
	dword icons;
	ushort wtxt[128],wtxt2[64],*witxt,*my_witxt;
	float	sc_width,sc_height,val;

	switch(info->message){
		case SC_NET_MES_SERVER_TICK:	
			//________________________________________________________________	
			//gPlayersConnected = 64;
			EnumPls=FALSE;
			if (SC_MP_EnumPlayers(enum_pl,&gPlayersConnected,SC_MP_ENUMPLAYER_SIDE_ALL)){
				EnumPls=TRUE;
			}


			gPhase_timer -= info->elapsed_time;
			switch(gPhase){
			case GPHASE_BEGIN: //GPHASE_BEGIN is phase for object restart
				if (gPhase_timer <= 0.0f){
					SC_MP_SetInstantRecovery(TRUE);//
					gPhase_timer=0;
					gPhase=GPHASE_WAIT_PLAYERS;
					SC_sgi(GVAR_GPHASE,gPhase);
				}
				break;
			case GPHASE_WAIT_PLAYERS:
				if (gPlayersConnected >1){
					gPhase_timer = RESTART_TIMER;
					gPhase=GPHASE_START_GAME;
					SC_sgi(GVAR_GPHASE,gPhase);
				}
				break;
			case GPHASE_START_GAME:
				
				if (gPhase_timer <= 0.0f){
					for (i=0;i<64;i++){
						SC_sgi(GVAR_PL_POINTS + i, 0);
					}
					SC_MP_SetInstantRecovery(FALSE);					
					gTime = 0;
					gPhase=GPHASE_GAME;
					SC_sgi(GVAR_GPHASE,gPhase);
					SC_MP_SRV_ClearPlsStats();
					SC_MP_SRV_InitGameAfterInactive();
					SC_MP_RecoverAllNoAiPlayers();	
				}
				break;
			case GPHASE_GAME:
				if(EnumPls){
					for (i=0;i<64;i++){//CLEAN DATA if player lost
						cur_handle = SC_ggi(GVAR_PLAYERS + i);
						if (cur_handle != 0){//some handle here
							if (SC_MP_GetPlofHandle (cur_handle) == 0){// not in game, clear data
								SC_sgi(GVAR_PLAYERS + i, 0);
								SC_sgi(GVAR_PL_POINTS + i, 0);
							}
						}
					}
					for (i=0;i<gPlayersConnected;i++){//IS PLAYER IN LIST
						cur_handle = SC_MP_GetHandleofPl(enum_pl[i].id);
						k=0;
						player_added=FALSE;
						do{// is player in list
							if (cur_handle == SC_ggi(GVAR_PLAYERS + k)){
								player_added = TRUE;
							}
							k++;
						}while(!player_added && (k < 64) );//||

						if (!player_added){// ADD PLAYER to list
							k=0;
							do{
								pl_slot = SC_ggi(GVAR_PLAYERS + k);
								if (pl_slot == 0){//slot free
									SC_sgi(GVAR_PLAYERS + k, cur_handle);
									SC_sgi(GVAR_PL_POINTS + k, 0);// clean data
									player_added=TRUE;
								}
								k++;
							}while(!player_added && (k < 64) );//||
						}
					}
				}
				break;
			case GPHASE_MISSION_COMPLETED:	
				break;
			}
			//________________________________________________________________
			if (SRV_CheckEndRule(info->elapsed_time)) break;
			for (i=0;i<gRecs;i++)
				gRecTimer[i] -= info->elapsed_time;
			break;
		case SC_NET_MES_CLIENT_TICK:
			switch(SC_ggi(GVAR_GPHASE)){
			case GPHASE_BEGIN:				//___________________________CLN______BEGIN
				//SC_Osi("GPHASE_BEGIN");
				break;
			case GPHASE_WAIT_PLAYERS:		//___________________________CLN______WAIT_PLAYERS
				//SC_Osi("GPHASE_WAIT_PLAYERS");
				witxt = SC_Wtxt(1076);//1076
				SC_GetScreenRes(&sc_width,&sc_height);
				val= sc_width - SC_Fnt_GetWidthW(witxt,1); 			
				SC_Fnt_WriteW(val * 0.5f,15,witxt,1,0xffffffff);
				break;	
			case GPHASE_START_GAME: 		//___________________________CLN______START_GAME
				//SC_Osi("GPHASE_START_GAME");
				if (fade_off){
					client_fade_timer -= info->elapsed_time;
					if (client_fade_timer < (FADE_TIME + 0.1f)){	
						SC_FadeTo(TRUE, FADE_TIME);
						fade_off=FALSE;
						client_fade_timer=RESTART_TIMER;
						fade_off_timer=0;

						//reset objexts and states
						if(SC_P_IsReady(SC_PC_Get())){
							if (SC_P_GetWeapons(SC_PC_Get(), &get_weap_inf)){
								if ((get_weap_inf.weap_pistol != 0 ) ||  (get_weap_inf.weap_main1 != 0 )){
									SC_P_ChangeWeapon(SC_PC_Get(), 0, 0);
									SC_P_ChangeWeapon(SC_PC_Get(), 1, 0);
									SC_P_ChangeWeapon(SC_PC_Get(), 2, 0);
									SC_P_ChangeWeapon(SC_PC_Get(), 3, 0);
									SC_P_ChangeWeapon(SC_PC_Get(), 4, 0);
									SC_P_ChangeWeapon(SC_PC_Get(), 5, 0);
									SC_P_ChangeWeapon(SC_PC_Get(), 6, 0);
									SC_P_ChangeWeapon(SC_PC_Get(), 7, 0);
									SC_P_ChangeWeapon(SC_PC_Get(), 8, 0);
									weap_removed=TRUE; // if droped after that then he dont get new weapon
								}
							}
						}
						PL_points=0;
						cur_weap=0;
					}
				}
				swprintf(wtxt,SC_AnsiToUni("%s %S", wtxt2),SC_Wtxt(6030)," - GG (Gun Game)");
				val= (sc_width*0.5) - (SC_Fnt_GetWidthW(wtxt,1)*0.5);			
				SC_Fnt_WriteW(val,15,wtxt,1,0xffffffff);
				break;
			case GPHASE_GAME:
				//FADE OFF
				if (!fade_off){
					fade_off_timer += info->elapsed_time;
					if (fade_off_timer >  0.2f){// looks better so because spawn is with short delay
						SC_FadeTo(FALSE, FADE_TIME);
						fade_off=TRUE;



					}
				}	




				if(SC_P_IsReady(SC_PC_Get())){
					PC_handle = SC_MP_GetHandleofPl(SC_PC_Get());
					player_added=FALSE;
					k=0;
					do{
						if (PC_handle == SC_ggi(GVAR_PLAYERS + k)){
							PL_points =  SC_ggi(GVAR_PL_POINTS + k);//get points
							
							cur_weap = WEAP_LIST[PL_points];
							if (last_weap != cur_weap){
								delay_timer = 0;
								last_weap = cur_weap;
								SC_P_ChangeWeapon(SC_PC_Get(), 0, 0);//cur_weap
								SC_P_ChangeWeapon(SC_PC_Get(), 1, 0);//cur_weap
								SC_P_ChangeWeapon(SC_PC_Get(), 2, 0);//cur_weap
								SC_P_ChangeWeapon(SC_PC_Get(), 3, 0);//cur_weap
								SC_P_ChangeWeapon(SC_PC_Get(), 4, 0);//cur_weap
								SC_P_ChangeWeapon(SC_PC_Get(), 5, 0);//cur_weap
								SC_P_ChangeWeapon(SC_PC_Get(), 6, 0);//cur_weap
								SC_P_ChangeWeapon(SC_PC_Get(), 7, 0);//cur_weap
								SC_P_ChangeWeapon(SC_PC_Get(), 8, 0);//cur_weap
								
								weap_removed=TRUE;
							}
							//SC_sgi(GVAR_PL_POINTS + k, PL_points + 1 );// set points
							player_added = TRUE;
						}
						k++;
					}while(!player_added && (k < 64) );//||
					
					delay_timer+=info->elapsed_time;
					if (delay_timer > 0.6f){
						if (cur_weap != 0){
							if(SC_P_IsReady(SC_PC_Get())){
								//if (!SC_P_HasWeapon(SC_PC_Get(), cur_weap)){// not working with grenade and knife????
								if (SC_P_GetWeapons(SC_PC_Get(), &get_weap_inf)){
									if(get_weap_inf.weap_main1 != cur_weap ){
										//SC_Osi("Here  weap: %d", cur_weap);
										if ((weap_removed==TRUE) && (get_weap_inf.weap_main1 == 0 ) ||  (weap_removed==FALSE)&& (get_weap_inf.weap_main1 != 0 )  || (get_weap_inf.weap_pistol != 0 )){
										//if (!SC_P_HasWeapon(SC_PC_Get(), cur_weap)){
											SC_P_ChangeWeapon(SC_PC_Get(), 0, 0);
											SC_P_ChangeWeapon(SC_PC_Get(), 1, 0);
											SC_P_ChangeWeapon(SC_PC_Get(), 3, 0);
											SC_P_ChangeWeapon(SC_PC_Get(), 4, 0);
											SC_P_ChangeWeapon(SC_PC_Get(), 5, 0);
											SC_P_ChangeWeapon(SC_PC_Get(), 6, 0);//cur_weap
											SC_P_ChangeWeapon(SC_PC_Get(), 7, 0);//cur_weap
											SC_P_ChangeWeapon(SC_PC_Get(), 8, 0);//cur_weap
											SC_P_ChangeWeapon(SC_PC_Get(), 2, cur_weap);//cur_weap
											SC_P_SetSelWeapon(SC_PC_Get(), 2);//
											weap_removed=FALSE; // if droped after that then he dont get new weapon
										}
									}
								}
							}
						}
					}
				}
				//#8450: 	#tee Level
				//if(SC_P_IsReady(SC_PC_Get())){
					swprintf(wtxt,SC_AnsiToUni("%s: %d of %d", wtxt2),SC_Wtxt(8450), PL_points , LIST_COUNT);
					SC_GetScreenRes(&sc_width,&sc_height);
					SC_Fnt_WriteW(50,(sc_height - 100),wtxt,1.1,0x85ffffff);
				//}
				break;
			case GPHASE_MISSION_COMPLETED:	
				if (fade_off){
					complete_f_timer -= info->elapsed_time;
					if (complete_f_timer < -6.0f){	
						SC_FadeTo(TRUE, FADE_TIME);
						fade_off=FALSE;
					}
				}
				swprintf(wtxt,SC_AnsiToUni("%s", wtxt2),SC_Wtxt(2026));//#2026: 	#tee   Mission completed
				SC_GetScreenRes(&sc_width,&sc_height);
				val= (sc_width*0.5) - (SC_Fnt_GetWidthW(wtxt,1)*0.5);			
				SC_Fnt_WriteW(val,15,wtxt,1,0xffffffff);

				swprintf(wtxt,SC_AnsiToUni("Best player:  %S ", wtxt2), SC_P_GetName(SC_MP_GetPlofHandle(SC_ggi(GVAR_WINNER))));
				//SC_Fnt_WriteW((sc_width*0.5),(sc_height*0.5),wtxt,1.1,0x85ffffff);
				val= (sc_width*0.5) - (SC_Fnt_GetWidthW(wtxt,1)*0.5);	
				SC_Fnt_WriteW(val,35,wtxt,1,0xffffffff);
				break;
			}
			break;// SC_NET_MES_CLIENT_TICK
		case SC_NET_MES_SERVER_KILL:
			//info->param2//killer
			//info->param1//killed
			if ((info->param1 != info->param2) && (info->param2 != 0)) {
				SC_P_MP_AddPoints(info->param2, 1);
				player_added=FALSE;
				k=0;
				killer_handle = SC_MP_GetHandleofPl(info->param2);
				do{
					if (killer_handle == SC_ggi(GVAR_PLAYERS + k)){
						CUR_PL_points =  SC_ggi(GVAR_PL_POINTS + k);//get points
						SC_sgi(GVAR_PL_POINTS + k, CUR_PL_points + 1 );// set points
						if((CUR_PL_points+1) >= LIST_COUNT){
							SC_sgi(GVAR_WINNER, killer_handle );
							//gPhase_timer=10;
							//gPhase=GPHASE_WIN;
							//SC_sgi(GVAR_GPHASE,gPhase);
						}
						player_added = TRUE;
					}
					k++;
				}while(!player_added && (k < 64) );//||
			}
			break;// SC_NET_MES_SERVER_KILL
		case SC_NET_MES_LEVELPREINIT:
			client_fade_timer=RESTART_TIMER;

			SC_sgi(GVAR_MP_MISSIONTYPE,GVAR_MP_MISSIONTYPE_GG);
			gEndRule = info->param1;
			gEndValue = info->param2;
			gTime = 0.0f;
			SC_MP_EnableBotsFromScene(FALSE);
			break;// SC_NET_MES_LEVELPREINIT
		case SC_NET_MES_LEVELINIT:
			//_____________________________________automatic custom global variables_________________
			for (i=GVAR_USE_start;i<GVAR_USE_start+SC_ggi(GVAR_COUNT)+1;i++){	//custom global variables
				SC_MP_Gvar_SetSynchro(i); 
			}
			//_______________________________________________________________________________________
			for (i=300;i<364;i++){	//custom global variables for player id's ( need to update from client side too)
				SC_MP_Gvar_SetSynchro(i); 
			}

			SC_MP_SRV_SetForceSide(0xffffffff);
			SC_MP_SetChooseValidSides(3);
			
			//SC_MP_SRV_SetClassLimit(18,0);//PILOT US
			//SC_MP_SRV_SetClassLimit(19,0);//DM- US
			//SC_MP_SRV_SetClassLimit(39,0);//DM - NVA
			
			SC_HUD_DisableRadar(TRUE);			
			//SC_MP_SRV_SetClassLimitsForDM();	
			CLEAR(hudinfo);
			hudinfo.title = 1050;
			hudinfo.sort_by[0] = SC_HUD_MP_SORTBY_POINTS;			
			hudinfo.sort_by[1] = SC_HUD_MP_SORTBY_KILLS;
			hudinfo.sort_by[2] = SC_HUD_MP_SORTBY_DEATHS | SC_HUD_MP_SORT_DOWNUP;
			hudinfo.sort_by[3] = SC_HUD_MP_SORTBY_PINGS | SC_HUD_MP_SORT_DOWNUP;
			hudinfo.pl_mask = SC_HUD_MP_PL_MASK_POINTS | SC_HUD_MP_PL_MASK_KILLS | SC_HUD_MP_PL_MASK_DEATHS;
			hudinfo.use_sides = 0;
			SC_MP_HUD_SetTabInfo(&hudinfo);
			SC_MP_AllowStPwD(FALSE);
			SC_MP_AllowFriendlyFireOFF(FALSE);
			SC_MP_SetItemsNoDisappear(FALSE);
			if (info->param2){
				if (info->param1){
					// it's server	
					//_______________________________________________________________________________________
					SC_sgi(GVAR_SERVER,1); 
					SC_MP_Gvar_SetSynchro(GVAR_GPHASE);
					SC_MP_Gvar_SetSynchro(GVAR_WINNER);
					SC_sgi(GVAR_GPHASE,gPhase);
					//_______________________________________________________________________________________
					
					for (i=400;i<464;i++){	//for player points
						SC_MP_Gvar_SetSynchro(i); 
					}
					//_______________________________________________________________________________________
					



					SC_MP_GetSRVsettings(&SRVset);
					SC_MP_SRV_InitWeaponsRecovery((float)SRVset.dm_weap_resp_time);
					gRecs = 0;
					for (i=0;i<REC_MAX;i++){		
						sprintf(txt,REC_WPNAME,i);			
						if (SC_NET_FillRecover(&gRec[gRecs],txt)) gRecs++;
					}					
#if _GE_VERSION_ >= 170
					i = REC_MAX - gRecs;
					SC_MP_GetRecovers(SC_MP_RESPAWN_GG,&gRec[gRecs],&i);
					gRecs += i;
#endif
					if (gRecs==0){ 
						SC_message("no 'GG' recover place added! Will use 'DM' recover place if exist.");
						i = REC_MAX - gRecs;
						SC_MP_GetRecovers(SC_MP_RESPAWN_DM,&gRec[gRecs],&i);
						gRecs += i;
					}




					CLEAR(gRecTimer);
				}// if (info->param1)
			}//if (info->param2)
			break;// SC_NET_MES_LEVELINIT
		case SC_NET_MES_RENDERHUD:

			if(SC_KeyPressed(0x0F)){//TAB pressed
				if(SHOW_PLAYER_COLOR){
					SC_MP_HUD_SelectPl(SC_PC_Get(),0x1100ffff);
				}
				if (SHOW_PLAYERS_COUNT){
					SC_MP_EnumPlayers(enum_pl,&j,SC_MP_ENUMPLAYER_SIDE_ALL);
					if (j==1) player_s = SC_Wtxt(350); else player_s = SC_Wtxt(7001);
					swprintf(wtxt,SC_AnsiToUni("%d  %s", wtxt2),j,player_s);
					SC_Fnt_WriteW(100,25,wtxt,1,0xffffffff);
				}
				SC_GetScreenRes(&sc_width,&sc_height);
				row=0;
				for (i=0;i<22;i++){
					swprintf(wtxt,SC_AnsiToUni("%d. %S", wtxt2), (i+1), WEAP_NAME_LIST[i]);
					if (i == PL_points){
						SC_Fnt_WriteW(10,(40+ row),wtxt,0.9,0x90ff0000);					
					}else{
						SC_Fnt_WriteW(10,(40+ row),wtxt,0.9,0x90ffffff);
					}
					row+=13;
				}
				
				// add some info 
				/*			
				swprintf(wtxt,SC_AnsiToUni("%d._ %d", wtxt2), SC_ggi(GVAR_PLAYERS + 0), SC_ggi(GVAR_PL_POINTS + 0));
				SC_Fnt_WriteW(10,(40+ row),wtxt,0.9,0x90ffffff);
				row+=13;
				swprintf(wtxt,SC_AnsiToUni("%d._ %d", wtxt2), SC_ggi(GVAR_PLAYERS + 1), SC_ggi(GVAR_PL_POINTS + 1));
				SC_Fnt_WriteW(10,(40+ row),wtxt,0.9,0x90ffffff);
				row+=13;
				swprintf(wtxt,SC_AnsiToUni("%d._ %d", wtxt2), SC_ggi(GVAR_PLAYERS + 2), SC_ggi(GVAR_PL_POINTS + 2));
				SC_Fnt_WriteW(10,(40+ row),wtxt,0.9,0x90ffffff);
				row+=13;
				swprintf(wtxt,SC_AnsiToUni("%d._ %d", wtxt2), SC_ggi(GVAR_PLAYERS + 3), SC_ggi(GVAR_PL_POINTS + 3));
				SC_Fnt_WriteW(10,(40+ row),wtxt,0.9,0x90ffffff);
				row+=13;
				
				*/
				
				
				
				
			}else if(SC_ggi(GVAR_GPHASE)==GPHASE_MISSION_COMPLETED){
				if (SC_MP_GetMaxPointsPl(&max_point)){
					if(max_point > 0){
						SC_MP_HUD_SelectPl(SC_MP_GetMaxPointsPl(&max_point),0x88440000);
					}
				}
			}
			break;
		case SC_NET_MES_SERVER_RECOVER_TIME:
			if (info->param2){
					info->fval1 = 0.1f;
			}
			else{// killed
				info->fval1 = RECOVER_TIME;
			}
			break;
		case SC_NET_MES_SERVER_RECOVER_PLACE:
			precov = (s_SC_MP_Recover*)info->param2;
			i = SC_MP_SRV_GetBestDMrecov(gRec,gRecs,gRecTimer,NORECOV_TIME);
			gRecTimer[i] = NORECOV_TIME;
			*precov = gRec[i];		
			break;
		case SC_NET_MES_RESTARTMAP:
			//___________________________________________________________
			gPhase_timer = BEGIN_TIMER;
			gPhase = GPHASE_BEGIN;	
			SC_sgi(GVAR_GPHASE,gPhase);
			break;// SC_NET_MES_RESTARTMAP
		case SC_NET_MES_RULESCHANGED:			
			gEndRule = info->param1;
			gEndValue = info->param2;
			gTime = 0.0f;
			break;
	}// switch(info->message
	return 1;
}// int ScriptMain(void)


