Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Combined GSC Script - Cryozyme
- Includes{
- Zombies Counter
- Give Points Command
- }
- */
- //START IMPORTS
- #include maps\mp\_utility;
- #include common_scripts\utility;
- #include maps\mp\gametypes_zm\_hud_util;
- #include maps\mp\gametypes_zm\_hud_message;
- //END IMPORTS
- //START MAIN FUNCTION
- main() {
- level thread onPlayerConnect(); //function that executes subfunctions when / if players connect, runs on a thread
- }
- //END IMPORTS
- //START PLAYER-BOUND FUNCTIONS
- onPlayerConnect() {
- for(;;) {
- level waittill("connected", player); //wait until players connect to execute subfunctions
- player thread onPlayerMessage(); //reads the chat on a thread
- player thread drawZombiesCounter(); //calls zombies counter function on a thread
- }
- }
- //END PLAYER-BOUND FUNCTIONS
- //START CHAT-BOUND FUNCTIONS
- onPlayerMessage() {
- self endon("disconnect");
- level endon("game_ended");
- //start give points chat command variables
- messageSize = message_strings.size;
- levelSize = level.players.size;
- giveCommand = "/give";
- //end give points chat command variables
- for(;;) {
- level waittill("say", player, message); //waits until a chat message is sent to execute subcommands
- //start give points chat function
- levelSize = level.players.size;
- for(i = 0; i < levelSize; i++) {
- message_strings = strToK(message, " ");
- if(tolower(message_strings[0]) == giveCommand && isSubStr(
- tolower(getPlayerName(level.players[i])), message_strings[1]
- )) {
- pointsValue = int(message_strings[(messageSize - 1)]);
- if(pointsValue < 0) {
- pointsValue = (pointsValue * -1);
- }
- player givePoints(level.players[i], int(pointsValue));
- }
- }
- //end give points chat function
- }
- }
- //END CHAT-BOUND FUNCTIONS
- //START GIVE POINTS: GET PLAYER NAME SUBFUNCTION
- getPlayerName(player) {
- playerName = getSubStr(player.name, 0, player.name.size);
- for(i = 0; i < playerName.size; i++) {
- if(playerName[i] == "]") {
- break;
- }
- }
- if(playerName.size != i) {
- playerName = getSubStr(playerName, i + 1, playerName.size);
- }
- return playerName;
- }
- //END GIVE POINTS: GET PLAYER NAME SUBFUNCTION
- //START GIVE POINTS FUNCTION
- givePoints(player, pointsValue) {
- //start give points command variables
- playerName = getPlayerName(player);
- yourName = getPlayerName(self);
- zmScore = maps\mp\zombies\_zm_score;
- pScore = player.score;
- sScore = self.score;
- //end give points command variables
- if(!isDefined(self.giving_points)) {
- self.giving_points = true;
- if(pScore == 1000000) {
- self tell(playerName + " already has ^51000000 ^7points.");
- } else if(sScore >= pointsValue) {
- self zmScore::minus_to_player_score(pointsValue, 1);
- self tell("^1Gave ^7" + yourName + " ^1" + pointsValue + "^7points!");
- player zmScore::add_to_player_score(pointsValue, 1);
- player tell("^2" + yourName + " ^7gave you ^2" + pointsValue + " ^7points!");
- } else {
- self tell("^1 You don't have enough points for that.");
- }
- wait 1;
- self.giving_points = undefined;
- }
- }
- //END GIVE POINTS FUNCTION
- //START ZOMBIE COUNTER
- drawZombiesCounter() {
- self endon("disconnect");
- level endon("end_game");
- level waittill("start_of_round");
- hudUtility = maps\mp\gametypes_zm\_hud_util;
- zmUtility = maps\mp\zombies\_zm_utility;
- zmCounter = hudUtility::createFontString("hudsmall", 1.9);
- zmCounter.alpha = 0;
- zombieTotal = zmUtility::get_round_enemy_array().size + level.zombie_total;
- zmCounter hudUtility::setPoint("CENTER", "CENTER", "CENTER", 190);
- while(true) {
- zmCounter setValue(zombieTotal);
- if(zombieTotal != 0) {
- zmCounter.label = &"Zombies: ^1";
- if(zmCounter.alpha != 1) {
- zmCounter fadeovertime(0.5);
- zmCounter.alpha = 1;
- }
- } else {
- zmCounter.label = &"Zombies: ^6";
- for(i=0; i < 15; i++) {
- if(zmCounter.alpha == 1) {
- zmCounter fadeovertime(0.5);
- zmCounter.alpha = 0;
- } else {
- zmCounter fadeovertime(0.5);
- zmCounter.alpha = 1;
- }
- wait 0.5;
- }
- level waittill("start_of_round");
- }
- wait 0.05;
- }
- }
- //END ZOMBIE COUNTER
Advertisement
Add Comment
Please, Sign In to add comment