mafialokka

cannot cast undefined to bool:

Recommended Posts

How to fix this

** script runtime error ***
cannot cast undefined to bool: (file 'crazy/cmd.gsc', line 159)
   if(player.pers["killCamMusic"] == 0)
                                  *
called from:
(file 'crazy/cmd.gsc', line 21)
   adminCommands( cmd, "number" );
   *

 

 

I have try with putting !isDefined(player.pers["killCamMusic"] ) inside if   then script won't work as expected plz tell me how can i fix this   same way i have fullbright and fov they works fine without error but this killcammusic one gives runtime errors

Share this post


Link to post
Share on other sites

First id try "0",

If that doesn't do it, maybe check if you even define " killCamMusic"...

Are you using crazy/togglebinds.gsc and duffman/_common?

Please share the script also

Share this post


Link to post
Share on other sites

instead of this  if(player.pers["killCamMusic"] == 0) add this  if(isDefined(player.pers["killCamMusic"]) && player.pers["killCamMusic"] == 0)

its must be defined you added !isdefined so this script works only when player.pers["killCamMusic"] is undefined 

Share this post


Link to post
Share on other sites
37 minutes ago, tincxd said:

First id try "0",

If that doesn't do it, maybe check if you even define " killCamMusic"...

Are you using crazy/togglebinds.gsc and duffman/_common?

Please share the script also

this is code inside crazy/cmd.gsc

case "killcammusic":
        player = getPlayer( arg1, pickingType );
        ifisDefinedplayer ) )
        {
            if(player.pers["killCamMusic"] == 0)
            {
                player setstat(1602,1); 
                player.pers["killCamMusic"] = 1;
                player quickNotify("^5Kill Cam Music","^2OFF");
            }
            else if (player.pers["killCamMusic"] == 1)
            {
                player setstat(1602,0); 
                player.pers["killCamMusic"] = 0;
                player quickNotify("^5Kill Cam Music","^3ON");
            }
        }
        break;  
 

 

this is code i want to use inside map/mp/gametype/endroundmusic.gsc

for(i=0;i<level.players.size;i++)
    {
        player=level.players;
        if(player.pers["killCamMusic"] == 0){
                player playLocalSound( soundAlias );
        }else if (player.pers["killCamMusic"] == 1){
            player iPrintln"You ^1Muted^7 Kill-Cam Music, ^7Type ^1!kmusic ^7to enable." );
            notifyData = spawnstruct();
            notifyData.notifyText =  "You ^1Muted^7 Kill-Cam Music, ^7Type ^1!kmusic ^7to un-Mute."//Title
            notifyData.glowColor = (100); //RGB Color array divided by 100
            notifyData.duration = 6.0;
            player thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
        }
 
    }

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.