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

Members Online

»
0 Active | 58 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: size cannot applied to int
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Aug. 17, 2011 01:40 am
i got the following error:
Quote:
******* script runtime error *******
size cannot be applied to int: (file 'test/_test.gsc', line 187)
if( self.carry.size <= 0 )
*
started from:
(file 'test/_test', line 176)
wait( 0.05 );
*
************************************


i also tried:
Quote:
if( int( self.carry.size ) <= 0 )

and
Quote:
if( !self.carry.size )

i call this on spawn with self.carry = [];

any suggestions? :o
Share |
Xylozi
General Member
Since: Jul 12, 2008
Posts: 218
Last: Mar 1, 2012
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Aug. 17, 2011 07:35 am
Does self.carry actually have any entries in its array? If not, then that is the issue.
Share |
Samuel033
General Member
Since: Dec 10, 2009
Posts: 484
Last: Dec 25, 2015
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Wednesday, Aug. 17, 2011 08:27 am
If I am reading the error correctly self.carry is not an array. Its possible you init it as one but maybe afterwards it is changed to an int.

As for size, if an array is created but nothing is added then its size is zero correct?
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Aug. 17, 2011 09:46 am
i dont know how to do it otherwise

i call it on spawn with self.carry = [];

and everytime i spawn something like a bomb i do self.carry[self.carry.size] = bomb;

and i clear it again with self.carry = [];

i guessed that that will be the issue but how can i check then an empty array?

i often see something like
Quote:
if( !self.carry.size )

maybe its a newer and only works until cod4?

but:

when you use anew array you also do
Quote:
newarray = [];
newarray[newarray.size] = "element1";
newarray[newarray.size] = "element2";
newarray[newarray.size] = "element3";
newarray[newarray.size] = "element4";
newarray[newarray.size] = "element5";


so the first newarray.size is 0, isn't it? :o
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Monday, Aug. 22, 2011 02:54 pm
i dont know what and where the error was, i didnt changed anything on the arrays, but it works now... who knows..
but thanks :)
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

»