UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Cannot cast undefined to bool

broken avatar :(
Created 9 years ago
by Gabrielle
0 Members and 1 Guest are viewing this topic.
4,809 views
broken avatar :(
×
broken avatar :(
Location: nlThe Netherlands
Date Registered: 23 November 2013
Last active: 2 years ago
Posts
331
Respect
Forum Rank
Perk Hacker
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Zombie Slayer Elite
×
Gabrielle's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Gabrielle's Contact & Social LinksTutorialZoneNL
Hey,

I was trying to make a script for my camo change. So I added a model to the map, clip around it, trigger with targetname 'switchcamo'. All good you should say.

I then made a script. New .gsc file with the following content:

Code Snippet
Plaintext
// Camo changer

init_camo_changer_variables()
{
level.camos = [];
level.camos[0] = "115";
level.camos[1] = "afterlife";
level.currentCamo = 0;
}

init_camo_changer_trigger()
{
nextCamoNr = level.currentCamo + 1;

if (nextCamoNr >= level.camos.size)
{
nextCamoNr = 0;
}

camo_changer_trigger = getent("switchcamo", "targetname");
camo_changer_trigger sethintstring("Press &&1 to change camo to " + level.camos[nextCamoNr]);

camo_changer_trigger waittill("trigger", player);

player giveWeapon("zombie_colt", "upgraded");
}

I rebuild my MOD and things started to become really messy. I got some weird ass number error which I can't remember, so I decided to remove everything from my map, remove the .gsc file from my MOD folder and comment out the function callings in _zombiemode.gsc. However, still, everytime I go to the map it gives me errors like cannot cast undefined to bool. If I click it away, after a split second it just comes back.

By the way, I don't know what the problem is with my script. I'm not the best scripter, I'm still learning, but is there anything I'm doing wrong?

Thanks in advance and have a nice day :)
broken avatar :(
  • steviewonder87
  • Deleted Member
×
broken avatar :(
steviewonder87
This user is deleted :(
Turn off developer 1?
broken avatar :(
×
broken avatar :(
Location: nlThe Netherlands
Date Registered: 23 November 2013
Last active: 2 years ago
Posts
331
Respect
Forum Rank
Perk Hacker
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Zombie Slayer Elite
×
Gabrielle's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Gabrielle's Contact & Social LinksTutorialZoneNL
Turn off developer 1?

I'm dumb lol. Anyways nice avatar! But can you say whether something's wrong with my script or not?
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
You have developer set which gives debug information. If i where you i'd fix it but if your lazy and/or don't care if your map is broken you can do "developer 0" in the console.

As far as the script goes, your if condition isn't right. '>=' would be true if nextCamoNr is over or equal to the array size, so the "afterlife" camo would never get selected.

So change:

Code Snippet
Plaintext
	if (nextCamoNr >= level.camos.size)
{
nextCamoNr = 0;
}

to:

Code Snippet
Plaintext
	if (nextCamoNr > level.camos.size)
{
nextCamoNr = 0;
}

also you don't have the code in a while loop, so it'll only run once.
broken avatar :(
×
broken avatar :(
Location: nlThe Netherlands
Date Registered: 23 November 2013
Last active: 2 years ago
Posts
331
Respect
Forum Rank
Perk Hacker
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Zombie Slayer Elite
×
Gabrielle's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Gabrielle's Contact & Social LinksTutorialZoneNL
You have developer set which gives debug information. If i where you i'd fix it but if your lazy and/or don't care if your map is broken you can do "developer 0" in the console.

As far as the script goes, your if condition isn't right. '>=' would be true if nextCamoNr is over or equal to the array size, so the "afterlife" camo would never get selected.

So change:

Code Snippet
Plaintext
	if (nextCamoNr >= level.camos.size)
{
nextCamoNr = 0;
}

to:

Code Snippet
Plaintext
	if (nextCamoNr > level.camos.size)
{
nextCamoNr = 0;
}

also you don't have the code in a while loop, so it'll only run once.

I wouldn't care about fixing but IDK what the problem is as I've removed everything I made today and it still gives me the errors while yesterday it worked. And I don't think the errors can be caused by the skybox.

Anyways, you're right I totally forgot, thanks for pointing it out.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
I wouldn't care about fixing but IDK what the problem is as I've removed everything I made today and it still gives me the errors while yesterday it worked. And I don't think the errors can be caused by the skybox.

Anyways, you're right I totally forgot, thanks for pointing it out.

Doesn't the console give any more information?
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 6 months ago
Posts
1,322
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Team Member
My Groups
More
My Contact & Social Links
More
Personal Quote
(ง º ω º )ง u wont sum m8y?
Signature
Do not take life too seriously. You will never get out of it alive.
×
DidUknowiPwn's Groups
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
That giveWeapon is also bad.
2nd param follows weapon file gunmodel1 etc so 2nd param is an int
broken avatar :(
×
broken avatar :(
Location: nlThe Netherlands
Date Registered: 23 November 2013
Last active: 2 years ago
Posts
331
Respect
Forum Rank
Perk Hacker
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Zombie Slayer Elite
×
Gabrielle's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Gabrielle's Contact & Social LinksTutorialZoneNL
Doesn't the console give any more information?

When I use my script, I get the following error when starting up my map:

Code Snippet
Plaintext
script runtime error
(see console for details)
pair 'undefined' and 'NUMBER' has unmatching
types 'undefined' and 'float'

My console gives a shitload of errors:



Just some of them.

That giveWeapon is also bad.
2nd param follows weapon file gunmodel1 etc so 2nd param is an int

Didn't know. I was searching for like 50 minutes for the function declaration but couldn't find it anywhere. I just want to change the gun camo (which is ofc. another model). Don't want it to refill ammo though.
Last Edit: August 22, 2015, 04:18:48 pm by JoshZombieBoy
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 1 year ago
Posts
1,187
Respect
1,404Add +1
Forum Rank
Zombie Colossus
Primary Group
Community Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntstuffy@BluntZombieBluntStuffyStuffyZombie
Quote
When I use my script, I get the following error when starting up my map:

Code Snippet
Plaintext
script runtime error
(see console for details)
pair 'undefined' and 'NUMBER' has unmatching
types 'undefined' and 'float'

My console gives a shitload of errors:

Just some of them.

All those error's are basicly because of 'sloppy' scripting, variable's arent defined propperly and the result is it's checking against an undefined variable ( and that will Always come out true i believe ).

Now you say the error is about a variable called NUMBER ( i dont see that in your code anywhere ) , so it's prob related to some other script, or you have changed your code allready. Fixing those kind of errors is useally pretty easy, since it'll give you the script + line number and the variable's involved. 


Quote
Didn't know. I was searching for like 50 minutes for the function declaration but couldn't find it anywhere. I just want to change the gun camo (which is ofc. another model). Don't want it to refill ammo though.

For changing the cammo do like pwn said and use the number of the model you used in the weaponfile, so for example:

Code Snippet
Plaintext
player giveWeapon("zombie_colt", 2);
Then it will use the gunmodel2 and worldmodel2 from the weaponfile, if that refils your ammo you'd prob have to correct that yourself by getting clip and ammo count before swapping weapons, and then set those numbers on the 'new' gun. Use:

Code Snippet
Plaintext
player getweaponammostock( weapon )
player getweaponammoclip( weapon )

player setweaponammostock( weapon, amount )
player setweaponammoclip( weapon, amount )
broken avatar :(
×
broken avatar :(
Location: nlThe Netherlands
Date Registered: 23 November 2013
Last active: 2 years ago
Posts
331
Respect
Forum Rank
Perk Hacker
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Zombie Slayer Elite
×
Gabrielle's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Gabrielle's Contact & Social LinksTutorialZoneNL
All those error's are basicly because of 'sloppy' scripting, variable's arent defined propperly and the result is it's checking against an undefined variable ( and that will Always come out true i believe ).

Now you say the error is about a variable called NUMBER ( i dont see that in your code anywhere ) , so it's prob related to some other script, or you have changed your code allready. Fixing those kind of errors is useally pretty easy, since it'll give you the script + line number and the variable's involved. 


For changing the cammo do like pwn said and use the number of the model you used in the weaponfile, so for example:

Code Snippet
Plaintext
player giveWeapon("zombie_colt", 2);
Then it will use the gunmodel2 and worldmodel2 from the weaponfile, if that refils your ammo you'd prob have to correct that yourself by getting clip and ammo count before swapping weapons, and then set those numbers on the 'new' gun. Use:

Code Snippet
Plaintext
player getweaponammostock( weapon )
player getweaponammoclip( weapon )

player setweaponammostock( weapon, amount )
player setweaponammoclip( weapon, amount )

I only called the 2 functions in _zombiemode.gsc the rest i haven't touched. And thanks for your help.

 
Loading ...