Results 1 to 4 of 4

Thread: Script Error

  1. #1
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts

    Script Error

    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

  2. #2
    Private
    Join Date
    Jan 2013
    Location
    Hungary
    Posts
    113
    Thanks
    10
    Thanked 74 Times in 45 Posts
    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)
    Last edited by randall; 1st February 2013 at 20:20.

  3. The Following 2 Users Say Thank You to randall For This Useful Post:

    kung foo man (1st February 2013),Loveboy (1st February 2013)

  4. #3
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Sounds like it is being threaded too soon, and the team assets haven't been defined. Try this:

    Code:
    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" );
    	}
    }
    Last edited by Tally; 1st February 2013 at 20:32.

  5. The Following 2 Users Say Thank You to Tally For This Useful Post:

    kung foo man (1st February 2013),Loveboy (2nd February 2013)

  6. #4
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    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.
    Last edited by Mitch; 1st February 2013 at 20:32.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •