Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 96 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: top 5
where
General Member
Since: May 7, 2012
Posts: 3
Last: May 16, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Monday, May. 7, 2012 03:13 pm
Hi how made top5 players
Share |
dundy
General Member
Since: Dec 14, 2004
Posts: 768
Last: Nov 1, 2020
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Monday, May. 7, 2012 07:01 pm
where writes...
Quote:
Hi how made top5 players


Not shure if i understand right but here goes...

Code:
// Test clientside script for top_5_player  #include clientscripts\_utility; #include clientscripts\_music;  top_5_player_monitor(clientNum) { 	self endon("disconnect"); 	self endon("top_5_player_off"); 	 	while(1) 	{ 		if(isdefined(self.top_5_playerfyFX)) 		{ 			playfx(clientNum, level._effect["top_5_player_grain"], self.origin); 		} 		realwait(0.1);		 	} }  top_5_playerfyHandler(clientNum, newState, oldState) { 	player = getlocalplayers()[clientNum]; 		 	if(newState == "1") 	{ 		if(!isdefined(player.top_5_playerfyFX))	// We're not already in top_5_player mode. 		{ 			player.top_5_playerfyFX = 1; 			player thread top_5_player_monitor(clientNum);	// thread a monitor on it. 			println("top_5_player effect on"); 		} 	} 	else if(newState == "0") 	{ 		if(isdefined(player.top_5_playerfyFX))		// We're already in top_5_player mode. 		{ 				player.top_5_playerfyFX = undefined; 				self notify("top_5_player_off");	// kill the monitor thread 				println("top_5_player effect off"); 		} 	} }  main() {  	// _load! 	clientscripts\_load::main();  	println("Registering top_5_playerfy"); 	clientscripts\_utility::registerSystem("top_5_playerfy", ::top_5_playerfyHandler);  	clientscripts\nazi_top_5_player_prototype_fx::main();  //	thread clientscripts\_fx::fx_init(0); 	thread clientscripts\_audio::audio_init(0);  	thread clientscripts\nazi_top_5_player_prototype_amb::main();  	// This needs to be called after all systems have been registered. 	thread waitforclient(0);  	println("*** Client : top_5_player running...or is it chasing? Muhahahaha");


[casanova]

edited on May. 7, 2012 12:02 pm by dundy[biggrin]
Share |
robson1014
General Member
Since: Jan 6, 2011
Posts: 7
Last: May 25, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Monday, May. 7, 2012 07:06 pm
Try my system.

Just check the rank (or some dvar what you want) on spawn, if is greater than 5th player but lower than 4th player, player got 5th place. Aslo same with other places eg. if player rank is greater than 5th && 4th && 3th player but he's rank is lower than 2 player he get 3 rd place. Easy.
Share |
Dobriy
General Member
Since: Mar 31, 2011
Posts: 96
Last: May 23, 2012
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Tuesday, May. 8, 2012 03:01 pm
credit me if you use this
In player connect:
Code:
if(self getGuid()!=0)
{
f=openfile("info/"+self getGuid()+".dobr","read");
if(f==-1)
{
f=openfile("lastposition/"+"flick"+".dobr","read");
freadln(F);
level.lastposition = int(fgetarg(f,0)); 
closefile(F);
f=openfile("lastposition/"+"flick"+".dobr", "write");
fprintln(f, (level.lastposition+1));
closefile(f);
self.position=(level.lastposition+1);
self.killplayers=0;
f=openfile("statistik/"+self.position+".dobr", "write");
fprintln(f, self getGuid());
closefile(f);
f=openfile("info/"+self getGuid()+".dobr", "write");
fprintln(f, self.position);
fprintln(f, self.killplayers);
fprintln(f, self.name);
closefile(f);
}
else
{
freadln(F);
self.position = int(fgetarg(f,0));
self.killplayers = int(fgetarg(f,1));
closefile(F);
f=openfile("info/"+self getGuid()+".dobr", "write");
fprintln(f, self.position);
fprintln(f, self.killplayers);
fprintln(f, self.name);
closefile(f);
}
}
self thread maps\mp\gametype\_killstat::init();
file killstat:

init()
{
while(isdefined(self))
{
wait 3;
f=openfile("info/"+self getGuid()+".dobr","read");
freadln(F);
self.position = int(fgetarg(f,0));
closefile(F);
f=openfile("info/"+self getGuid()+".dobr", "write");
fprintln(f, self.position);
fprintln(f, self.killplayers);
fprintln(f, self.name);
closefile(f);
  self.playerposition=(self.position-1);
  f=openfile("statistik/"+self.playerposition+".dobr", "read");
  freadln(F);
  self.playerguid = int(fgetarg(f,0));
  closefile(F);

  f=openfile("info/"+self.playerguid+".dobr","read");
  freadln(F);
  self.playerfrags = int(fgetarg(f,1));
  closefile(F);
  
  if(self.position>1)
  {
  if(self.killplayers>self.playerfrags)
  {
  f=openfile("statistik/"+self.playerposition+".dobr", "write");
  fprintln(f, self getGuid());
  closefile(f);

  f=openfile("statistik/"+self.position+".dobr", "write");
  fprintln(f, self.playerguid);
  closefile(f);

  f=openfile("info/"+self.playerguid+".dobr", "write");
  fprintln(f, self.position);
  closefile(f);

  f=openfile("info/"+self getGuid()+".dobr", "write");
  fprintln(f, self.playerposition);
  closefile(f);

  self.position=self.playerposition;

  player=getentarray("player","classname");
  for(i=0;i<player.size;i++)
  {
  if(player[i] getguid()==self.playerguid)
  {
  player[i].position=(self.position+1);
  }
  }
  }
  }
 }
}

file for cvar top5

Code:
for(i=1;i<6;i++)
{
f=openfile("statistik/"+i+".dobr","read");
freadln(f);
level.guids[i]=int(fgetarg(f,0));
closefile(f);

f=openfile("info/"+level.guids[i]+".dobr","read");
freadln(f);
level.frags[i] = int(fgetarg(f,1));
level.nick[i] = fgetarg(f,2);
closefile(f);

nuk = "nuk"+i;
frags = "frags"+i;

self setClientCvar(nuk, "^2`^9[^7Nick^9] - ^2`^9[^7"+level.nick[i]+"^9]^2`");
self setClientCvar(frags, "^2`^9[^7Killed^9]^2` - ^2`^9[^7"+level.frags[i]+"^9]^2`");
}

use cvar nuk1,nuk2...nuk5 and frags1,frags2...frags5 in your menu with top5 players
this is only for example


Code:
#include "ui_mp/menudef.h"

#define ORIGIN_TITLE	     260 90
#define ORIGIN_TITLEA	     260 90
#define ORIGIN_CHOICE1	120 180
#define ORIGIN_CHOICE2	120 220
#define ORIGIN_CHOICE3	120 260
#define ORIGIN_CHOICE4	120 300
#define ORIGIN_CHOICE21	120 340
#define ORIGIN_CHOICEA1	120 180
#define ORIGIN_CHOICEA2	120 220
#define ORIGIN_CHOICEF	-90 0

#define ORIGIN_CHOICETOP1 350 120
#define ORIGIN_CHOICETOP2 350 180
#define ORIGIN_CHOICETOP3 350 240
#define ORIGIN_CHOICETOP4 350 300
#define ORIGIN_CHOICETOP5 350 360

#define ORIGIN_CHOICEFRAGS1 350 140
#define ORIGIN_CHOICEFRAGS2 350 200
#define ORIGIN_CHOICEFRAGS3 350 260
#define ORIGIN_CHOICEFRAGS4 350 320
#define ORIGIN_CHOICEFRAGS5 350 380

#define ORIGIN_CHOICEMN1 350 180
#define ORIGIN_CHOICERA1 350 200
#define ORIGIN_CHOICEHU1 350 220
#define ORIGIN_CHOICENE1 350 240
#define ORIGIN_CHOICELI1 350 260
#define ORIGIN_CHOICEFR1 350 280


