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

Members Online

»
1 Active | 107 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: cod2 mod in stats
doctorpatton
General Member
Since: Feb 12, 2012
Posts: 8
Last: Jul 8, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Saturday, Mar. 3, 2012 05:18 pm
Hi guys, I created an automatic system stats, but has a problem, only one player at a time can view the status of each player, and a second player can not see the stats of other players, can someone help me?
Code:
else if(menu == "playerstatus")
		{
		        a = 0;
	             players=getentarray("player","classname");
                     for(i=0;i<players.size;i++) 
                     {

                   self.nome destroy();
                   self.nome = newClientHudElem(self);
                   self.nome.x = 80;
                   self.nome.y = 263; 
                   self.nome.fontscale = 0.9;
                   self.nome setPlayerNameString(players[i]);
                     
                   self.pontos destroy();
                   self.pontos = newClientHudElem(self);
                   self.pontos.x = 80;
                   self.pontos.y = 273; 
                   self.pontos.fontscale = 0.9;
                   self.pontos setvalue(players[i].score);

                   self.mortes destroy();
                   self.mortes = newClientHudElem(self);
                   self.mortes.x = 80;
                   self.mortes.y = 283; 
                   self.mortes.fontscale = 0.9;
                   self.mortes setvalue(players[i].deaths);

                   self.lvl destroy();
                   self.lvl = newClientHudElem(self);
                   self.lvl.x = 60;
                   self.lvl.y = 293; 
                   self.lvl.fontscale = 0.9;
                   //self.lvl setvalue(players[i].level);  //rank

                   self.dinheiro destroy();
                   self.dinheiro = newClientHudElem(self);
                   self.dinheiro.x = 90;
                   self.dinheiro.y = 303; 
                   self.dinheiro.fontscale = 0.9;
                   //self.dinheiro setvalue(players[i].dinheiro); //money

                   switch(response)
			{
			case "proximo"://next player automatic
						            if(players[i+a])
									{
									a+=1; 
									}
									   
                                        break;
			case "fechar":
			                     self.nome destroy();
                                 self.pontos destroy();
                                 self.mortes destroy();
                                 self.lvl destroy();
                                 self.dinheiro destroy();
                                        break;
 
                        }
						wait 2;
                     }
					 			 self.nome destroy();
                                 self.pontos destroy();
                                 self.mortes destroy();
                                 self.lvl destroy();
                                 self.dinheiro destroy();
                
	
		}

Sorry I sent the old script
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Saturday, Mar. 3, 2012 06:07 pm
Code:
else if(menu == "playerstatus")
{
a = 0; //assuming there is a point to this.
players=getentarray("player","classname");
for(i=0;i<players.sizei++) // forgot <
{
a += 1;	//dont understand why your doing this
a += i;      // if your doing that <----
//player = self; //no point you can remove this...

self.nome destroy();
self.nome = newClientHudElem(self);
self.nome.x = 80;
self.nome.y = 263; 
self.nome.fontscale = 0.9;
self.nome setPlayerNameString(players);

self.pontos destroy();
self.pontos = newClientHudElem(self);
self.pontos.x = 80;
self.pontos.y = 273; 
self.pontos.fontscale = 0.9;
self.pontos setvalue(players.score);

self.mortes destroy();
self.mortes = newClientHudElem(self);
self.mortes.x = 80;
self.mortes.y = 283; 
self.mortes.fontscale = 0.9;
self.mortes setvalue(players.deaths);

self.lvl destroy();
self.lvl = newClientHudElem(self);
self.lvl.x = 60;
self.lvl.y = 293; 
self.lvl.fontscale = 0.9;
//self.lvl setvalue(self.deaths);

self.dinheiro destroy();
self.dinheiro = newClientHudElem(self);
self.dinheiro.x = 90;
self.dinheiro.y = 303; 
self.dinheiro.fontscale = 0.9;
//self.dinheiro setvalue(self.score);

switch(response)
{
case "proximo":
if(players) 
{
a+=1;
}

break;
case "fechar":
self.nome destroy();
self.pontos destroy();
self.mortes destroy();
self.lvl destroy();
self.dinheiro destroy();
break;

}
wait 2;
}
self.nome destroy();
self.pontos destroy();
self.mortes destroy();
self.lvl destroy();
self.dinheiro destroy();
}


