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

Members Online

»
0 Active | 68 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
Page
Previous Page
subscribe
Author Topic: Random Player
ODAWA
General Member
Since: Jan 3, 2011
Posts: 18
Last: May 6, 2012
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Saturday, May. 5, 2012 11:14 pm
Anyone know why this consistently crashes on the first "wait", no matter where I put it or for how long I specify?

Code:
rendezvous_axis_create()
{
	level endon("rendezvous_axis_created");

	wait( [[level.ex_fpstime]](5) );

	for(;;)
	{
		players = getentarray("player", "classname");

		level.players = players;
		level.teamPlayers = [];
		level.teamPlayers["allies"] = [];
		level.teamPlayers["axis"] = [];

		for(i=0; i<players.size; i++)
		{
			player = players[i];
		  
			if(isDefined(player.pers["team"]) && isDefined(level.teamPlayers[player.pers["team"]]) && !isdefined(player.undercover))
				level.teamPlayers[player.pers["team"]][level.teamPlayers[player.pers["team"]].size] = player;
		}

		level.rendezvous_axis = undefined;
 
		if(level.teamPlayers["axis"].size > 0)
		{
			level.rendezvous_axis = level.teamPlayers["axis"][randomInt(level.teamPlayers["axis"].size)];
			self thread rendezvous_axis_waypoint();
			level notify("rendezvous_axis_created");
		}

		else wait( [[level.ex_fpstime]](1) );
	}
}
Share |
Leal
General Member
Since: Feb 5, 2010
Posts: 196
Last: Aug 18, 2013
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Sunday, May. 6, 2012 08:27 am
Show us the whole information the error gives you.
Share |
ODAWA
General Member
Since: Jan 3, 2011
Posts: 18
Last: May 6, 2012
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Sunday, May. 6, 2012 12:09 pm
I was using someone else's server, so I had never thought to read their console log. Well shucks, I simply forgot to precache a shader used in a waypoint later on in the code.

Thanks for this website!
Share |
megazor
General Member
Since: Sep 18, 2009
Posts: 5
Last: Oct 25, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Wednesday, May. 9, 2012 11:32 am
I think this will work faster:

code 1:

Code:
team = "allies";
teamplayers = [];
for(i = 0; i < players.size; i++)
{
	p = players[i];
	if(isDefined(p.pers["team"]) && p.pers["team"] == team)
     		teamplayers[teamplayers.size] = p;
}
randomplayer = teamplayers[randomInt(TEAMplayers.size)];


code 2:

Code:
exceptplayer = self;
num = randomInt(players.size);
cand = players[num];
if(cand == exceptplayer)
{
	if(num == players.size-1)
		cand = players[0];
	else
		cand = players[num+1];
}


edited on May. 9, 2012 04:33 am by megazor
Share |
Restricted Access Topic is Locked
Page
Previous Page
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

»