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

Members Online

»
0 Active | 13 Guests
Online:

LATEST FORUM THREADS

»
Script errors
CoD4 MP Mapping
water
CoD4 MP 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, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Restricted Access 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 04: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 29, 2008
Posts: 128
Last: Apr 23, 2013
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Wednesday, Apr. 18, 2012 05:20 am
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 05:46 am
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 05:51 am
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 06:56 am
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 06:12 am
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 09:51 am
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 Restricted Access subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Why console gaming is dying
Quote:Consider this: Dedicated gaming sales — including living-room consoles...
Devs: Games are being dumb...
Click 'read more' to view the contents of this post.
Loadout
Gun Crafting to the Max. edited on Sep. 25, 2012 06:57 pm by Morp...
Introducing the Source Fil...
Surprised this wasn't made a long time ago. Sounds like a nice little feature.
Introducing the Source Fil...
The Source Filmmaker (SFM) is the movie-making tool built and used by us he...

Partners & Friends

»