{
	menuDef
	{
		name			"ingame"
		rect			0 0 640 480
		focuscolor		GLOBAL_FOCUSED_COLOR
		style			WINDOW_STYLE_EMPTY
		blurWorld		5.0
		onEsc 
		{
			close ingame;
		}

		onOpen 
		{
			hide top;
                        scriptMenuResponse "top";
                hide statskill;
                        scriptMenuResponse "statskill";
		}
		onClose 
		{
			hide top;
                hide statskill;
		}

		// Gradient
		itemDef
		{
			style			WINDOW_STYLE_SHADER
			//rect			-107 0 554 480
			rect			0 0 640 480 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN
			background		"gradient"
			visible			1
			decoration
		}



// WINDOW BACKGROUND
		itemDef
		{
		name			"window_background"
		visible			1
		rect			0 0 850 480
		origin			ORIGIN_CHOICEF
		style			WINDOW_STYLE_FILLED
		forecolor		1 1 1 1
		backcolor		0 0 0 0.7975
		decoration
		}



		itemDef
		{
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_TITLE
			forecolor		1 1 1 1
			text			"@^2`^9Общее Меню^2`"
			textfont		UI_FONT_NORMAL
			textscale		GLOBAL_HEADER_SIZE
			decoration
		}
		
// MENU CHOICES
		execKey "1" { play "mouse_click"; scriptMenuResponse "changeweapon" }
		execKey "2" { play "mouse_click"; scriptMenuResponse "changeteam" }
		execKey "3" { play "mouse_click"; scriptMenuResponse "top" ; show top }
		execKey "4" { play "mouse_click"; close ingame; open leavegame }
		execKey "5" { play "mouse_click"; scriptMenuResponse "statskill" ; show statskill }


                ///////////////////////&#1090;оп 1



		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICETOP1
			forecolor		1 1 1 1
			dvar			"nuk1"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEFRAGS1
			forecolor		1 1 1 1
			dvar			"frags1"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

                /////////////////////////&#1090;оп 2


		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICETOP2
			forecolor		1 1 1 1
			dvar			"nuk2"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEFRAGS2
			forecolor		1 1 1 1
			dvar			"frags2"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}


                /////////////////////////&#1090;оп 3


		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICETOP3
			forecolor		1 1 1 1
			dvar			"nuk3"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEFRAGS3
			forecolor		1 1 1 1
			dvar			"frags3"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

                /////////////////////////&#1090;оп 4


		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICETOP4
			forecolor		1 1 1 1
			dvar			"nuk4"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEFRAGS4
			forecolor		1 1 1 1
			dvar			"frags4"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

                /////////////////////////&#1090;оп 5


		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICETOP5
			forecolor		1 1 1 1
			dvar			"nuk5"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEFRAGS5
			forecolor		1 1 1 1
			dvar			"frags5"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

///////////////////////////////////////////////////

		itemDef
		{
                        name		"statskill"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEMN1
			forecolor		1 1 1 1
			dvar			"menuk"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name		"statskill"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICERA1
			forecolor		1 1 1 1
			dvar			"merank"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name		"statskill"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEHU1
			forecolor		1 1 1 1
			dvar			"mehun"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}
		itemDef
		{
                        name		"statskill"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICENE1
			forecolor		1 1 1 1
			dvar			"menext"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}
		itemDef
		{
                        name		"statskill"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICELI1
			forecolor		1 1 1 1
			dvar			"melil"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}
		itemDef
		{
                        name		"statskill"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEFR1
			forecolor		1 1 1 1
			dvar			"mefrags"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		
		itemDef
		{
			name			"button_changeweapon"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICE1
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@^91^2.^2`^9Выбор Оружие^2`"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			dvartest		"ui_allow_weaponchange"
			showDvar		{ "1" }
			action
			{
				play "mouse_click";
				scriptMenuResponse "changeweapon";
			}
			onFocus
			{
				play "mouse_over";
			}
		}


		itemDef 
		{
			name			"button_changeteam"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICE2
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@^92^2.^2`^9Выбор Команды^2`"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
				scriptMenuResponse "changeteam";
			}
			onFocus
			{
				play "mouse_over";
			}
		}


		itemDef 
		{
			name			"button_top"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICE3
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@^93^2.^2`^9Топ 5 Игроков^2`"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
                                show top;
                                hide statskill;
				scriptMenuResponse "top";
			}
			onFocus
			{
				play "mouse_over";
			}
		}

		itemDef 
		{
			name			"button_stat"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICE21
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@^95^2.^2`^9Моя Статистика^2`"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
                                 hide top;
                                show statskill;
				scriptMenuResponse "statskill";
			}
			onFocus
			{
				play "mouse_over";
			}
		}

		itemDef 
		{
			name			"button_leavegame"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICE4
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@^94^2.^2`^9Выйти с Сервера^2`"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
				close ingame;
				open leavegame;
			}
			onFocus
			{
				play "mouse_over";
			}
		}

		itemDef 
		{
			#include "ui_mp/button_mainmenu.menu"

			action
			{
				play "mouse_click";
				close ingame;
				open main;
			}
			onFocus
			{
				play "mouse_over";
			}
		}
	}


	
	menuDef
	{
		name			"leavegame"
		rect			0 0 640 480
		focuscolor		GLOBAL_FOCUSED_COLOR
		style			WINDOW_STYLE_EMPTY
		blurWorld		5.0
		onEsc 
		{
			close leavegame;
		}
		onOpen 
		{
		}
		onClose
		{
			setfocus button_no;
		}

		// Gradient
		itemDef
		{
			style			WINDOW_STYLE_SHADER
			//rect			-107 0 554 480
			rect			0 0 640 480 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN
			background		"gradient"
			visible			1
			decoration
		}

		itemDef
		{
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_TITLEA
			forecolor		1 1 1 1
			text			"^2`^9Выйти с Сервера^2`"
			textfont		UI_FONT_NORMAL
			textscale		.50
			decoration
		}

// MENU CHOICES
		execKey "1" { play "mouse_click"; close leavegame; exec "disconnect" }
		execKey "2" { play "mouse_click"; close leavegame; }

		itemDef
		{
			name			"button_yes"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICEA1
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"^2`^9Да,простите я ухожу^2`"
			textfont		UI_FONT_NORMAL
			textscale		.55
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
				close leavegame;
				exec "disconnect";
			}
			onFocus
			{
				play "mouse_over";
			}
		}

		itemDef
		{
			name			"button_no"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICEA2
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"^2`^9Нет,я еще не ухожу^2`"
			textfont		UI_FONT_NORMAL
			textscale		.55
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
				close leavegame;
			}
			onFocus
			{
				play "mouse_over";
			}
		}

		itemDef 
		{
			#include "ui_mp/button_mainmenu.menu"

			action
			{
				play "mouse_click";
				close leavegame;
				open main;
			}
			onFocus
			{
				play "mouse_over";
			}
		}
	}
}
Share |
where
General Member
Since: May 7, 2012
Posts: 3
Last: May 16, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Tuesday, May. 8, 2012 03:19 pm
thx Dobriy
Share |
robson1014
General Member
Since: Jan 6, 2011
Posts: 7
Last: May 25, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Tuesday, May. 8, 2012 06:25 pm
Dobriy writes...
Quote:
credit me if you use this
In player connect:
Code:
if(self getGuid()!=0)
{
f=openfile("info/"+self getGuid()+".dobr","read");
if(f==-1)
{
f=openfile("lastposition/"+"flick"+".dobr","read");
freadln(F);
level.lastposition = int(fgetarg(f,0)); 
closefile(F);
f=openfile("lastposition/"+"flick"+".dobr", "write");
fprintln(f, (level.lastposition+1));
closefile(f);
self.position=(level.lastposition+1);
self.killplayers=0;
f=openfile("statistik/"+self.position+".dobr", "write");
fprintln(f, self getGuid());
closefile(f);
f=openfile("info/"+self getGuid()+".dobr", "write");
fprintln(f, self.position);
fprintln(f, self.killplayers);
fprintln(f, self.name);
closefile(f);
}
else
{
freadln(F);
self.position = int(fgetarg(f,0));
self.killplayers = int(fgetarg(f,1));
closefile(F);
f=openfile("info/"+self getGuid()+".dobr", "write");
fprintln(f, self.position);
fprintln(f, self.killplayers);
fprintln(f, self.name);
closefile(f);
}
}
self thread maps\mp\gametype\_killstat::init();
file killstat:

