1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Release Useful GSC Functions (Checks, waits, etc)

Discussion in 'Call of Duty Classics' started by The Dark Side, Aug 10, 2017.

  1. The Dark Side

    The Dark Side Sectional Moderator Staff Member

    958
    795
    398
    Credits:
    3,277
    I found this batch of GSC functions on pastebin by Duffman. This guy was obviously an extremely talented coder. I've never seen codes like his before. Either way, they should be shared with the community.

    These can be used with any COD as long as it supports gsc. The syntax may have to be adjusted a tad bit though. If anybody else has some useful functions like these let me know, and i will add them. :smile:

    Have a great day!
    Dark side.
    Code:
    /*
    
    ////////Tools To Use\\\\\\\\\\
    Cleanscreen(); Cleans the screen of iPrintlns and iPrintlnbolds.
    
    showDelayText(text, delaytime); iPrints text after a delay.
    
    playSoundOnAllPlayers(sound); Plays a sound on ALL players.
    
    lockOrigin(); Locks your origin, you cannot move.
    
    unlockOrigin(); Unlocks your origin, if you were previously locked you can now move.
    
    SoundOnOrigin(sound,origin); Plays a sound on an origin.
    
    isRealyAlive(); check for being alive, if the sessionstate is valid and you're playing, and if your health is defined.
    
    fadeOut(time); fade to out on a HUD. time for how long it takes to fade it.
    
    fadeIn(time); fade to in on a HUD. time for how long it takes to fade it.
    
    DestroyOn(act1,act2,act3,act4); Destroy something on notify, 4 max.
    
    DeleteOn(act1,act2,act3,act4); Delete something on notify, 4 max.
    
    RemoveBots(); Kicks all bots from the game.(i edited this one a bit)
    
    AddBlocker(origin,radius,height); Adds a blocker on the origin,radius,and height that are defined.
    
    isHex(value); Check if a value is hex or not. (Dont know a use for this one, but its neato!)
    
    setPlayerHealth(health); Sets the player health to what you want.
    
    waitTillNotMoving(); Has a wait until you aren't moving.
    
    waitForPlayers(); Has a wait until all players are spawned in and playing.
    
    isWallbang(); Check for if you wallbang somebody (shoot them through a wall)
    
    */
    Code:
    CleanScreen()
    {
        for(i=0;i<10;i++)
        {
            iPrintlnbold(" ");
            iPrintln(" ");
        }
    }
    Code:
    showDelayText(text,delay)
    {
        wait delay;
        iPrintln(text);
    }
    Code:
    playSoundOnAllPlayers( soundAlias )
    {
        foreach(player in level.players)
                  player playLocalSound(soundAlias);
    }
    Code:
    lockOrigin()
    {
            if(isDefined(self.temp_linker))
                    self.temp_linker delete();
            self.temp_linker = spawn( "script_model", self.origin );
            self linkTo(self.temp_linker);
    }
    unlockOrigin()
    {
            self unlink();
            if(isDefined(self.temp_linker))
                    self.temp_linker delete();
    }
    Code:
    isHex(value) {
            if(isDefined(value) && value.size == 1)
                    return (value == "a" || value == "b" || value == "c" || value == "d" || value == "e" || value == "f" || value == "0" || value == "1" || value == "2" || value == "3" || value == "4" || value == "5" || value == "6" || value == "7" || value == "8" || value == "9");
            else if(isDefined(value))
                    for(i=0;i<value.size;i++)
                            if(!isHex(value[i]))
                                    return false;
            return true;
    }
    Code:
    SoundOnOrigin(alias,origin)
    {
            soundPlayer = spawn( "script_origin", origin );
            soundPlayer playsound( alias );
            wait 10;
            soundPlayer delete();
    }
    Code:
    isRealyAlive()
    {
        return self.pers["team"] != "spectator" && self.health && self.sessionstate == "playing";
    }
    Code:
    fadeOut(time) {
            if(!isDefined(self)) return;
            self fadeOverTime(time);
            self.alpha = 0;
            wait time;
            if(!isDefined(self)) return;
            self destroy();
    }
    fadeIn(time) {
            alpha = self.alpha;
            self.alpha = 0;
            self fadeOverTime(time);
            self.alpha = alpha;
    }
    Code:
    DestroyOn(act1,act2,act3,act4)
    {
            self endon("death");
            self endon("disconnect");
            self waittill_any(act1,act2,act3,act4);
            self destroy();
    }
    Code:
    DeleteOn(act1,act2,act3,act4)
    {
            self endon("death");
            self endon("disconnect");
            self waittill_any(act1,act2,act3,act4);
            self delete();
    }
    Code:
    RemoveBots()
    {
        foreach(player in level.players)
        {
            if(isDefined(player.pers["isBot"])&& player.pers["isBot"])
            kick(player getEntityNumber(),"EXE_PLAYERKICKED");
        }
        CleanScreen(); //uses cleanscreen, make sure you have this function!
    }
    Code:
    AddBlocker(origin,radius,height) {
            blocker = spawn("trigger_radius", origin,0, radius,height);
            blocker setContents(1);
            return blocker;
    }
    Code:
    setPlayerHealth(health)
    {
            self notify("end_healthregen");
            self.maxhealth = health;
            self.health = self.maxhealth;
            self setnormalhealth(self.health);
            self thread playerHealthRegen();
    }
    Code:
    waitTillNotMoving()
    {
        prevorigin = self.origin;
        while( isDefined( self ) )
        {
            wait .15;
            if ( self.origin == prevorigin )
                break;
            prevorigin = self.origin;
        }
    }
    Code:
    waitForPlayers( requiredPlayersCount )
    {
        quit = false;
        while( !quit )
        {
            wait 0.5;
            count = 0;
            foreach(player in level.players)
            {
                if( player isPlaying() )
                    count++;
            }
    
            if( count >= requiredPlayersCount )
                break;
        }
    }
    Code:
    isWallBang( attacker, victim )
    {
        return !bulletTracePassed( attacker getEye(), victim getEye(), false, attacker );
    }

    Changelog: 8/12/17 - Added isWallbang. Had to add it when i saw it.
     
    Last edited: Aug 12, 2017
    Autistic, Gelton, SCP and 4 others like this.
  2. Freezee

    Freezee Known Member

    182
    250
    273
    Credits:
    1,188
    Wonderful thread @The Dark Side!. I might just have to use this myself :smirk:
     
    Autistic and The Dark Side like this.
  3. vRice

    vRice Active Member

    54
    90
    118
    Credits:
    628
    You got a link to his pastebin? I wanna see these talented codes :wink:

    This should help a couple of people too which is nice
     
    The Dark Side likes this.
  4. The Dark Side

    The Dark Side Sectional Moderator Staff Member

    958
    795
    398
    Credits:
    3,277
    I will PM you what I found later, since I cannot right now. :smile:
     
    vRice likes this.
  5. Tusta

    Tusta Head Member Donator

    14
    14
    14
    Credits:
    3,155
    we have already a function isAlive( self )
     
  6. The Dark Side

    The Dark Side Sectional Moderator Staff Member

    958
    795
    398
    Credits:
    3,277
    The older cods do not. isRealyAlive was made for cod4.. the isHost() check didn't exist then either. You gotta do something like

    Code:
    isHost()
    {
         return self getentititynumber() == 0;
    } 
    Something like that lol
     
    DF_AUS and CabCon like this.
  7. SCP

    SCP Moderator Staff Member Donator

    384
    371
    173
    Credits:
    3,279
    Nice thread! Quite useful functions. :y:
     
    Autistic, DF_AUS and The Dark Side like this.

Share This Page