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

Members Online

»
0 Active | 114 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: Script dont work
Moczulak
General Member
Since: Mar 30, 2009
Posts: 77
Last: Apr 8, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Wednesday, Apr. 18, 2012 11:21 am
I make this script. I'm trying to make the player id random but do not know which way...

My script random "id" player does not work.

Code:
Funkcja()
{
	array = [];
	array[array.size] = self.clientid = 0;
	array[array.size] = self.clientid = 1;
	
	players = getentarray("player", "classname");
	for(i = 0; i < players.size; i++)
	{
		player = players[i];
		
		if(player.clientid = 0)
		{
			player iprintlnbold("Give Item");
		}
		
		break;
	}
}


Someone help me odnalezeniu this way?
Share |
Spik3d
General Member
Since: Jan 30, 2008
Posts: 130
Last: Feb 19, 2015
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Wednesday, Apr. 18, 2012 12:20 pm
Well that break at the end of your for loop should be removed. Breaks break out of for and while loops and jump to the end of the for loop. So with your script, you're only going through that loop for player[0].

I'm not sure what you're trying to do with the array though, the array isn't used anywhere after you initialize it and give it two elements.
Code:
array = [];
array[array.size] = self.clientid = 0;
array[array.size] = self.clientid = 1;

I don't know whether you can or cannot do this with CoD's scripting language, but you have two declaration statements on the same lines (array[array.size] = self.clientid = 0;). If it is supported though, who is self in this scope and why are you setting the same self's clientid to 0, then immediately afterwards to 1?

You also shouldn't be trying to print like this. That function doesn't have support to be called on a player in CoD2 AFAIK.
Code:
player iprintlnbold("Give Item");

This is for CoD4, it's probably supported in CoD2, but you should use ClientPrint(player, message) instead.

You also don't need to do this, you can just use player[i] instead of player for the rest of the loop and it will behave the same.
Code:
player = players[i];

But lastly, I don't see anything generating random numbers for players. I don't even see a random number generator being used in your function there. I'm not entirely sure what you're trying to do though, I wouldn't rely on random numbers to distinguish players between each other if you'd be using that id to print something to their screen.

If you want to print "Give Item" to their screen after they give or are given an item, you should print it in your script soon after the actual action is being done so you can reference the player who was given or gave an item and print it to their screen without any random numbers or looping involved.
Share |
Rezil
General Member
Since: Aug 25, 2006
Posts: 30
Last: Apr 10, 2013
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Wednesday, Apr. 18, 2012 12:46 pm
Quote:
You also shouldn't be trying to print like this. That function doesn't have support to be called on a player in CoD2 AFAIK.


iprintlnbold is supported in CoD2. An addon to the list of things wrong with this code is also

Code:
if(player.clientid = 0)


which should be

Code:
if(player.clientid == 0)


since you have to compare two values in an if statement.
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Wednesday, Apr. 18, 2012 12:51 pm
Damian17 writes...
Quote:
I make this script. I'm trying to make the player id random but do not know which way...

My script random "id" player does not work.

Code:
Funkcja()
{
	array = [];
	array[array.size] = self.clientid = 0;
	array[array.size] = self.clientid = 1;
	
	players = getentarray("player", "classname");
	for(i = 0; i < players.size; i++)
	{
		player = players[i];
		
		if(player.clientid = 0)
		{
			player iprintlnbold("Give Item");
		}
		
		break;
	}
}


Someone help me odnalezeniu this way?


You cannot change a client's ID. It is given to a player according to the order in which they connect to a server. Even if they leave, their ID is not then given to someone else joining the server.

Give up the idea of changing a clien't ID, and find some other way to find the player you are looking for.
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: Wednesday, Apr. 18, 2012 01:56 pm
you could just simply make a custom var to take place instead of using "clientid" when they connect. so when they connect you could do.

Code:
level.idNums = 0; // put this in your main func so it dosnt keep reseting its self to 0

players.customID = level.idNums; // put when they connect
level.idNums++; // put when they connect


then you can monitor when they disconnect and put level.idNums--; so everything will stay neat and in order.
Share |
Moczulak
General Member
Since: Mar 30, 2009
Posts: 77
Last: Apr 8, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Friday, Apr. 20, 2012 01:12 pm
level.idNums = 0; - zero means that the player no have on the server, right?
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: Friday, Apr. 20, 2012 04:51 pm
Damian17 writes...
Quote:
level.idNums = 0; - zero means that the player no have on the server, right?


im sorry i dont know what your trying to say? level.idNums is just a custom var i came up with that holds an int of 0. so your first person to connect will hold that memory. then next will be 1 ect ect. its just like clientid but you are aloud to change the players level.idNums.
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

»