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

Members Online

»
0 Active | 103 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: Element on players in compass
Leal
General Member
Since: Feb 5, 2010
Posts: 196
Last: Aug 18, 2013
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Sunday, Nov. 28, 2010 02:28 pm
It works now, thanks!

And what is the difference between self showAlliedObjective(); and self thread showAlliedObjective(); ?

Pedro699 writes...
Quote:
Where are you running this function from? And how? It sounds as if you are not threading the code.

As regards the objective number you need to keep a track of which of the available numbers are available (0-15). Some of these will be used by gametypes. Do not use the player's entity number as this may go outside of the allowed range.

As mentioned previously you can only have up to 16 objective icons at any time (indexes 0-15).


How could I do it then?
Share |
zeroy
General Member
Since: Nov 26, 2007
Posts: 1060
Last: Mar 12, 2014
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Sunday, Nov. 28, 2010 10:10 pm
Leal writes...
Quote:
It works now, thanks!

And what is the difference between self showAlliedObjective(); and self thread showAlliedObjective(); ?


The added "thread" means that you arent going to wait for the function to be completed to run the next one. Without the thread the function called would need to be completed to go onto next one.
Share |
Leal
General Member
Since: Feb 5, 2010
Posts: 196
Last: Aug 18, 2013
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Sunday, Nov. 28, 2010 10:12 pm
Aha all right Thank you!

Hope Pedro is going to answer me to the other question.
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Sunday, Nov. 28, 2010 10:17 pm
The difference? Its the word 'thread'

This tells the script engine to start your function (which has an infinite loop) but to continue with what it was doing before. Before the calling function was waiting for your objective loop to end before continuing (and it never ended).

~~~~~~~~~

In order to track which icons are in use you need to add a custom icon handler. This might give you an idea:

Code:
// based on code from AWE

getFreeObjId()
{
	if(!isDefined(level.trackobjicons)) 
      createObjectivesArray();

	id = undefined;

	for(i = 15; i >= 4; i--)
	{
		if(level.trackobjicons[i] == 0)
		{
			level.trackobjicons[i] = 1;
			id = i;
			break;
		}
	}
	return id;
}

deleteObjective(objnum)
{
	if(!isDefined(level.trackobjicons)) 
      createObjectivesArray();

	if(level.trackobjicons[objnum] == 1)
	{
		objective_delete(objnum);
		level.trackobjicons[objnum] = 0;
	}
}

createObjectivesArray() // create an array of available icon ids
{
	if(!isDefined(level.trackobjicons)) 
      level.trackobjicons = [];

	for(i = 0; i <= 15; i++)
	{
		if(i < 4) 
         level.trackobjicons[i] = 1; // First 4 objectives are reserved for gametypes (e.g S&D)
		else 
         level.trackobjicons[i] = 0;
	}
}

//============================//

// Usage:

showAlliedObjective()
{
   self endon("disconnect");
   self endon("killed_player");
   self endon("spawned");
     
   if(isDefined(self.markerid))
      num = self.markerid;
   else
      num = getFreeObjId();
      
   if(num != undefined)
   {
      self thread watchfordeath();
      self thread watchfordisconnect();
   
      objective_add(num, "current", self.origin);
      
      self.markerid = num;
      
      while(1)
      {
         objective_position(num, self.origin);
         wait 0.3;
      }
	}
}

watchfordeath() 
{
   self endon("disconnect");
   
   self waittill("killed_player");
   
   if(isDefined(self.markerid))
      deleteObjective(self.markerid);
}

watchfordisconnect() 
{
   self endon("killed_player");
   
   self waittill("disconnect");
   
   if(isDefined(self.markerid))
      deleteObjective(self.markerid);
}


I'm not sure how well the disconnect handler will work - personally I would implement a watchdog to clean up un-used icons.

But as mentioned previously once there are more than 12 players in the server it will stop working (due to the 4 icons required for S&D). CoD4 / 5 used 4 icons but I think CoD2 uses less, so might be able to free up a couple more.
Share |
Leal
General Member
Since: Feb 5, 2010
Posts: 196
Last: Aug 18, 2013
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Monday, Nov. 29, 2010 03:11 pm
Well the server im looking to put the mod in has 64 slots... and it's normaly at 45/64. Then bad for the zombies to search the hunters.

I will try to make this script which replaces what i used with getentitynumber because you said it's bad.
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

»