init()
{
while(isdefined(self))
{
wait 3;
f=openfile("info/"+self getGuid()+".dobr","read");
freadln(F);
self.position = int(fgetarg(f,0));
closefile(F);
f=openfile("info/"+self getGuid()+".dobr", "write");
fprintln(f, self.position);
fprintln(f, self.killplayers);
fprintln(f, self.name);
closefile(f);
  self.playerposition=(self.position-1);
  f=openfile("statistik/"+self.playerposition+".dobr", "read");
  freadln(F);
  self.playerguid = int(fgetarg(f,0));
  closefile(F);

  f=openfile("info/"+self.playerguid+".dobr","read");
  freadln(F);
  self.playerfrags = int(fgetarg(f,1));
  closefile(F);
  
  if(self.position>1)
  {
  if(self.killplayers>self.playerfrags)
  {
  f=openfile("statistik/"+self.playerposition+".dobr", "write");
  fprintln(f, self getGuid());
  closefile(f);

  f=openfile("statistik/"+self.position+".dobr", "write");
  fprintln(f, self.playerguid);
  closefile(f);

  f=openfile("info/"+self.playerguid+".dobr", "write");
  fprintln(f, self.position);
  closefile(f);

  f=openfile("info/"+self getGuid()+".dobr", "write");
  fprintln(f, self.playerposition);
  closefile(f);

  self.position=self.playerposition;

  player=getentarray("player","classname");
  for(i=0;i<player.size;i++)
  {
  if(player[i] getguid()==self.playerguid)
  {
  player[i].position=(self.position+1);
  }
  }
  }
  }
 }
}