kk i got lost on exactly what are you trying to even make? explain to me what your trying to make and i can help you some more.

edited on Mar. 3, 2012 11:07 am by liltc64
Share |
doctorpatton
General Member
Since: Feb 12, 2012
Posts: 8
Last: Jul 8, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Saturday, Mar. 3, 2012 06:47 pm
Sorry I sent the script wrong, right now this!
The thing is I created a system of accounts, to save score, money, death, rank, etc. .. and put in a system of stats, but only one player at a time can view the stats system.
Share |
Dobriy
General Member
Since: Mar 31, 2011
Posts: 96
Last: May 23, 2012
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Monday, Mar. 5, 2012 04:11 am
Code:
else if(menu == "playerstatus")
		{
	           players=getentarray("player","classname");
                   for(i=0;i<players.size;i++) 
                   {
                   players[i].nome destroy();
                   players[i].nome = newClientHudElem(players[i]);
                   players[i].nome.x = 80;
                   players[i].nome.y = 263; 
                   players[i].nome.fontscale = 0.9;
                   players[i].nome setPlayerNameString(players[i]);
                     
                   players[i].pontos destroy();
                   players[i].pontos = newClientHudElem(players[i]);
                   players[i].pontos.x = 80;
                   players[i].pontos.y = 273; 
                   players[i].pontos.fontscale = 0.9;
                   players[i].pontos setvalue(players[i].score);

                   players[i].mortes destroy();
                   players[i].mortes = newClientHudElem(players[i]);
                   players[i].mortes.x = 80;
                   players[i].mortes.y = 283; 
                   players[i].mortes.fontscale = 0.9;
                   players[i].mortes setvalue(players[i].deaths);

                   players[i].lvl destroy();
                   players[i].lvl = newClientHudElem(players[i]);
                   players[i].lvl.x = 60;
                   players[i].lvl.y = 293; 
                   players[i].lvl.fontscale = 0.9;
                   players[i].lvl setvalue(players[i].level);

                   players[i].dinheiro destroy();
                   players[i].dinheiro = newClientHudElem(players[i]);
                   players[i].dinheiro.x = 90;
                   players[i].dinheiro.y = 303; 
                   players[i].dinheiro.fontscale = 0.9;
                   players[i].dinheiro setvalue(players[i].dinheiro);
                   }
                   wait 2;
	           players=getentarray("player","classname");
                   for(i=0;i<players.size;i++) 
                   {
                   players[i].nome destroy();
                   players[i].pontos destroy();
                   players[i].mortes destroy();
                   players[i].lvl destroy();
                   players[i].dinheiro destroy();
                   }							   

		}
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Monday, Mar. 5, 2012 08:52 am
Dobryi, have you even read your own code?

First thing thats wrong with it:
Code:

 players[i].nome destroy();

without checking if its even there (goes for all the huds)

the for() players loop loops the huds on all players... on themselves... with their own stats... wtf?

Why destroy hudelems if you can .alpha=0; them and update them whenever neccesary? Less hud related server crashes...

The name of the (i think its money) dinheiro hud is the same as the name of the money var... look at this:
Code:

players[i].dinheiro destroy();

Or, even more funny, this:
Code:

players[i].dinheiro setvalue(players[i].dinheiro);



To the guy that asks this question: Learn some proper english to explain what you want to achieve, then come back with a proper codelayout. (tabbing)


And what about a more modular approach, like this:
Code:

showstats(target)
{
	self endon("disconnect");
	self notify("showstats_restart");
	self endon("showstats_restart");
	if(!isdefined(self.nomehud))
	{
		self.nomehud=newClientHudElem(self);
		self.nomehud.x=80;
		self.nomehud.y=263; 
		self.nomehud.fontscale=0.9;
	}
	if(!isdefined(self.pontoshud))
	{
		self.pontoshud=newClientHudElem(self);
		self.pontoshud.x=80;
		self.pontoshud.y=273; 
		self.pontoshud.fontscale=0.9;
	}
	if(!isdefined(self.morteshud))
	{
		self.morteshud=newClientHudElem(self);
		self.morteshud.x=80;
		self.morteshud.y=283; 
		self.morteshud.fontscale=0.9;
	}
	if(!isdefined(self.lvlhud))
	{
		self.lvlhud=newClientHudElem(self);
		self.lvlhud.x=60;
		self.lvlhud.y=293; 
		self.lvlhud.fontscale=0.9;
	}
	if(!isdefined(self.dinheirohud))
	{
		self.dinheirohud=newClientHudElem(self);
		self.dinheirohud.x=90;
		self.dinheirohud.y=303; 
		self.dinheirohud.fontscale=0.9;
	}
	self.nomehud setplayernamestring(target);
	self.pontoshud setvalue(target.score);
	self.morteshud setvalue(target.deaths);
	self.lvlhud setvalue(target.level);
	self.dinheirohud setvalue(target.dinheiro);

	self.nomehud.alpha=1;
	self.pontoshud.alpha=1;
	self.morteshud.alpha=1;
	self.lvlhud.alpha=1;
	self.dinheirohud.alpha=1;

	wait 2;

	self.nomehud.alpha=0;
	self.pontoshud.alpha=0;
	self.morteshud.alpha=0;
	self.lvlhud.alpha=0;
	self.dinheirohud.alpha=0;
}
Share |
Dobriy
General Member
Since: Mar 31, 2011
Posts: 96
Last: May 23, 2012
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Monday, Mar. 5, 2012 09:54 am
I wrote it in the morning, before work, certainly not the best variant, but it will work except
Code:
players [i].dinheiro setvalue (players [i].dinheiro);

As I didn't look variables in an initial code
Whether as to check is hud or it isn't present. The variant with
Code:
destroy () 

quite works, whether and it is not obligatory to check there is it.
Also into the account
Code:
alpha=0;

If you didn't know that on the screen there is a quantity restriction hud's and if a considerable quantity that them is required better to remove
+
As I have understood doctorpatton it is required to show hud's to all players, and not just to one, therefore it is better to use it
Code:
players=getentarray("player","classname");
for(i=0;i<players.size;i++) 
{
if(isdefined(players[i].nome))
players[i].nome destroy();

players[i].nome = newClientHudElem(players[i]);
players[i].nome.x = 80;
players[i].nome.y = 263; 
players[i].nome.fontscale = 0.9;
players[i].nome setPlayerNameString(players[i]);
                     
if(isdefined(players[i].pontos))
players[i].pontos destroy();

players[i].pontos = newClientHudElem(players[i]);
players[i].pontos.x = 80;
players[i].pontos.y = 273; 
players[i].pontos.fontscale = 0.9;
players[i].pontos setvalue(players[i].score);

if(isdefined(players[i].mortes))
players[i].mortes destroy();

players[i].mortes = newClientHudElem(players[i]);
players[i].mortes.x = 80;
players[i].mortes.y = 283; 
players[i].mortes.fontscale = 0.9;
players[i].mortes setvalue(players[i].deaths);

if(isdefined(players[i].lvl))
players[i].lvl destroy();

players[i].lvl = newClientHudElem(players[i]);
players[i].lvl.x = 60;
players[i].lvl.y = 293; 
players[i].lvl.fontscale = 0.9;
players[i].lvl setvalue(players[i].level);

if(isdefined(players[i].dinheiro))
players[i].dinheiro destroy();

players[i].dinheiro = newClientHudElem(players[i]);
players[i].dinheiro.x = 90;
players[i].dinheiro.y = 303; 
players[i].dinheiro.fontscale = 0.9;
players[i].dinheiro setvalue(players[i].money);
}

wait 2;

players=getentarray("player","classname");
for(i=0;i<players.size;i++) 
{
if(isdefined(players[i].nome))
players[i].nome destroy();
if(isdefined(players[i].pontos))
players[i].pontos destroy();
if(isdefined(players[i].mortes))
players[i].mortes destroy();
if(isdefined(players[i].lvl))
players[i].lvl destroy();
if(isdefined(players[i].dinheiro))
players[i].dinheiro destroy();
}
Share |
doctorpatton
General Member
Since: Feb 12, 2012
Posts: 8
Last: Jul 8, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Monday, Mar. 5, 2012 07:48 pm
Well, the problem was the following:
Example: Suppose I am a gamer, and I want to see the stats (points, money, position, death ...), the second player, until I could see player statistics 2. But the second player could not see your statistics, because I was looking at their stats.

But I get it to work, all players can see the stats of all, as the "scoreboard", but with more definitions
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

»