PDA

View Full Version : Script Error



Loveboy
1st February 2013, 19:53
Hi guys, i have a script error:

******* script runtime error *******
cannot switch on undefined: (file 'perks/_tripwire.gsc', line 62)
switch( game["allies"] )
*
called from:
(file 'perks/_tripwire.gsc', line 44)
onPrecache();
*
called from:
(file 'demon/_globallogic.gsc', line 31)
thread perks\_tripwire::init();
*
called from:
(file 'maps/mp/gametypes/_callbacksetup.gsc', line 19)
level thread demon\_globallogic::init();
*
started from:
(file 'maps/mp/gametypes/_callbacksetup.gsc', line 14)
CodeCallback_StartGameType()
*
************************************

here is from perks/_tripwire onPrecache() script:

onPrecache()
{
if( !isdefined( game["gamestarted"] ) )
{
precacheString( game["tripwire"]["pickupmessage"] );
precacheString( game["tripwire"]["placemessage"] );

if( game["tripwire"]["picktimesameteam"] || game["tripwire"]["picktimeotherteam"] )
precacheString( game["tripwire"]["pickingUpmessage"] );

if( game["tripwire"]["planttime"] )
precacheString( game["tripwire"]["placingmessage"] );

switch( game["allies"] )
{
case "american":
precacheShader( "gfx/icons/hud@us_grenade_C.tga" );
precacheShader( "hud_us_grenade_defuse" );
break;

case "british":
precacheShader( "gfx/icons/hud@british_grenade_C.tga" );
precacheShader( "hud_british_grenade_defuse" );
break;

case "russian":
precacheShader( "gfx/icons/hud@russian_grenade_C.tga" );
precacheShader( "hud_russian_grenade_defuse" );
break;
}
precacheShader( "gfx/icons/hud@steilhandgrenate_C.tga" );
precacheShader( "hud_german_grenade_defuse" );

if( game["tripwire"]["planttime"] || game["tripwire"]["picktimesameteam"] || game["tripwire"]["picktimeotherteam"] )
precacheShader( "white" );
}
}

so what is wrong? pls help me killtube

randall
1st February 2013, 20:17
game["allies"] is undefined.
Maybe you deleted the lines where game["allies"] is defined (game["allies"] = "american") and/or you call the script too early.




(thats why do not modify others' scripts without any knowledge)

Tally
1st February 2013, 20:29
Sounds like it is being threaded too soon, and the team assets haven't been defined. Try this:


onPrecache()
{
if( !isdefined( game["gamestarted"] ) )
{
precacheString( game["tripwire"]["pickupmessage"] );
precacheString( game["tripwire"]["placemessage"] );

if( game["tripwire"]["picktimesameteam"] || game["tripwire"]["picktimeotherteam"] )
precacheString( game["tripwire"]["pickingUpmessage"] );

if( game["tripwire"]["planttime"] )
precacheString( game["tripwire"]["placingmessage"] );

if( !isDefined( game["allies"] ) )
game["allies"] = "american";


switch( game["allies"] )
{
case "american":
precacheShader( "gfx/icons/hud@us_grenade_C.tga" );
precacheShader( "hud_us_grenade_defuse" );
break;

case "british":
precacheShader( "gfx/icons/hud@british_grenade_C.tga" );
precacheShader( "hud_british_grenade_defuse" );
break;

case "russian":
precacheShader( "gfx/icons/hud@russian_grenade_C.tga" );
precacheShader( "hud_russian_grenade_defuse" );
break;
}

precacheShader( "gfx/icons/hud@steilhandgrenate_C.tga" );
precacheShader( "hud_german_grenade_defuse" );

if( game["tripwire"]["planttime"] || game["tripwire"]["picktimesameteam"] || game["tripwire"]["picktimeotherteam"] )
precacheShader( "white" );
}
}

Mitch
1st February 2013, 20:29
I would say that you call your precache too soon.
It gets defined in Callback_StartGameType() (all gametypes). This function gets called from _callbacksetup by CodeCallback_StartGameType().
You should call the precache after [[level.callbackStartGameType]]() or in the gametype.