file for cvar top5

Code:
for(i=1;i<6;i++)
{
f=openfile("statistik/"+i+".dobr","read");
freadln(f);
level.guids[i]=int(fgetarg(f,0));
closefile(f);

f=openfile("info/"+level.guids[i]+".dobr","read");
freadln(f);
level.frags[i] = int(fgetarg(f,1));
level.nick[i] = fgetarg(f,2);
closefile(f);

nuk = "nuk"+i;
frags = "frags"+i;

self setClientCvar(nuk, "^2`^9[^7Nick^9] - ^2`^9[^7"+level.nick[i]+"^9]^2`");
self setClientCvar(frags, "^2`^9[^7Killed^9]^2` - ^2`^9[^7"+level.frags[i]+"^9]^2`");
}

use cvar nuk1,nuk2...nuk5 and frags1,frags2...frags5 in your menu with top5 players
this is only for example


Code:
#include "ui_mp/menudef.h"

#define ORIGIN_TITLE	     260 90
#define ORIGIN_TITLEA	     260 90
#define ORIGIN_CHOICE1	120 180
#define ORIGIN_CHOICE2	120 220
#define ORIGIN_CHOICE3	120 260
#define ORIGIN_CHOICE4	120 300
#define ORIGIN_CHOICE21	120 340
#define ORIGIN_CHOICEA1	120 180
#define ORIGIN_CHOICEA2	120 220
#define ORIGIN_CHOICEF	-90 0

#define ORIGIN_CHOICETOP1 350 120
#define ORIGIN_CHOICETOP2 350 180
#define ORIGIN_CHOICETOP3 350 240
#define ORIGIN_CHOICETOP4 350 300
#define ORIGIN_CHOICETOP5 350 360

#define ORIGIN_CHOICEFRAGS1 350 140
#define ORIGIN_CHOICEFRAGS2 350 200
#define ORIGIN_CHOICEFRAGS3 350 260
#define ORIGIN_CHOICEFRAGS4 350 320
#define ORIGIN_CHOICEFRAGS5 350 380

#define ORIGIN_CHOICEMN1 350 180
#define ORIGIN_CHOICERA1 350 200
#define ORIGIN_CHOICEHU1 350 220
#define ORIGIN_CHOICENE1 350 240
#define ORIGIN_CHOICELI1 350 260
#define ORIGIN_CHOICEFR1 350 280


{
	menuDef
	{
		name			"ingame"
		rect			0 0 640 480
		focuscolor		GLOBAL_FOCUSED_COLOR
		style			WINDOW_STYLE_EMPTY
		blurWorld		5.0
		onEsc 
		{
			close ingame;
		}

		onOpen 
		{
			hide top;
                        scriptMenuResponse "top";
                hide statskill;
                        scriptMenuResponse "statskill";
		}
		onClose 
		{
			hide top;
                hide statskill;
		}

		// Gradient
		itemDef
		{
			style			WINDOW_STYLE_SHADER
			//rect			-107 0 554 480
			rect			0 0 640 480 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN
			background		"gradient"
			visible			1
			decoration
		}



// WINDOW BACKGROUND
		itemDef
		{
		name			"window_background"
		visible			1
		rect			0 0 850 480
		origin			ORIGIN_CHOICEF
		style			WINDOW_STYLE_FILLED
		forecolor		1 1 1 1
		backcolor		0 0 0 0.7975
		decoration
		}



		itemDef
		{
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_TITLE
			forecolor		1 1 1 1
			text			"@^2`^9Общее Меню^2`"
			textfont		UI_FONT_NORMAL
			textscale		GLOBAL_HEADER_SIZE
			decoration
		}
		
// MENU CHOICES
		execKey "1" { play "mouse_click"; scriptMenuResponse "changeweapon" }
		execKey "2" { play "mouse_click"; scriptMenuResponse "changeteam" }
		execKey "3" { play "mouse_click"; scriptMenuResponse "top" ; show top }
		execKey "4" { play "mouse_click"; close ingame; open leavegame }
		execKey "5" { play "mouse_click"; scriptMenuResponse "statskill" ; show statskill }


                ///////////////////////&#1090;оп 1



		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICETOP1
			forecolor		1 1 1 1
			dvar			"nuk1"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEFRAGS1
			forecolor		1 1 1 1
			dvar			"frags1"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

                /////////////////////////&#1090;оп 2


		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICETOP2
			forecolor		1 1 1 1
			dvar			"nuk2"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEFRAGS2
			forecolor		1 1 1 1
			dvar			"frags2"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}


                /////////////////////////&#1090;оп 3


		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICETOP3
			forecolor		1 1 1 1
			dvar			"nuk3"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEFRAGS3
			forecolor		1 1 1 1
			dvar			"frags3"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

                /////////////////////////&#1090;оп 4


		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICETOP4
			forecolor		1 1 1 1
			dvar			"nuk4"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEFRAGS4
			forecolor		1 1 1 1
			dvar			"frags4"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

                /////////////////////////&#1090;оп 5


		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICETOP5
			forecolor		1 1 1 1
			dvar			"nuk5"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name			"top"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEFRAGS5
			forecolor		1 1 1 1
			dvar			"frags5"
			textfont		UI_FONT_NORMAL
			textscale		.32
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

///////////////////////////////////////////////////

		itemDef
		{
                        name		"statskill"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEMN1
			forecolor		1 1 1 1
			dvar			"menuk"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name		"statskill"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICERA1
			forecolor		1 1 1 1
			dvar			"merank"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		itemDef
		{
                        name		"statskill"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEHU1
			forecolor		1 1 1 1
			dvar			"mehun"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}
		itemDef
		{
                        name		"statskill"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICENE1
			forecolor		1 1 1 1
			dvar			"menext"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}
		itemDef
		{
                        name		"statskill"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICELI1
			forecolor		1 1 1 1
			dvar			"melil"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}
		itemDef
		{
                        name		"statskill"
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_CHOICEFR1
			forecolor		1 1 1 1
			dvar			"mefrags"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
		}

		
		itemDef
		{
			name			"button_changeweapon"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICE1
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@^91^2.^2`^9Выбор Оружие^2`"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			dvartest		"ui_allow_weaponchange"
			showDvar		{ "1" }
			action
			{
				play "mouse_click";
				scriptMenuResponse "changeweapon";
			}
			onFocus
			{
				play "mouse_over";
			}
		}


		itemDef 
		{
			name			"button_changeteam"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICE2
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@^92^2.^2`^9Выбор Команды^2`"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
				scriptMenuResponse "changeteam";
			}
			onFocus
			{
				play "mouse_over";
			}
		}


		itemDef 
		{
			name			"button_top"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICE3
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@^93^2.^2`^9Топ 5 Игроков^2`"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
                                show top;
                                hide statskill;
				scriptMenuResponse "top";
			}
			onFocus
			{
				play "mouse_over";
			}
		}

		itemDef 
		{
			name			"button_stat"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICE21
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@^95^2.^2`^9Моя Статистика^2`"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
                                 hide top;
                                show statskill;
				scriptMenuResponse "statskill";
			}
			onFocus
			{
				play "mouse_over";
			}
		}

		itemDef 
		{
			name			"button_leavegame"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICE4
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"@^94^2.^2`^9Выйти с Сервера^2`"
			textfont		UI_FONT_NORMAL
			textscale		.45
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
				close ingame;
				open leavegame;
			}
			onFocus
			{
				play "mouse_over";
			}
		}

		itemDef 
		{
			#include "ui_mp/button_mainmenu.menu"

			action
			{
				play "mouse_click";
				close ingame;
				open main;
			}
			onFocus
			{
				play "mouse_over";
			}
		}
	}


	
	menuDef
	{
		name			"leavegame"
		rect			0 0 640 480
		focuscolor		GLOBAL_FOCUSED_COLOR
		style			WINDOW_STYLE_EMPTY
		blurWorld		5.0
		onEsc 
		{
			close leavegame;
		}
		onOpen 
		{
		}
		onClose
		{
			setfocus button_no;
		}

		// Gradient
		itemDef
		{
			style			WINDOW_STYLE_SHADER
			//rect			-107 0 554 480
			rect			0 0 640 480 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN
			background		"gradient"
			visible			1
			decoration
		}

		itemDef
		{
			type			ITEM_TYPE_TEXT
			visible			1
			origin			ORIGIN_TITLEA
			forecolor		1 1 1 1
			text			"^2`^9Выйти с Сервера^2`"
			textfont		UI_FONT_NORMAL
			textscale		.50
			decoration
		}

// MENU CHOICES
		execKey "1" { play "mouse_click"; close leavegame; exec "disconnect" }
		execKey "2" { play "mouse_click"; close leavegame; }

		itemDef
		{
			name			"button_yes"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICEA1
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"^2`^9Да,простите я ухожу^2`"
			textfont		UI_FONT_NORMAL
			textscale		.55
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
				close leavegame;
				exec "disconnect";
			}
			onFocus
			{
				play "mouse_over";
			}
		}

		itemDef
		{
			name			"button_no"
			visible			1
			rect			0 0 128 24
			origin			ORIGIN_CHOICEA2
			forecolor		GLOBAL_UNFOCUSED_COLOR
			type			ITEM_TYPE_BUTTON
			text			"^2`^9Нет,я еще не ухожу^2`"
			textfont		UI_FONT_NORMAL
			textscale		.55
			textstyle		ITEM_TEXTSTYLE_SHADOWED
			textaligny		20
			action
			{
				play "mouse_click";
				close leavegame;
			}
			onFocus
			{
				play "mouse_over";
			}
		}

		itemDef 
		{
			#include "ui_mp/button_mainmenu.menu"

			action
			{
				play "mouse_click";
				close leavegame;
				open main;
			}
			onFocus
			{
				play "mouse_over";
			}
		}
	}
}


Do not you think your code is too messed up? 6 files to get working script, try to use tabulators and spaces when define the var or open {}. Code looks a 150%x better than yours. Easy for understand and dont "lag" too much cpu. You can just read one file where is players from 5 to 1.But this is my opinion, you dont have to accept it. Part of your cleaned code looks :

Code:

file = openFile("info/" + self getGuid() + ".dobr","read");
	
	if(file == 0)
	{
		file = openFile("lastposition/" + "flick" + ".dobr","read");
		freadln(file);
		level.lastposition = int(fgetarg(file,0)); 
		closefile(file);
		
		file = openFile("lastposition/" + "flick" + ".dobr", "write");
		fPrintLn(file, (level.lastposition+1));
		closefile(file);
		self.position = (level.lastposition+1);
		self.killplayers = 0;
		
		file = openFile("statistik/" + self.position + ".dobr", "write");
		fPrintLn(file, self getGuid());
		closefile(file);
		
		file = openFile("info/" + self getGuid() + ".dobr", "write");
		fPrintLn(file, self.position);
		fPrintLn(file, self.killplayers);
		fPrintLn(file, self.name);
		closefile(file);
	}


I think it looks better :>
Share |
Dobriy
General Member
Since: Mar 31, 2011
Posts: 96
Last: May 23, 2012
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Tuesday, May. 8, 2012 09:51 pm
It is my old code I don't use it now, I simply showed a principle of work of system

P.S. Logs aren't present)
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»