Junior Member
|
12-12-2009
, 07:32
Blockmaker [+Quit]
|
#1
|
Hi, in forum im Kyel but in steam im +Quit. It's my first plugin so you do not laugh much from me;) first of all like to know if this is all right.
Thanks
I added : DEAGLE, AWP, FROST, FLASH, HE, DELAYED, AND MONEY
IM WORKING ON : DUCK, FLASH 2#, TRAMPOLINE (LOW,MID,HIGH) AND POLE BLOCKS.
I DELETED TIME MENU, LONG JUMP MENU.
Code:
new gKeysMainMenu;
new gKeysBlockMenu;
new gKeysBlockSelectionMenu;
new gKeysTeleportMenu;
new gKeysOptionsMenu;
const Float:gfSnapDistance = 10.0; //blocks snap together when they're within this value + the players snap gap
// enum for menu option values
enum
{
N1, N2, N3, N4, N5, N6, N7, N8, N9, N0
};
// enum for bit-shifted numbers 1 - 10
enum
{
B1 = 1 << N1, B2 = 1 << N2, B3 = 1 << N3, B4 = 1 << N4, B5 = 1 << N5,
B6 = 1 << N6, B7 = 1 << N7, B8 = 1 << N8, B9 = 1 << N9, B0 = 1 << N0,
};
// enum for options with YES/NO confirmation
enum
{
CHOICE_LOAD,
CHOICE_DEL_BLOCKS,
CHOICE_DEL_TELEPORTS
};
// enum for different block sizes
enum
{
NORMAL,
SMALL,
LARGE
};
// enum for axes
enum
{
X,
Y,
Z
};
// block scales
const Float:SCALE_SMALL = 0.25;
const Float:SCALE_NORMAL = 1.0;
const Float:SCALE_LARGE = 2.0;
// hud message values
const gHudRed = 10;
const gHudGreen = 30;
const gHudBlue = 200;
const Float:gfTextX = -1.0;
const Float:gfTextY = 0.84;
const gHudEffects = 0;
const Float:gfHudFxTime = 0.0;
const Float:gfHudHoldTime = 0.25;
const Float:gfHudFadeInTime = 0.0;
const Float:gfHudFadeOutTime = 0.0;
const gHudChannel = 2;
// Task ID offsets
const TASK_BHOPSOLID = 1000;
const TASK_BHOPSOLIDNOT = 2000;
const TASK_INVINCIBLE = 3000;
const TASK_STEALTH = 4000;
const TASK_ICE = 5000;
const TASK_SPRITE = 6000;
const TASK_CAMOUFLAGE = 7000;
const TASK_HONEY = 8000;
const TASK_FIRE = 9000;
const TASK_BOOTSOFSPEED = 10000;
const TASK_TELEPORT = 11000;
const TASK_NOSLOW = 12000;
const TASK_AUTOBHOP = 13000;
// strings
new const gszPrefix[] = "[BM] ";
new const gszInfoTarget[] = "info_target";
new const gszHelpFilenameFormat[] = "blockmaker_v%s.txt";
new gszFile[128];
new gszNewFile[128];
new gszMainMenu[256];
new gszBlockMenu[256];
new gszTeleportMenu[256];
new gszTimerMenu[256];
new gszMeasureMenu[512];
new gszLongJumpMenu[256];
new gszOptionsMenu[256];
new gszChoiceMenu[128];
new gszHelpTitle[64];
new gszHelpText[1600];
new gszHelpFilename[32];
new gszViewModel[33][32];
// block dimensions
new Float:gfBlockSizeMinForX[3] = {-4.0,-32.0,-32.0};
new Float:gfBlockSizeMaxForX[3] = { 4.0, 32.0, 32.0};
new Float:gfBlockSizeMinForY[3] = {-32.0,-4.0,-32.0};
new Float:gfBlockSizeMaxForY[3] = { 32.0, 4.0, 32.0};
new Float:gfBlockSizeMinForZ[3] = {-32.0,-32.0,-4.0};
new Float:gfBlockSizeMaxForZ[3] = { 32.0, 32.0, 4.0};
new Float:gfDefaultBlockAngles[3] = { 0.0, 0.0, 0.0 };
// block models
new const gszBlockModelDefault[] = "models/blockmaker/bm_block_default.mdl";
new const gszBlockModelPlatform[] = "models/blockmaker/bm_block_platform.mdl";
new const gszBlockModelBhop[] = "models/blockmaker/bm_block_bhop.mdl";
new const gszBlockModelDamage[] = "models/blockmaker/bm_block_damage.mdl";
new const gszBlockModelHealer[] = "models/blockmaker/bm_block_healer.mdl";
new const gszBlockModelInvincibility[] = "models/blockmaker/bm_block_invincibility.mdl";
new const gszBlockModelStealth[] = "models/blockmaker/bm_block_stealth.mdl";
new const gszBlockModelSpeedBoost[] = "models/blockmaker/bm_block_speedboost.mdl";
new const gszBlockModelNoFallDamage[] = "models/blockmaker/bm_block_nofalldamage.mdl";
new const gszBlockModelIce[] = "models/blockmaker/bm_block_ice.mdl";
new const gszBlockModelDeath[] = "models/blockmaker/bm_block_death.mdl";
new const gszBlockModelNuke[] = "models/blockmaker/bm_block_nuke.mdl";
new const gszBlockModelCamouflage[] = "models/blockmaker/bm_block_camouflage.mdl";
new const gszBlockModelLowGravity[] = "models/blockmaker/bm_block_lowgravity.mdl";
new const gszBlockModelFire[] = "models/blockmaker/bm_block_fire.mdl";
new const gszBlockModelRandom[] = "models/blockmaker/bm_block_random.mdl";
new const gszBlockModelSlap[] = "models/blockmaker/bm_block_slap.mdl";
new const gszBlockModelHoney[] = "models/blockmaker/bm_block_honey.mdl";
new const gszBlockModelBarrierCT[] = "models/blockmaker/bm_block_barrier_ct.mdl";
new const gszBlockModelBarrierT[] = "models/blockmaker/bm_block_barrier_t.mdl";
new const gszBlockModelBootsOfSpeed[] = "models/blockmaker/bm_block_bootsofspeed.mdl";
new const gszBlockModelGlass[] = "models/blockmaker/bm_block_glass.mdl";
new const gszBlockModelBhopNoSlow[] = "models/blockmaker/bm_block_bhop_noslow.mdl";
new const gszBlockModelAutoBhop[] = "models/blockmaker/bm_block_autobhop.mdl";
new const gszBlockModelDeagle[] = "models/blockmaker/bm_block_deagle.mdl";
new const gszBlockModelAwp[] = "models/blockmaker/bm_block_awp.mdl";
new const gszBlockModelDelayed[] = "models/blockmaker/bm_block_delayed.mdl";
new const gszBlockModelFrost[] = "models/blockmaker/bm_block_frost.mdl";
new const gszBlockModelFlash[] = "models/blockmaker/bm_block_flash.mdl";
new const gszBlockModelHe[] = "models/blockmaker/bm_block_he.mdl";
new const gszBlockModelMoney[] = "models/blockmaker/bm_block_money.mdl";
// block sprites
new const gszBlockSpriteFire[] = "sprites/blockmaker/bm_block_fire.spr"; //custom
new const gszBlockSpriteFireSmall[] = "sprites/blockmaker/bm_block_fire_small.spr"; //custom
new const gszBlockSpriteFireLarge[] = "sprites/blockmaker/bm_block_fire_large.spr"; //custom
new const gszBlockSpriteTrampoline[] = "sprites/blockmaker/bm_block_trampoline.spr"; //custom
new const gszBlockSpriteTrampolineSmall[] = "sprites/blockmaker/bm_block_trampoline_small.spr"; //custom
new const gszBlockSpriteTrampolineLarge[] = "sprites/blockmaker/bm_block_trampoline_large.spr"; //custom
new const gszBlockSpriteSpeedBoost[] = "sprites/blockmaker/bm_block_speedboost.spr"; //custom
new const gszBlockSpriteSpeedBoostSmall[] = "sprites/blockmaker/bm_block_speedboost_small.spr"; //custom
new const gszBlockSpriteSpeedBoostLarge[] = "sprites/blockmaker/bm_block_speedboost_large.spr"; //custom
new const gszFireSprite[] = "sprites/blockmaker/bm_block_fire_flame.spr"; //custom
// block sounds
new const gszNukeExplosion[] = "weapons/c4_explode1.wav"; //from CS
new const gszFireSoundFlame[] = "ambience/flameburst1.wav"; //from HL
new const gszInvincibleSound[] = "warcraft3/divineshield.wav"; //from WC3 plugin
new const gszCamouflageSound[] = "warcraft3/antend.wav"; //from WC3 plugin
new const gszStealthSound[] = "warcraft3/levelupcaster.wav"; //from WC3 plugin
new const gszBootsOfSpeedSound[] = "warcraft3/purgetarget1.wav"; //from WC3 plugin
new const gszAutoBhopSound[] = "blockmaker/boing.wav"; //from 'www.wavsource.com/sfx/sfx.htm'
// teleport
new const Float:gfTeleportSizeMin[3] = {-16.0,-16.0,-16.0};
new const Float:gfTeleportSizeMax[3] = { 16.0, 16.0, 16.0};
new const Float:gfTeleportZOffset = 36.0;
new const gTeleportStartFrames = 20;
new const gTeleportEndFrames = 5;
new const gszTeleportSound[] = "warcraft3/blinkarrival.wav"; //from WC3 plugin
new const gszTeleportSpriteStart[] = "sprites/flare6.spr"; //from HL
new const gszTeleportSpriteEnd[] = "sprites/blockmaker/bm_teleport_end.spr"; //custom
// timer
new const gszTimerModelStart[] = "models/blockmaker/bm_timer_start.mdl";
new const gszTimerModelEnd[] = "models/blockmaker/bm_timer_end.mdl";
new Float:gfTimerSizeMin[3] = {-8.0,-8.0, 0.0};
new Float:gfTimerSizeMax[3] = { 8.0, 8.0, 60.0};
new Float:gfTimerTime[33];
new Float:gfScoreTimes[15];
new gszScoreNames[15][32];
new gszScoreSteamIds[15][32];
new bool:gbHasTimer[33];
// global variables
new gSpriteIdBeam;
new gSpriteIdFire;
new gMsgScreenFade;
new gBlockSize[33];
new gMenuBeforeOptions[33];
new gChoiceOption[33];
new gBlockMenuPage[33];
new gTeleportStart[33];
new gStartTimer[33];
new gGrabbed[33];
new gGroupedBlocks[33][256];
new gGroupCount[33];
new gMeasureToolBlock1[33];
new gMeasureToolBlock2[33];
new gLongJumpDistance[33];
new gLongJumpAxis[33];
// global booleans
new bool:gbMeasureToolEnabled[33];
new bool:gbSnapping[33];
new bool:gbNoFallDamage[33];
new bool:gbOnIce[33];
new bool:gbNoSlowDown[33];
new bool:gbLowGravity[33];
new bool:gbOnFire[33];
new bool:gbAutoBhop[33];
new bool:gbJustDeleted[33];
new bool:gbAdminGodmode[33];
new bool:gbAdminNoclip[33];
// global floats
new Float:gfSnappingGap[33];
new Float:gfOldMaxSpeed[33];
new Float:gfGrablength[33];
new Float:gfNextHealTime[33];
new Float:gfNextDamageTime[33];
new Float:gfInvincibleNextUse[33];
new Float:gfInvincibleTimeOut[33];
new Float:gfStealthNextUse[33];
new Float:gfStealthTimeOut[33];
new Float:gfTrampolineTimeout[33];
new Float:gfSpeedBoostTimeOut[33];
new Float:gfNukeNextUse[33];
new Float:gfCamouflageNextUse[33];
new Float:gfCamouflageTimeOut[33];
new Float:gfRandomNextUse[33];
new Float:gfBootsOfSpeedTimeOut[33];
new Float:gfBootsOfSpeedNextUse[33];
new Float:gfAutoBhopTimeOut[33];
new Float:gfAutoBhopNextUse[33];
new Float:gfDeagleNextUse[33];
new Float:gfAwpNextUse[33];
new Float:gfHeNextUse[33];
new Float:gfFlashNextUse[33];
new Float:gfFrostNextUse[33];
new Float:gfMoneyNextUse[33],
// global vectors
new Float:gvGrabOffset[33][3];
new Float:gvMeasureToolPos1[33][3];
new Float:gvMeasureToolPos2[33][3];
// global strings
new gszCamouflageOldModel[33][32];
// block & teleport types
const gBlockMax = 24;
new gSelectedBlockType[gBlockMax];
new gRender[gBlockMax];
new gRed[gBlockMax];
new gGreen[gBlockMax];
new gBlue[gBlockMax];
new gAlpha[gBlockMax];
new const gszBlockClassname[] = "bm_block";
new const gszSpriteClassname[] = "bm_sprite";
new const gszTeleportStartClassname[] = "bm_teleport_start";
new const gszTeleportEndClassname[] = "bm_teleport_end";
new const gszTimerClassname[] = "bm_timer";
enum
{
TELEPORT_START,
TELEPORT_END,
TIMER_START,
TIMER_END
};
enum
{
BM_PLATFORM, //A
BM_BHOP, //B
BM_DAMAGE, //C
BM_HEALER, //D
BM_NOFALLDAMAGE, //I
BM_ICE, //J
BM_TRAMPOLINE, //G
BM_SPEEDBOOST, //H
BM_INVINCIBILITY, //E
BM_STEALTH, //F
BM_DEATH, //K
BM_NUKE, //L
BM_CAMOUFLAGE, //M
BM_LOWGRAVITY, //N
BM_FIRE, //O
BM_SLAP, //P
BM_RANDOM, //Q
BM_HONEY, //R
BM_BARRIER_CT, //S
BM_BARRIER_T, //T
BM_BOOTSOFSPEED, //U
BM_GLASS, //V
BM_BHOP_NOSLOW, //W
BM_AUTO_BHOP //X
BM_DEAGLE //Y
BM_AWP //Z
BM_FROST //1
BM_DELAYED //2
BM_HE //3
BM_FLASH //4
BM_MONEY //5
};
enum
{
NORMAL,
GLOWSHELL,
TRANSCOLOR,
TRANSALPHA,
TRANSWHITE
};
new const gszBlockNames[gBlockMax][32] =
{
"Platform",
"Bunnyhop",
"Damage",
"Healer",
"No Fall Damage",
"Ice",
"Trampoline",
"Speed Boost",
"Invincibility",
"Stealth",
"Death",
"Nuke",
"Camouflage",
"Low Gravity",
"Fire",
"Slap",
"Random",
"Honey",
"CT Barrier",
"T Barrier",
"Boots Of Speed",
"Glass",
"Bunnyhop (No slow down)",
"Auto Bunnyhop",
"Deagle",
"Awp",
"Flash",
"He",
"Frost",
"Delayed",
"Money"
};
// save IDs
new const gBlockSaveIds[gBlockMax] =
{
'A', 'B', 'C', 'D', 'I', 'J', 'G', 'H', 'E', 'F', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X'
};
const gTeleportSaveId = '*';
const gTimerSaveId = '&';
//global array of strings to store the paths and filenames to the block models
new gszBlockModels[gBlockMax][256];
//array of blocks that the random block can be
const gRandomBlocksMax = 7;
new const gRandomBlocks[gRandomBlocksMax] =
{
BM_STEALTH,
BM_DEATH,
BM_CAMOUFLAGE,
BM_SLAP,
BM_BOOTSOFSPEED,
BM_DEAGLE,
BM_AWP,
BM_HE,
BM_FROST,
BM_FLASH,
};
//max speed for player when they have the boots of speed
const Float:gfBootsMaxSpeed = 400.0;
//how many pages for the block selection menu
new gBlockMenuPagesMax;
/***** PLUGIN START *****/
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_cvar(PLUGIN, VERSION, FCVAR_SERVER, 0.0);
//register client commands
register_clcmd("say /maker", "showMainMenu");
register_clcmd("say /bm15", "timerShowScoreboard");
register_clcmd("+bmmake", "cmdGrab", BM_ADMIN_LEVEL, "bind a key to +bmmake");
register_clcmd("-bmgrab", "cmdRelease", BM_ADMIN_LEVEL);
//register forwards
register_forward(FM_EmitSound, "forward_EmitSound");
//create the menus
createMenus();
//register menus
register_menucmd(register_menuid("bmMainMenu"), gKeysMainMenu, "handleMainMenu");
register_menucmd(register_menuid("bmBlockMenu"), gKeysBlockMenu, "handleBlockMenu");
register_menucmd(register_menuid("bmBlockSelectionMenu"), gKeysBlockSelectionMenu, "handleBlockSelectionMenu");
register_menucmd(register_menuid("bmTeleportMenu"), gKeysTeleportMenu, "handleTeleportMenu");
register_menucmd(register_menuid("bmTimerMenu"), gKeysTimerMenu, "handleTimerMenu");
register_menucmd(register_menuid("bmMeasureMenu"), gKeysMeasureMenu, "handleMeasureMenu");
register_menucmd(register_menuid("bmLongJumpMenu"), gKeysLongJumpMenu, "handleLongJumpMenu");
register_menucmd(register_menuid("bmOptionsMenu"), gKeysOptionsMenu, "handleOptionsMenu");
register_menucmd(register_menuid("bmChoiceMenu"), gKeysChoiceMenu, "handleChoiceMenu");
//register CVARs
register_cvar("bm_telefrags", "1"); //players near teleport exit die if someone comes through
register_cvar("bm_firedamageamount", "20.0"); //damage you take per half-second on the fire block
register_cvar("bm_damageamount", "5.0"); //damage you take per half-second on the damage block
register_cvar("bm_healamount", "1.0"); //how much hp per half-second you get on the healing block
register_cvar("bm_invincibletime", "20.0"); //how long a player is invincible
register_cvar("bm_invinciblecooldown", "60.0"); //time before the invincible block can be used again
register_cvar("bm_stealthtime", "20.0"); //how long a player is in stealth
register_cvar("bm_stealthcooldown", "60.0"); //time before the stealth block can be used again
register_cvar("bm_camouflagetime", "20.0"); //how long a player is in camouflage
register_cvar("bm_camouflagecooldown", "60.0"); //time before the camouflage block can be used again
register_cvar("bm_nukecooldown", "60.0"); //someone might have been invincible when it was used
register_cvar("bm_randomcooldown", "30.0"); //time before the random block can be used again
register_cvar("bm_bootsofspeedtime", "20.0"); //how long the player has boots of speed
register_cvar("bm_bootsofspeedcooldown", "60.0"); //time before boots of speed can be used again
register_cvar("bm_autobhoptime", "20.0"); //how long the player has auto bhop
register_cvar("bm_autobhopcooldown", "60.0"); //time before auto bhop can be used again
register_cvar("bm_teleportsound", "1"); //teleporters make sound
register_cvar("bm_deaglecooldown", "999999999.0"); //someone might have been invincible when it was used
register_cvar("bm_awpcooldown", "999999999.0"); //someone might have been invincible when it was used
register_cvar("bm_hecooldown", "999999999.0"); //someone might have been invincible when it was used
register_cvar("bm_frostcooldown", "999999999.0"); //someone might have been invincible when it was used
register_cvar("bm_flashcooldown", "999999999.0"); //someone might have been invincible when it was used
register_cvar("bm_moneycooldown", "999999999.0"); //someone might have been invincible when it was used
//register events
register_event("DeathMsg", "eventPlayerDeath", "a");
register_event("TextMsg", "eventRoundRestart", "a", "2&#Game_C", "2&#Game_w");
register_event("ResetHUD", "eventPlayerSpawn", "b");
register_event("CurWeapon", "eventCurWeapon", "be");
register_logevent("eventRoundRestart", 2, "1=Round_Start");
//make save folder in basedir (new saving/loading method)
new szDir[64];
new szMap[32];
get_basedir(szDir, 64);
add(szDir, 64, "/blockmaker");
//make config folder if it doesn't already exist
if (!dir_exists(szDir))
{
mkdir(szDir);
}
get_mapname(szMap, 32);
formatex(gszNewFile, 96, "%s/%s.bm", szDir, szMap);
}
public plugin_precache()
{
//set block models to defaults
gszBlockModels[BM_PLATFORM] = gszBlockModelPlatform;
gszBlockModels[BM_BHOP] = gszBlockModelBhop;
gszBlockModels[BM_DAMAGE] = gszBlockModelDamage;
gszBlockModels[BM_HEALER] = gszBlockModelHealer;
gszBlockModels[BM_NOFALLDAMAGE] = gszBlockModelNoFallDamage;
gszBlockModels[BM_ICE] = gszBlockModelIce;
gszBlockModels[BM_TRAMPOLINE] = gszBlockModelDefault;
gszBlockModels[BM_SPEEDBOOST] = gszBlockModelSpeedBoost;
gszBlockModels[BM_INVINCIBILITY] = gszBlockModelInvincibility;
gszBlockModels[BM_STEALTH] = gszBlockModelStealth;
gszBlockModels[BM_DEATH] = gszBlockModelDeath;
gszBlockModels[BM_NUKE] = gszBlockModelNuke;
gszBlockModels[BM_CAMOUFLAGE] = gszBlockModelCamouflage;
gszBlockModels[BM_LOWGRAVITY] = gszBlockModelLowGravity;
gszBlockModels[BM_FIRE] = gszBlockModelFire;
gszBlockModels[BM_SLAP] = gszBlockModelSlap;
gszBlockModels[BM_RANDOM] = gszBlockModelRandom;
gszBlockModels[BM_HONEY] = gszBlockModelHoney;
gszBlockModels[BM_BARRIER_CT] = gszBlockModelBarrierCT;
gszBlockModels[BM_BARRIER_T] = gszBlockModelBarrierT;
gszBlockModels[BM_BOOTSOFSPEED] = gszBlockModelBootsOfSpeed;
gszBlockModels[BM_GLASS] = gszBlockModelGlass;
gszBlockModels[BM_BHOP_NOSLOW] = gszBlockModelBhopNoSlow;
gszBlockModels[BM_AUTO_BHOP] = gszBlockModelAutoBhop;
gszBlockModels[BM_DEAGLE] = gszBlockModelDeagle;
gszBlockModels[BM_AWP] = gszBlockModelAwp;
gszBlockModels[BM_FROST] = gszBlockModelFrost;
gszBlockModels[BM_FLASH] = gszBlockModelFlash;
gszBlockModels[BM_HE] = gszBlockModelHe;
gszBolckModels[BM_MONEY] = gszBlockModelMoney;
//setup default block rendering (unlisted block use normal rendering)
setupBlockRendering(BM_INVINCIBILITY, GLOWSHELL, 255, 255, 255, 16);
setupBlockRendering(BM_STEALTH, TRANSWHITE, 255, 255, 255, 100);
setupBlockRendering(BM_GLASS, TRANSALPHA, 255, 255, 255, 50);
//process block models config file
processBlockModels();
new szBlockModelSmall[256];
new szBlockModelLarge[256];
//precache blocks
for (new i = 0; i < gBlockMax; ++i)
{
//get filenames for the small and large blocks based on normal block name
setBlockModelNameSmall(szBlockModelSmall, gszBlockModels[i], 256);
setBlockModelNameLarge(szBlockModelLarge, gszBlockModels[i], 256);
precache_model(gszBlockModels[i]);
precache_model(szBlockModelSmall);
precache_model(szBlockModelLarge);
}
//precache timer models
precache_model(gszTimerModelStart);
precache_model(gszTimerModelEnd);
//precache sprites
precache_model(gszBlockSpriteFire);
precache_model(gszBlockSpriteFireSmall);
precache_model(gszBlockSpriteFireLarge);
precache_model(gszBlockSpriteTrampoline);
precache_model(gszBlockSpriteTrampolineSmall);
precache_model(gszBlockSpriteTrampolineLarge);
precache_model(gszBlockSpriteSpeedBoost);
precache_model(gszBlockSpriteSpeedBoostSmall);
precache_model(gszBlockSpriteSpeedBoostLarge);
precache_model(gszTeleportSpriteStart);
precache_model(gszTeleportSpriteEnd);
gSpriteIdFire = precache_model(gszFireSprite);
gSpriteIdBeam = precache_model("sprites/zbeam4.spr");
//precache sounds
precache_sound(gszTeleportSound);
precache_sound(gszNukeExplosion);
precache_sound(gszInvincibleSound);
precache_sound(gszCamouflageSound);
precache_sound(gszStealthSound);
precache_sound(gszFireSoundFlame);
precache_sound(gszBootsOfSpeedSound);
precache_sound(gszAutoBhopSound);
}
public plugin_cfg()
{
//format help text filename
format(gszHelpFilename, 32, gszHelpFilenameFormat, VERSION);
//create help title
format(gszHelpTitle, sizeof(gszHelpTitle), "%s v%s by %s", PLUGIN, VERSION, AUTHOR);
//read in help text from file
new szConfigsDir[32];
new szHelpFilename[64];
new szLine[128];
get_configsdir(szConfigsDir, 32);
format(szHelpFilename, sizeof(szHelpFilename), "%s/%s", szConfigsDir, gszHelpFilename);
//open help file for reading
new f = fopen(szHelpFilename, "rt");
//iterate through all the lines in the file
new size = sizeof(gszHelpText);
while (!feof(f))
{
fgets(f, szLine, 128);
add(gszHelpText, size, szLine);
}
//close file
fclose(f);
//get id for message 'ScreenFade'
gMsgScreenFade = get_user_msgid("ScreenFade");
//make the scoreboard times very large
for (new i = 0; i < 15; ++i)
{
gfScoreTimes[i] = 999999.9;
}
//load blocks from file
loadBlocks(0);
}
createMenus()
{
//calculate maximum number of block menu pages from maximum amount of blocks
gBlockMenuPagesMax = floatround((float(gBlockMax) / 8.0), floatround_ceil);
//create main menu
new size = sizeof(gszMainMenu);
add(gszMainMenu, size, "\yBy +Quit^n^n");
add(gszMainMenu, size, "\r1. \wBlock Menu^n");
add(gszMainMenu, size, "\r2. \wTeleport Menu^n");
add(gszMainMenu, size, "\r6. %sNoclip: %s^n");
add(gszMainMenu, size, "\r7. %sGodmode: %s^n^n^n");
add(gszMainMenu, size, "\r9. \wOptions Menu^n");
add(gszMainMenu, size, "\r0. \wClose");
gKeysMainMenu = B1 | B2 | B3 | B4 | B5 | B6 | B7 | B9 | B0;
//create block menu
size = sizeof(gszBlockMenu);
add(gszBlockMenu, size, "\yBlock Menu^n^n");
add(gszBlockMenu, size, "\r1. \wBlock Type: \y%s^n");
add(gszBlockMenu, size, "\r2. %sCreate Block^n");
add(gszBlockMenu, size, "\r3. %sConvert Block^n");
add(gszBlockMenu, size, "\r4. %sDelete Block^n");
add(gszBlockMenu, size, "\r5. %sRotate Block^n^n");
add(gszBlockMenu, size, "\r6. %sNoclip: %s^n");
add(gszBlockMenu, size, "\r7. %sGodmode: %s^n");
add(gszBlockMenu, size, "\r8. \wBlock Size: \y%s^n^n");
add(gszBlockMenu, size, "\r9. \wOptions Menu^n");
add(gszBlockMenu, size, "\r0. \wBack");
gKeysBlockMenu = B1 | B2 | B3 | B4 | B5 | B6 | B7 | B8 | B9 | B0;
gKeysBlockSelectionMenu = B1 | B2 | B3 | B4 | B5 | B6 | B7 | B8 | B9 | B0;
//create teleport menu
size = sizeof(gszTeleportMenu);
add(gszTeleportMenu, size, "\yTeleporter Menu^n^n");
add(gszTeleportMenu, size, "\r1. %sTeleport Start^n");
add(gszTeleportMenu, size, "\r2. %sTeleport Destination^n");
add(gszTeleportMenu, size, "\r3. %sSwap Teleport Start/Destination^n");
add(gszTeleportMenu, size, "\r4. %sDelete Teleport^n");
add(gszTeleportMenu, size, "\r5. %sShow Teleport Path^n^n");
add(gszTeleportMenu, size, "\r6. %sNoclip: %s^n");
add(gszTeleportMenu, size, "\r7. %sGodmode: %s^n^n^n");
add(gszTeleportMenu, size, "\r9. \wOptions Menu^n");
add(gszTeleportMenu, size, "\r0. \wBack");
gKeysTeleportMenu = B1 | B2 | B3 | B4 | B5 | B6 | B7 | B9 | B0;
//create the options menu
size = sizeof(gszOptionsMenu);
add(gszOptionsMenu, size, "\yOptions Menu^n^n");
add(gszOptionsMenu, size, "\r1. %sSnapping: %s^n");
add(gszOptionsMenu, size, "\r2. %sSnapping gap: \y%.1f^n");
add(gszOptionsMenu, size, "\r3. %sAdd to group^n");
add(gszOptionsMenu, size, "\r4. %sClear group^n^n");
add(gszOptionsMenu, size, "\r5. %sDelete all blocks^n");
add(gszOptionsMenu, size, "\r6. %sDelete all teleports^n^n");
add(gszOptionsMenu, size, "\r7. %sSave to file^n");
add(gszOptionsMenu, size, "\r8. %sLoad from file^n");
add(gszOptionsMenu, size, "\r9. \wShow help^n");
add(gszOptionsMenu, size, "\r0. \wBack");
gKeysOptionsMenu = B1 | B2 | B3 | B4 | B5 | B6 | B7 | B8 | B9 | B0;
//create choice (YES/NO) menu
size = sizeof(gszChoiceMenu);
add(gszChoiceMenu, size, "\y%s^n^n");
add(gszChoiceMenu, size, "\r1. \wYes^n");
add(gszChoiceMenu, size, "\r2. \wNo^n^n^n^n^n^n^n^n^n^n");
add(gszChoiceMenu, size, "\r0. \wBack");
gKeysChoiceMenu = B1 | B2 | B0;
}
setupBlockRendering(blockType, renderType, red, green, blue, alpha)
{
gRender[blockType] = renderType;
gRed[blockType] = red;
gGreen[blockType] = green;
gBlue[blockType] = blue;
gAlpha[blockType] = alpha;
}
setBlockModelNameLarge(szBlockModelTarget[256], szBlockModelSource[256], size)
{
szBlockModelTarget = szBlockModelSource;
replace(szBlockModelTarget, size, ".mdl", "_large.mdl");
}
setBlockModelNameSmall(szBlockModelTarget[256], szBlockModelSource[256], size)
{
szBlockModelTarget = szBlockModelSource;
replace(szBlockModelTarget, size, ".mdl", "_small.mdl");
}
processBlockModels()
{
//get full path to block models config file
new szBlockModelsFile[96];
get_configsdir(szBlockModelsFile, 96);
add(szBlockModelsFile, 96, "/blockmaker_models.ini");
//open block models config file for reading
new f = fopen(szBlockModelsFile, "rt");
new szData[160];
new szType[32];
new szBlockModel[256];
new szRender[16];
new szRed[8];
new szGreen[8];
new szBlue[8];
new szAlpha[8];
new blockType;
new render;
new red;
new green;
new blue;
new alpha;
//iterate through all the lines in the file
while (!feof(f))
{
//clear data
szBlockModel = "";
szRender = "";
szRed = "";
szGreen = "";
szBlue = "";
szAlpha = "";
blockType = -1;
//get and parse a line of data from file
fgets(f, szData, 160);
parse(szData, szType, 24, szBlockModel, 64, szRender, 16, szRed, 8, szGreen, 8, szBlue, 8, szAlpha, 8);
//replace '\' with '/' in block model path
replace_all(szBlockModel, 64, "\", "/");
if (equal(szType, "PLATFORM")) blockType = BM_PLATFORM;
else if (equal(szType, "BHOP")) blockType = BM_BHOP;
else if (equal(szType, "DAMAGE")) blockType = BM_DAMAGE;
else if (equal(szType, "HEALER")) blockType = BM_HEALER;
else if (equal(szType, "NOFALLDAMAGE")) blockType = BM_NOFALLDAMAGE;
else if (equal(szType, "ICE")) blockType = BM_ICE;
else if (equal(szType, "TRAMPOLINE")) blockType = BM_TRAMPOLINE;
else if (equal(szType, "SPEEDBOOST")) blockType = BM_SPEEDBOOST;
else if (equal(szType, "INVINCIBILITY")) blockType = BM_INVINCIBILITY;
else if (equal(szType, "STEALTH")) blockType = BM_STEALTH;
else if (equal(szType, "DEATH")) blockType = BM_DEATH;
else if (equal(szType, "NUKE")) blockType = BM_NUKE;
else if (equal(szType, "CAMOUFLAGE")) blockType = BM_CAMOUFLAGE;
else if (equal(szType, "LOWGRAVITY")) blockType = BM_LOWGRAVITY;
else if (equal(szType, "FIRE")) blockType = BM_FIRE;
else if (equal(szType, "SLAP")) blockType = BM_SLAP;
else if (equal(szType, "RANDOM")) blockType = BM_RANDOM;
else if (equal(szType, "HONEY")) blockType = BM_HONEY;
else if (equal(szType, "BARRIER_CT")) blockType = BM_BARRIER_CT;
else if (equal(szType, "BARRIER_T")) blockType = BM_BARRIER_T;
else if (equal(szType, "BOOTSOFSPEED")) blockType = BM_BOOTSOFSPEED;
else if (equal(szType, "GLASS")) blockType = BM_GLASS;
else if (equal(szType, "BHOP_NOSLOW")) blockType = BM_BHOP_NOSLOW;
else if (equal(szType, "AUTO_BHOP")) blockType = BM_AUTO_BHOP;
else if (equal(szType, "DEAGLE")) blockType = BM_DEAGLE;
else if (equal(szType, "AWP")) blockType = BM_AWP;
else if (equal(szType, "FROST")) blockType = BM_FROST;
else if (equal(szType, "FLASH")) blockType = BM_FLASH;
else if (equal(szType, "HE")) blockType = BM_HE;
else if (equal(szType, "DELAYED")) blockType = BM_DELAYED;
else if (equal(szType, "MONEY")) blockType = BM_MONEY;
//if we're dealing with a valid block type
if (blockType >= 0 && blockType < gBlockMax)
{
new bool:bDoRendering = false;
//if block model file exists
if (file_exists(szBlockModel))
{
//set block models for given block type
gszBlockModels[blockType] = szBlockModel;
//block model file does exist so process rendering values as well
bDoRendering = true;
}
else
{
if (equal(szBlockModel, "DEFAULT"))
{
//block is set to use default so process rendering values
bDoRendering = true;
}
}
//process rendering values
if (bDoRendering)
{
render = NORMAL;
red = 255;
green = 255;
blue = 255;
alpha = 255;
if (equal(szRender, "GLOWSHELL")) render = GLOWSHELL;
if (equal(szRender, "TRANSCOLOR")) render = TRANSCOLOR;
if (equal(szRender, "TRANSALPHA")) render = TRANSALPHA;
if (equal(szRender, "TRANSWHITE")) render = TRANSWHITE;
if (strlen(szRed) > 0) red = str_to_num(szRed);
if (strlen(szGreen) > 0) green = str_to_num(szGreen);
if (strlen(szBlue) > 0) blue = str_to_num(szBlue);
if (strlen(szAlpha) > 0) alpha = str_to_num(szAlpha);
//set blocks rendering values
setupBlockRendering(blockType, render, red, green, blue, alpha);
}
}
}
//close file
fclose(f);
}
/***** FORWARDS *****/
public client_connect(id)
{
//make sure snapping is on by default
gbSnapping[id] = true;
//players chosen snapping gap defaults to 0.0 units
gfSnappingGap[id] = 0.0;
//make sure players can die
gbNoFallDamage[id] = false;
//players block selection menu is on page 1
gBlockMenuPage[id] = 1;
//player doesn't have godmode or noclip
gbAdminGodmode[id] = false;
gbAdminNoclip[id] = false;
//player doesn't have any blocks grouped
gGroupCount[id] = 0;
//set default long jump distance and axis
gLongJumpDistance[id] = 240;
gLongJumpAxis[id] = X;
//reset players timers
resetTimers(id);
}
public client_disconnect(id)
{
//clear players group
groupClear(id);
//if player was grabbing an entity when they disconnected
if (gGrabbed[id])
{
//if entity is valid
if (is_valid_ent(gGrabbed[id]))
{
//set the entity to 'not being grabbed'
entity_set_int(gGrabbed[id], EV_INT_iuser2, 0);
}
gGrabbed[id] = 0;
}
//disable measure tool and reset values
gbMeasureToolEnabled[id] = false;
gMeasureToolBlock1[id] = 0;
gMeasureToolBlock2[id] = 0;
gvMeasureToolPos1[id][0] = 0.0;
gvMeasureToolPos1[id][1] = 0.0;
gvMeasureToolPos1[id][2] = 0.0;
gvMeasureToolPos2[id][0] = 0.0;
gvMeasureToolPos2[id][1] = 0.0;
gvMeasureToolPos2[id][2] = 0.0;
}
public pfn_touch(ent, id)
{
//if touch event involves a player
if (id > 0 && id <= 32)
{
//if player is alive
if (is_user_alive(id))
{
//if entity involved is a block
if (isBlock(ent))
{
//get the blocktype
new blockType = entity_get_int(ent, EV_INT_body);
//if blocktype is a bunnyhop block or barrier
if (blockType == BM_BHOP || blockType == BM_BARRIER_CT || blockType == BM_BARRIER_T || blockType == BM_BHOP_NOSLOW)
{
//if task does not already exist for bunnyhop block
if (!task_exists(TASK_BHOPSOLIDNOT + ent) && !task_exists(TASK_BHOPSOLID + ent))
{
//get the players team
new CsTeams:team = cs_get_user_team(id);
//if players team is different to barrier
if (blockType == BM_BARRIER_CT && team == CS_TEAM_T)
{
//make block SOLID_NOT without any delay
taskSolidNot(TASK_BHOPSOLIDNOT + ent);
}
else if (blockType == BM_BARRIER_T && team == CS_TEAM_CT)
{
//make block SOLID_NOT without any delay
taskSolidNot(TASK_BHOPSOLIDNOT + ent);
}
else if (blockType == BM_BHOP || blockType == BM_BHOP_NOSLOW)
{
//set bhop block to be SOLID_NOT after 0.1 seconds
set_task(0.1, "taskSolidNot", TASK_BHOPSOLIDNOT + ent);
}
}
}
}
}
}
return PLUGIN_CONTINUE;
}
public server_frame()
{
new ent;
new Float:vOrigin[3];
new bool:entNear = false;
new tele;
new entinsphere;
//iterate through all players and remove slow down after jumping
for (new i = 1; i <= 32; ++i)
{
if (is_user_alive(i))
{
if (gbOnIce[i] || gbNoSlowDown[i])
{
entity_set_float(i, EV_FL_fuser2, 0.0);
}
}
}
//find all teleport start entities in map and if a player is close to one, teleport the player
while ((ent = find_ent_by_class(ent, gszTeleportStartClassname)))
{
new Float:vOrigin[3];
entity_get_vector(ent, EV_VEC_origin, vOrigin);
//teleport players and grenades within a sphere around the teleport start entity
entinsphere = -1;
while ((entinsphere = find_ent_in_sphere(entinsphere, vOrigin, 32.0)))
{
//get classname of entity
new szClassname[32];
entity_get_string(entinsphere, EV_SZ_classname, szClassname, 32);
//if entity is a player
if (entinsphere > 0 && entinsphere <= 32)
{
//only teleport player if they're alive
if (is_user_alive(entinsphere))
{
//teleport the player
actionTeleport(entinsphere, ent);
}
}
//or if entity is a grenade
else if (equal(szClassname, "grenade"))
{
//get the end of the teleport
tele = entity_get_int(ent, EV_INT_iuser1);
//if the end of the teleport exists
if (tele)
{
//set the end of the teleport to be not solid
entity_set_int(tele, EV_INT_solid, SOLID_NOT); //can't be grabbed or deleted
//teleport the grenade
actionTeleport(entinsphere, ent);
//set a time in the teleport it will become solid after 2 seconds
entity_set_float(tele, EV_FL_ltime, halflife_time() + 2.0);
}
}
}
}
//make teleporters SOLID_NOT when players are near them
while ((ent = find_ent_by_class(ent, gszTeleportEndClassname)))
{
//get the origin of the teleport end entity
entity_get_vector(ent, EV_VEC_origin, vOrigin);
//compare this origin with all player and grenade origins
entinsphere = -1;
while ((entinsphere = find_ent_in_sphere(entinsphere, vOrigin, 64.0)))
{
//get classname of entity
new szClassname[32];
entity_get_string(entinsphere, EV_SZ_classname, szClassname, 32);
//if entity is a player
if (entinsphere > 0 && entinsphere <= 32)
{
//make sure player is alive
if (is_user_alive(entinsphere))
{
entNear = true;
break;
}
}
//or if entity is a grenade
else if (equal(szClassname, "grenade"))
{
entNear = true;
break;
}
}
//set the solid type of the teleport end entity depending on whether or not a player is near
if (entNear)
{
//only do this if it is not being grabbed
if (entity_get_int(ent, EV_INT_iuser2) == 0)
{
entity_set_int(ent, EV_INT_solid, SOLID_NOT); //can't be grabbed or deleted
}
}
else
{
//get time from teleport end entity to check if it can go solid
new Float:fTime = entity_get_float(ent, EV_FL_ltime);
//only set teleport end entity to solid if its 'solid not' time has elapsed
if (halflife_time() >= fTime)
{
entity_set_int(ent, EV_INT_solid, SOLID_BBOX); //CAN be grabbed and deleted
}
}
}
//find all block entities
while ((ent = find_ent_by_class(ent, gszBlockClassname)))
{
//get block type
new blockType = entity_get_int(ent, EV_INT_body);
//if block is a speed boost
if (blockType == BM_SPEEDBOOST)
{
new Float:vOrigin[3];
new Float:pOrigin[3];
new Float:dist = 9999.9;
new Float:playerDist = 9999.9;
new nearestPlayer = 0;
//get the origin of the speed boost block
entity_get_vector(ent, EV_VEC_origin, vOrigin);
//compare this origin with all players origins to find the nearest player to the block
for (new id = 1; id <= 32; ++id)
{
//if player is alive
if (is_user_alive(id))
{
//get player origin
entity_get_vector(id, EV_VEC_origin, pOrigin);
//get the distance from the block to the player
dist = get_distance_f(vOrigin, pOrigin);
if (dist < playerDist)
{
nearestPlayer = id;
playerDist = dist;
}
}
}
//if we found a player within 100 units of the speed boost block
if (nearestPlayer > 0 && playerDist < 200.0)
{
//get the sprite on top of the speed boost block
new sprite = entity_get_int(ent, EV_INT_iuser3);
//make sure sprite entity is valid
if (sprite)
{
new Float:vAngles[3];
//get the direction the player is looking
entity_get_vector(nearestPlayer, EV_VEC_angles, vAngles);
//set the angles of the sprite to be the same as the player
vAngles[0] = 90.0; //always make sure sprite is flat to the block
vAngles[1] += 90.0; //rotate the sprite by 90 because it doesnt point up (PAT!)
entity_set_vector(sprite, EV_VEC_angles, vAngles);
}
}
}
}
}
public client_PreThink(id)
{
//make sure player is connected
if (is_user_connected(id))
{
//display type of block that player is aiming at
new ent, body;
get_user_aiming(id, ent, body, 320);
if (isBlock(ent))
{
new blockType = entity_get_int(ent, EV_INT_body);
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "Block Type: %s", gszBlockNames[blockType]);
}
//if player has the measure tool enabled
if (gbMeasureToolEnabled[id])
{
new Float:vOrigin1[3];
new Float:vOrigin2[3];
new Float:vSizeMax1[3];
new Float:vSizeMax2[3];
new Float:fDist = 0.0;
new Float:fX = 0.0;
new Float:fY = 0.0;
new Float:fZ = 0.0;
if (is_valid_ent(gMeasureToolBlock1[id]))
{
if (is_valid_ent(gMeasureToolBlock2[id]))
{
//get position and size information from the blocks
entity_get_vector(gMeasureToolBlock1[id], EV_VEC_origin, vOrigin1);
entity_get_vector(gMeasureToolBlock2[id], EV_VEC_origin, vOrigin2);
entity_get_vector(gMeasureToolBlock1[id], EV_VEC_maxs, vSizeMax1);
entity_get_vector(gMeasureToolBlock2[id], EV_VEC_maxs, vSizeMax2);
//calculate differences on X, Y and Z
fX = floatabs(vOrigin2[0] - vOrigin1[0]) - vSizeMax1[0] - vSizeMax2[0];
fY = floatabs(vOrigin2[1] - vOrigin1[1]) - vSizeMax1[1] - vSizeMax2[1];
fZ = (vOrigin2[2] + vSizeMax2[2]) - (vOrigin1[2] + vSizeMax1[2]);
//make sure X and Y are never below 0.0
if (fX < 0.0) fX = 0.0;
if (fY < 0.0) fY = 0.0;
}
else
{
gMeasureToolBlock2[id] = 0;
}
}
else
{
gMeasureToolBlock1[id] = 0;
}
//calculate the sums of the 2 positions
new Float:pos1sum = gvMeasureToolPos1[id][0] + gvMeasureToolPos1[id][1] + gvMeasureToolPos1[id][2];
new Float:pos2sum = gvMeasureToolPos2[id][0] + gvMeasureToolPos2[id][1] + gvMeasureToolPos2[id][2];
//calculate distance between measure tool positions 1 and 2
if (pos1sum != 0.0 && pos2sum != 0.0)
{
fDist = get_distance_f(gvMeasureToolPos1[id], gvMeasureToolPos2[id]);
}
//show the values to the player
set_hudmessage(gHudRed, gHudGreen, gHudBlue, 0.02, 0.22, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "X: %.2f^nY: %.2f^nZ: %.2f^nDistance: %.2f", fX, fY, fZ, fDist);
}
//make sure player is alive
if (is_user_alive(id))
{
//if player has low gravity
if (gbLowGravity[id])
{
//get players flags
new flags = entity_get_int(id, EV_INT_flags);
//if player has feet on the ground, set gravity to normal
if (flags & FL_ONGROUND)
{
set_user_gravity(id);
gbLowGravity[id] = false;
}
}
//if player has auto bhop
if (gbAutoBhop[id])
{
//get players old buttons
new oldbuttons = get_user_oldbutton(id);
//remove jump flag from old buttons
oldbuttons &= ~IN_JUMP;
entity_set_int(id, EV_INT_oldbuttons, oldbuttons);
}
//trace directly down to see if there is a block beneath player
new Float:pOrigin[3];
new Float:pSize[3];
new Float:pMaxs[3];
new Float:vTrace[3];
new Float:vReturn[3];
entity_get_vector(id, EV_VEC_origin, pOrigin);
entity_get_vector(id, EV_VEC_size, pSize);
entity_get_vector(id, EV_VEC_maxs, pMaxs);
//calculate position of players feet
pOrigin[2] = pOrigin[2] - ((pSize[2] - 36.0) - (pMaxs[2] - 36.0));
//make the trace small for some blocks
vTrace[2] = pOrigin[2] - 1.0;
//do 4 traces for each corner of the player
for (new i = 0; i < 4; ++i)
{
switch (i)
{
case 0: { vTrace[0] = pOrigin[0] - 16; vTrace[1] = pOrigin[1] + 16; }
case 1: { vTrace[0] = pOrigin[0] + 16; vTrace[1] = pOrigin[1] + 16; }
case 2: { vTrace[0] = pOrigin[0] + 16; vTrace[1] = pOrigin[1] - 16; }
case 3: { vTrace[0] = pOrigin[0] - 16; vTrace[1] = pOrigin[1] - 16; }
}
ent = trace_line(id, pOrigin, vTrace, vReturn);
//if entity found is a block
if (isBlock(ent))
{
new blockType = entity_get_int(ent, EV_INT_body);
switch (blockType)
{
case BM_HEALER: actionHeal(id);
case BM_DAMAGE: actionDamage(id);
case BM_INVINCIBILITY: actionInvincible(id, false);
case BM_STEALTH: actionStealth(id, false);
case BM_TRAMPOLINE: actionTrampoline(id);
case BM_SPEEDBOOST: actionSpeedBoost(id);
case BM_DEATH: actionDeath(id);
case BM_NUKE: actionNuke(id, false);
case BM_LOWGRAVITY: actionLowGravity(id);
case BM_CAMOUFLAGE: actionCamouflage(id, false);
case BM_FIRE: actionFire(id, ent);
case BM_SLAP: actionSlap(id);
case BM_RANDOM: actionRandom(id, ent);
case BM_HONEY: actionHoney(id);
case BM_BOOTSOFSPEED: actionBootsOfSpeed(id, false);
case BM_AUTO_BHOP: actionAutoBhop(id, false);
case BM_DEAGLE: actionDeagle(id, false);
case BM_AWP: actionAwp(id, false);
case BM_FROST: actionFrost(id, false);
case BM_FLASH: actionFlash(id, false);
case BM_HE: actionHe(id, false);
case BM_MONEY: actionMoney(id, false);
}
}
}
//make the trace longer for other blocks
vTrace[2] = pOrigin[2] - 20.0;
//do 4 traces for each corner of the player
for (new i = 0; i < 4; ++i)
{
switch (i)
{
case 0: { vTrace[0] = pOrigin[0] - 16; vTrace[1] = pOrigin[1] + 16; }
case 1: { vTrace[0] = pOrigin[0] + 16; vTrace[1] = pOrigin[1] + 16; }
case 2: { vTrace[0] = pOrigin[0] + 16; vTrace[1] = pOrigin[1] - 16; }
case 3: { vTrace[0] = pOrigin[0] - 16; vTrace[1] = pOrigin[1] - 16; }
}
ent = trace_line(id, pOrigin, vTrace, vReturn);
//if entity found is a block
if (isBlock(ent))
{
new blockType = entity_get_int(ent, EV_INT_body);
switch (blockType)
{
case BM_TRAMPOLINE: actionTrampoline(id);
case BM_NOFALLDAMAGE: actionNoFallDamage(id);
case BM_ICE: actionOnIce(id);
case BM_BHOP_NOSLOW: actionNoSlowDown(id);
case BM_DELAYED: actionDelayed(id);
}
}
}
//display amount of invincibility/stealth/camouflage/boots of speed timeleft
new Float:fTime = halflife_time();
new Float:fTimeleftInvincible = gfInvincibleTimeOut[id] - fTime;
new Float:fTimeleftStealth = gfStealthTimeOut[id] - fTime;
new Float:fTimeleftCamouflage = gfCamouflageTimeOut[id] - fTime;
new Float:fTimeleftBootsOfSpeed = gfBootsOfSpeedTimeOut[id] - fTime;
new Float:fTimeleftAutoBhop = gfAutoBhopTimeOut[id] - fTime;
new szTextToShow[256] = "";
new szText[48];
new bool:bShowText = false;
if (fTimeleftInvincible >= 0.0)
{
format(szText, sizeof(szText), "Invincible: %.1f^n", fTimeleftInvincible);
add(szTextToShow, sizeof(szTextToShow), szText);
bShowText = true;
}
if (fTimeleftStealth >= 0.0)
{
format(szText, sizeof(szText), "Stealth: %.1f^n", fTimeleftStealth);
add(szTextToShow, sizeof(szTextToShow), szText);
bShowText = true;
}
if (fTimeleftCamouflage >= 0.0)
{
//if player is a CT
if (get_user_team(id) == 1)
{
format(szText, sizeof(szText), "You look like a Counter-Terrorist: %.1f^n", fTimeleftCamouflage);
}
else
{
format(szText, sizeof(szText), "You look like a Terrorist: %.1f^n", fTimeleftCamouflage);
}
add(szTextToShow, sizeof(szTextToShow), szText);
bShowText = true;
}
if (fTimeleftBootsOfSpeed >= 0.0)
{
format(szText, sizeof(szText), "Boots of speed: %.1f^n", fTimeleftBootsOfSpeed);
add(szTextToShow, sizeof(szTextToShow), szText);
bShowText = true;
}
if (fTimeleftAutoBhop >= 0.0)
{
format(szText, sizeof(szText), "Auto bunnyhop: %.1f^n", fTimeleftAutoBhop);
add(szTextToShow, sizeof(szTextToShow), szText);
bShowText = true;
}
//if there is some text to show then show it
if (bShowText)
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, szTextToShow);
}
}
//get players buttons
new buttons = get_user_button(id);
new oldbuttons = get_user_oldbutton(id);
//if player has grabbed an entity
if (gGrabbed[id] > 0)
{
//check for a single press on the following buttons
if (buttons & IN_JUMP && !(oldbuttons & IN_JUMP)) cmdJump(id);
if (buttons & IN_DUCK && !(oldbuttons & IN_DUCK)) cmdDuck(id);
if (buttons & IN_ATTACK && !(oldbuttons & IN_ATTACK)) cmdAttack(id);
if (buttons & IN_ATTACK2 && !(oldbuttons & IN_ATTACK2)) cmdAttack2(id);
//prevent player from using attack
buttons &= ~IN_ATTACK;
entity_set_int(id, EV_INT_button, buttons);
//if player has grabbed a valid entity
if (is_valid_ent(gGrabbed[id]))
{
//if block the player is grabbing is in their group and group count is larger than 1
if (isBlockInGroup(id, gGrabbed[id]) && gGroupCount[id] > 1)
{
new Float:vMoveTo[3];
new Float:vOffset[3];
new Float:vOrigin[3];
new block;
//move the block the player has grabbed and get the move vector
moveGrabbedEntity(id, vMoveTo);
//move the rest of the blocks in the players group using vector for grabbed block
for (new i = 0; i <= gGroupCount[id]; ++i)
{
block = gGroupedBlocks[id][i];
//if block is still in this players group
if (isBlockInGroup(id, block))
{
//get offset vector from block
entity_get_vector(block, EV_VEC_vuser1, vOffset);
vOrigin[0] = vMoveTo[0] - vOffset[0];
vOrigin[1] = vMoveTo[1] - vOffset[1];
vOrigin[2] = vMoveTo[2] - vOffset[2];
//move grouped block
moveEntity(id, block, vOrigin, false);
}
}
}
else
{
//move the entity the player has grabbed
moveGrabbedEntity(id);
}
}
else
{
cmdRelease(id);
}
}
//if player has just deleted something
if (gbJustDeleted[id])
{
//if player is pressing attack2
if (buttons & IN_ATTACK2)
{
//prevent player from using attack2
buttons &= ~IN_ATTACK2;
entity_set_int(id, EV_INT_button, buttons);
}
else
{
//player has now NOT just deleted something
gbJustDeleted[id] = false;
}
}
}
return PLUGIN_CONTINUE;
}
public client_PostThink(id)
{
//if player is alive
if (is_user_alive(id))
{
//if player is set to not get fall damage
if (gbNoFallDamage[id])
{
entity_set_int(id, EV_INT_watertype, -3);
gbNoFallDamage[id] = false;
}
}
}
public forward_EmitSound(id, channel, sample[])
{
if (is_user_alive(id) && containi(sample, "common/wpn_select.wav") >= 0)
{
actionTimer(id);
}
}
/***** EVENTS *****/
public eventPlayerDeath()
{
new id = read_data(2);
resetTimers(id);
}
public eventRoundRestart()
{
//iterate through all players
for (new id = 1; id <= 32; ++id)
{
//reset all players timers
resetTimers(id);
}
}
public eventPlayerSpawn(id)
{
//if player has godmode enabled
if (gbAdminGodmode[id])
{
//re-enable godmode on player
set_user_godmode(id, 1);
}
//if player has noclip enabled
if (gbAdminNoclip[id])
{
//re-enable noclip on player
set_user_noclip(id, 1);
}
}
resetTimers(id)
{
gfInvincibleTimeOut[id] = 0.0;
gfInvincibleNextUse[id] = 0.0;
gfStealthTimeOut[id] = 0.0;
gfStealthNextUse[id] = 0.0;
gfCamouflageTimeOut[id] = 0.0;
gfCamouflageNextUse[id] = 0.0;
gfNukeNextUse[id] = 0.0;
gbOnFire[id] = false;
gfRandomNextUse[id] = 0.0;
gfBootsOfSpeedTimeOut[id] = 0.0;
gfBootsOfSpeedNextUse[id] = 0.0;
gfAutoBhopTimeOut[id] = 0.0;
gfAutoBhopNextUse[id] = 0.0;
//remove any task this player might have
new taskId = TASK_INVINCIBLE + id;
if (task_exists(taskId))
{
remove_task(taskId);
}
taskId = TASK_STEALTH + id;
if (task_exists(taskId))
{
remove_task(taskId);
}
taskId = TASK_CAMOUFLAGE + id;
if (task_exists(taskId))
{
remove_task(taskId);
//change back to players old model
cs_set_user_model(id, gszCamouflageOldModel[id]);
}
taskId = TASK_BOOTSOFSPEED + id;
if (task_exists(taskId))
{
remove_task(taskId);
}
taskId = TASK_AUTOBHOP + id;
if (task_exists(taskId))
{
remove_task(taskId);
}
//make sure player is connected
if (is_user_connected(id))
{
//set players rendering to normal
set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 255);
}
//player is not 'on ice'
gbOnIce[id] = false;
//player slows down after jumping
gbNoSlowDown[id] = false;
//player does not have auto bhop
gbAutoBhop[id] = false;
//player does not have a timer
gbHasTimer[id] = false;
}
public eventCurWeapon(id)
{
new Float:fTime = halflife_time();
new Float:fTimeleftBootsOfSpeed = gfBootsOfSpeedTimeOut[id] - fTime;
//if the player has the boots of speed
if (fTimeleftBootsOfSpeed >= 0.0)
{
//set their max speed so they obtain their speed after changing weapon
set_user_maxspeed(id, gfBootsMaxSpeed);
}
}
/***** BLOCK ACTIONS *****/
actionDamage(id)
{
if (halflife_time() >= gfNextDamageTime[id])
{
if (get_user_health(id) > 0)
{
new Float:amount = get_cvar_float("bm_damageamount");
fakedamage(id, "damage block", amount, DMG_CRUSH);
}
gfNextDamageTime[id] = halflife_time() + 0.5;
}
}
actionHE(id, OverrideTimer)
{
//get game time
new Float:fTime = halflife_time();
//make sure player is alive
if (fTime >= gfHENextUse[id] || OverrideTimer)
{
//ID HE
give_item(id, "weapon_hegrenade");
{
//omg
}
//set the time when the player can use the nuke again (someone might have been invincible)
gfHENextUse[id] = fTime + get_cvar_float("bm_hecooldown");
//setup hud message to show who nuked what team
set_hudmessage(255, 255, 0, -1.0, 0.35, 0, 6.0, 10.0, 1.0, 1.0);
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "HE USED, WAIT 1 ROUND", gfHENextUse[id] - fTime);
}
}
actionFrost(id, OverrideTimer)
{
//get game time
new Float:fTime = halflife_time();
//make sure player is alive
if (fTime >= gfFrostNextUse[id] || OverrideTimer)
{
if ( get_user_team ( id ) == 1 )
{
give_item(id, "weapon_smokegrenade");
}
//set the time when the player can use the nuke again (someone might have been invincible)
gfFrostNextUse[id] = fTime + get_cvar_float("bm_frostcooldown");
//setup hud message to show who nuked what team
set_hudmessage(255, 255, 0, -1.0, 0.35, 0, 6.0, 10.0, 1.0, 1.0);
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "FROSTNADE USED, WAIT 1 ROUND", gfFrostNextUse[id] - fTime);
}
}
actionMoney(id, OverrideTimer)
{
//get game time
new Float:fTime = halflife_time();
//make sure player is alive
if (fTime >= gfMoneyNextUse[id] || OverrideTimer)
{
cs_set_user_money(id, cs_get_user_money (id) + 5005) ;
{
//omg
}
//set the time when the player can use the nuke again (someone might have been invincible)
gfMoneyNextUse[id] = fTime + get_cvar_float("bm_moneycooldown");
//setup hud message to show who nuked what team
set_hudmessage(255, 255, 0, -1.0, 0.35, 0, 6.0, 10.0, 1.0, 1.0);
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "MONEY USED, WAIT 1 ROUND", gfMoneyNextUse[id] - fTime);
}
}
actionAwp(id, OverrideTimer)
{
//get game time
new Float:fTime = halflife_time();
//make sure player is alive
if (fTime >= gfAwpNextUse[id] || OverrideTimer)
{
if ( get_user_team ( id ) == 1 )
{
cs_set_weapon_ammo(give_item(id, "weapon_awp"), 1);
}
//set the time when the player can use the nuke again (someone might have been invincible)
gfAwpNextUse[id] = fTime + get_cvar_float("bm_awpcooldown");
//setup hud message to show who nuked what team
set_hudmessage(255, 255, 0, -1.0, 0.35, 0, 6.0, 10.0, 1.0, 1.0);
//Show Message
new szPlayerName[32];
get_user_name(id, szPlayerName, 32);
if ( get_user_team ( id ) == 1 )
{
show_hudmessage(0, "Oh My God, Oh SHIT %s Got a fuck AWP!", szPlayerName);
}
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "AWP USED, WAIT 1 ROUND", gfAwpNextUse[id] - fTime);
}
}
actionFlash(id, OverrideTimer)
{
//get game time
new Float:fTime = halflife_time();
//make sure player is alive
if (fTime >= gfFlashNextUse[id] || OverrideTimer)
{
give_item(id, "weapon_flashbang");
{
//omg
}
//set the time when the player can use the nuke again (someone might have been invincible)
gfFlashNextUse[id] = fTime + get_cvar_float("bm_flashcooldown");
//setup hud message to show who nuked what team
set_hudmessage(255, 255, 0, -1.0, 0.35, 0, 6.0, 10.0, 1.0, 1.0);
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "FLASH USED, WAIT 1 ROUND", gfFlashNextUse[id] - fTime);
}
}
actionDelayed(id)
{
new taskid = TASK_BHOPSOLIDNOT + id;
//remove any existing 'slow down' task
if (task_exists(taskid))
{
remove_task(taskid);
}
//set task to remove 'no slow down' effect very soon
set_task(2.0, "taskSoldNot", taskid);
}
actionHeal(id)
{
if (halflife_time() >= gfNextHealTime[id])
{
new hp = get_user_health(id);
new amount = floatround(get_cvar_float("bm_healamount"), floatround_floor);
new sum = (hp + amount);
if (sum < 100)
{
set_user_health(id, sum);
}
else
{
set_user_health(id, 100);
}
gfNextHealTime[id] = halflife_time() + 0.5;
}
}
actionInvincible(id, OverrideTimer)
{
new Float:fTime = halflife_time();
if (fTime >= gfInvincibleNextUse[id] || OverrideTimer)
{
new Float:fTimeout = get_cvar_float("bm_invincibletime");
set_user_godmode(id, 1);
set_task(fTimeout, "taskInvincibleRemove", TASK_INVINCIBLE + id, "", 0, "a", 1);
//only make player glow white for invincibility if player isn't already stealth
if (fTime >= gfStealthTimeOut[id])
{
set_user_rendering(id, kRenderFxGlowShell, 255, 255, 255, kRenderNormal, 16);
}
//play invincibility sound
emit_sound(id, CHAN_STATIC, gszInvincibleSound, 1.0, ATTN_NORM, 0, PITCH_NORM);
gfInvincibleTimeOut[id] = fTime + fTimeout;
gfInvincibleNextUse[id] = fTime + fTimeout + get_cvar_float("bm_invinciblecooldown");
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "Invincibility next use: %.1f", gfInvincibleNextUse[id] - fTime);
}
}
actionStealth(id, OverrideTimer)
{
new Float:fTime = halflife_time();
//check if player is outside of cooldown time to use stealth
if (fTime >= gfStealthNextUse[id] || OverrideTimer)
{
new Float:fTimeout = get_cvar_float("bm_stealthtime");
//set a task to remove stealth after time out amount
set_task(fTimeout, "taskStealthRemove", TASK_STEALTH + id, "", 0, "a", 1);
//make player invisible
set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderTransColor, 0);
//play stealth sound
emit_sound(id, CHAN_STATIC, gszStealthSound, 1.0, ATTN_NORM, 0, PITCH_NORM);
gfStealthTimeOut[id] = fTime + fTimeout;
gfStealthNextUse[id] = fTime + fTimeout + get_cvar_float("bm_stealthcooldown");
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "Stealth next use: %.1f", gfStealthNextUse[id] - fTime);
}
}
actionTrampoline(id)
{
//if trampoline timeout has exceeded (needed to prevent velocity being given multiple times)
if (halflife_time() >= gfTrampolineTimeout[id])
{
new Float:velocity[3];
//set player Z velocity to make player bounce
entity_get_vector(id, EV_VEC_velocity, velocity);
velocity[2] = 500.0; //jump velocity
entity_set_vector(id, EV_VEC_velocity, velocity);
entity_set_int(id, EV_INT_gaitsequence, 6); //play the Jump Animation
gfTrampolineTimeout[id] = halflife_time() + 0.5;
}
}
actionSpeedBoost(id)
{
//if speed boost timeout has exceeded (needed to prevent speed boost being given multiple times)
if (halflife_time() >= gfSpeedBoostTimeOut[id])
{
new Float:pAim[3];
//set velocity on player in direction they're aiming
velocity_by_aim(id, 800, pAim);
pAim[2] = 260.0; //make sure Z velocity is only as high as a jump
entity_set_vector(id, EV_VEC_velocity, pAim);
entity_set_int(id, EV_INT_gaitsequence, 6); //play the Jump Animation
gfSpeedBoostTimeOut[id] = halflife_time() + 0.5;
}
}
actionNoFallDamage(id)
{
//set the player to not receive any fall damage (handled in client_PostThink)
gbNoFallDamage[id] = true;
}
actionOnIce(id)
{
new taskid = TASK_ICE + id;
if (!gbOnIce[id])
{
//save players maxspeed value
gfOldMaxSpeed[id] = get_user_maxspeed(id);
//make player feel like they're on ice
entity_set_float(id, EV_FL_friction, 0.15);
set_user_maxspeed(id, 600.0);
//player is now 'on ice'
gbOnIce[id] = true;
}
//remove any existing 'not on ice' task
if (task_exists(taskid))
{
remove_task(taskid);
}
//set task to remove 'on ice' effect very soon (task replaced if player is still on ice before task time reached)
set_task(0.1, "taskNotOnIce", taskid);
}
actionDeath(id)
{
//if player does not have godmode enabled (admin godmode or invincibility)
if (!get_user_godmode(id))
{
//kill player by inflicting massive damage
fakedamage(id, "the block of death", 10000.0, DMG_GENERIC);
}
}
actionNuke(id, OverrideTimer)
{
//get game time
new Float:fTime = halflife_time();
//make sure player is alive
if (is_user_alive(id) && (fTime >= gfNukeNextUse[id] || OverrideTimer))
{
//get players team
new CsTeams:playerTeam = cs_get_user_team(id);
new CsTeams:team;
//iterate through all players
for (new i = 1; i <= 32; ++i)
{
//make sure player is alive
if (is_user_alive(i))
{
team = cs_get_user_team(i);
//if this player is on a different team to the player that used the nuke
if ((team == CS_TEAM_T && playerTeam == CS_TEAM_CT) || (team == CS_TEAM_CT && playerTeam == CS_TEAM_T))
{
//slay player
fakedamage(i, "a nuke", 10000.0, DMG_BLAST);
}
}
//make sure player is connected
if (is_user_connected(i))
{
//make the screen flash for a nuke effect
message_begin(MSG_ONE, gMsgScreenFade, {0, 0, 0}, i);
write_short(1024); //duration
write_short(1024); //hold time
write_short(4096); //type (in / out)
write_byte(255); //red
write_byte(255); //green
write_byte(255); //blue
write_byte(255); //alpha
message_end();
}
}
//play explosion sound
emit_sound(0, CHAN_STATIC, gszNukeExplosion, 1.0, ATTN_NORM, 0, PITCH_NORM);
//set the time when the player can use the nuke again (someone might have been invincible)
gfNukeNextUse[id] = fTime + get_cvar_float("bm_nukecooldown");
//get the name of the player that used the nuke
new szPlayerName[32];
get_user_name(id, szPlayerName, 32);
//setup hud message to show who nuked what team
set_hudmessage(255, 255, 0, -1.0, 0.35, 0, 6.0, 10.0, 1.0, 1.0);
//show message saying player nuked the other team
if (playerTeam == CS_TEAM_T)
{
show_hudmessage(0, "%s just nuked the Counter-Terrorists", szPlayerName);
}
else
{
show_hudmessage(0, "%s just nuked the Terrorists", szPlayerName);
}
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "Nuke next use: %.1f", gfNukeNextUse[id] - fTime);
}
}
actionCamouflage(id, OverrideTimer)
{
new Float:fTime = halflife_time();
//check if player is outside of cooldown time to use camouflage
if (fTime >= gfCamouflageNextUse[id] || OverrideTimer)
{
new Float:fTimeout = get_cvar_float("bm_camouflagetime");
//get players team and model
new szModel[32];
new team;
cs_get_user_model(id, szModel, 32);
team = get_user_team(id);
//save current player model
gszCamouflageOldModel[id] = szModel;
//change player model depending on their current team
if (team == 1) //TERRORIST
{
cs_set_user_model(id, "urban");
}
else
{
cs_set_user_model(id, "leet");
}
//play camouflage sound
emit_sound(id, CHAN_STATIC, gszCamouflageSound, 1.0, ATTN_NORM, 0, PITCH_NORM);
//set a task to remove camouflage after time out amount
set_task(fTimeout, "taskCamouflageRemove", TASK_CAMOUFLAGE + id, "", 0, "a", 1);
//set timers to prevent player from using camouflage again so soon
gfCamouflageTimeOut[id] = fTime + fTimeout;
gfCamouflageNextUse[id] = fTime + fTimeout + get_cvar_float("bm_camouflagecooldown");
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "Camouflage next use: %.1f", gfCamouflageNextUse[id] - fTime);
}
}
actionLowGravity(id)
{
//set player to have low gravity
set_user_gravity(id, 0.25);
//set global boolean showing player has low gravity
gbLowGravity[id] = true;
}
actionFire(id, ent)
{
if (halflife_time() >= gfNextDamageTime[id])
{
new hp = get_user_health(id);
//if players health is greater than 0
if (hp > 0)
{
//if player does not have godmode
if (!get_user_godmode(id))
{
new Float:amount = get_cvar_float("bm_firedamageamount") / 10.0;
new Float:newAmount = hp - amount;
//if this amount of damage won't kill the player
if (newAmount > 0)
{
set_user_health(id, floatround(newAmount, floatround_floor));
}
else
{
//use fakedamage to kill the player
fakedamage(id, "fire block", amount, DMG_BURN);
}
}
//get halflife time and time for next fire sound from fire block
new Float:fTime = halflife_time();
new Float:fNextFireSoundTime = entity_get_float(ent, EV_FL_ltime);
//if the current time is greater than or equal to the next time to play the fire sound
if (fTime >= fNextFireSoundTime)
{
//play the fire sound
emit_sound(ent, CHAN_ITEM, gszFireSoundFlame, 0.6, ATTN_NORM, 0, PITCH_NORM);
//set the fire blocks time
entity_set_float(ent, EV_FL_ltime, fTime + 0.75);
}
//get effects vectors using block origin
new Float:origin1[3];
new Float:origin2[3];
entity_get_vector(ent, EV_VEC_origin, origin1);
entity_get_vector(ent, EV_VEC_origin, origin2);
origin1[0] -= 32.0;
origin1[1] -= 32.0;
origin1[2] += 10.0;
origin2[0] += 32.0;
origin2[1] += 32.0;
origin2[2] += 10.0;
//get a random height for the flame
new randHeight = random_num(0, 32) + 16;
//show some effects
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BUBBLES);
write_coord(floatround(origin1[0], floatround_floor)); //min start position
write_coord(floatround(origin1[1], floatround_floor));
write_coord(floatround(origin1[2], floatround_floor));
write_coord(floatround(origin2[0], floatround_floor)); //max start position
write_coord(floatround(origin2[1], floatround_floor));
write_coord(floatround(origin2[2], floatround_floor));
write_coord(randHeight); //float height
write_short(gSpriteIdFire); //model index
write_byte(10); //count
write_coord(1); //speed
message_end();
}
gfNextDamageTime[id] = halflife_time() + 0.05;
}
}
actionSlap(id)
{
user_slap(id, 0);
user_slap(id, 0);
set_hudmessage(255, 255, 255, -1.0, 0.20, 0, 6.0, 12.0, 0.0, 1.0, 3);
show_hudmessage(id, "FLY BABY");
}
actionRandom(id, ent)
{
new Float:fTime = halflife_time();
//check if player is outside of cooldown time to use camouflage
if (fTime >= gfRandomNextUse[id])
{
//get which type of block this is set to be
new blockType = entity_get_int(ent, EV_INT_iuser4);
//do the random block action
switch (blockType)
{
case BM_STEALTH: actionStealth(id, true);
case BM_DEATH: actionDeath(id);
case BM_CAMOUFLAGE: actionCamouflage(id, true);
case BM_SLAP: actionSlap(id);
case BM_BOOTSOFSPEED: actionBootsOfSpeed(id, true);
case BM_DEAGLE; actionDeagle(id, true);
case BM_FROST; actionFrost(id, true);
case BM_AWP; actionAWP(id, true);
case BM_HE; actionHE(id,true);
case BM_FLASH; actionFlash(id,true);
}
//set timer to prevent player from using the random block again so soon
gfRandomNextUse[id] = fTime + get_cvar_float("bm_randomcooldown");
//set this random block to another random block!
new randNum = random_num(0, gRandomBlocksMax - 1);
entity_set_int(ent, EV_INT_iuser4, gRandomBlocks[randNum]);
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "Random block next use: %.1f", gfRandomNextUse[id] - fTime);
}
}
actionHoney(id)
{
new taskid = TASK_HONEY + id;
//make player feel like they're stuck in honey by lowering their maxspeed
set_user_maxspeed(id, 50.0);
//remove any existing 'in honey' task
if (task_exists(taskid))
{
remove_task(taskid);
}
else
{
//half the players velocity the first time they touch it
new Float:vVelocity[3];
entity_get_vector(id, EV_VEC_velocity, vVelocity);
vVelocity[0] = vVelocity[0] / 2.0;
vVelocity[1] = vVelocity[1] / 2.0;
entity_set_vector(id, EV_VEC_velocity, vVelocity);
}
//set task to remove 'in honey' effect very soon (task replaced if player is still in honey before task time reached)
set_task(0.1, "taskNotInHoney", taskid);
}
actionBootsOfSpeed(id, bool:OverrideTimer)
{
new Float:fTime = halflife_time();
//check if player is outside of cooldown time to use the boots of speed
if (fTime >= gfBootsOfSpeedNextUse[id] || OverrideTimer)
{
new Float:fTimeout = get_cvar_float("bm_bootsofspeedtime");
//set a task to remove the boots of speed after time out amount
set_task(fTimeout, "taskBootsOfSpeedRemove", TASK_BOOTSOFSPEED + id, "", 0, "a", 1);
//set the players maxspeed to 400 so they run faster!
set_user_maxspeed(id, gfBootsMaxSpeed);
//play boots of speed sound
emit_sound(id, CHAN_STATIC, gszBootsOfSpeedSound, 1.0, ATTN_NORM, 0, PITCH_NORM);
gfBootsOfSpeedTimeOut[id] = fTime + fTimeout;
gfBootsOfSpeedNextUse[id] = fTime + fTimeout + get_cvar_float("bm_bootsofspeedcooldown");
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "Boots of speed next use: %.1f", gfBootsOfSpeedNextUse[id] - fTime);
}
}
actionNoSlowDown(id)
{
new taskid = TASK_NOSLOW + id;
gbNoSlowDown[id] = true;
//remove any existing 'slow down' task
if (task_exists(taskid))
{
remove_task(taskid);
}
//set task to remove 'no slow down' effect very soon
set_task(0.1, "taskSlowDown", taskid);
}
actionDeagle(id, OverrideTimer)
{
//get game time
new Float:fTime = halflife_time();
//make sure player is alive
if (fTime >= gfDeagleNextUse[id] || OverrideTimer)
{
if ( get_user_team ( id ) == 1 )
{
cs_set_weapon_ammo(give_item(id, "weapon_deagle"), 1);
}
//set the time when the player can use the nuke again (someone might have been invincible)
gfDeagleNextUse[id] = fTime + get_cvar_float("bm_deaglecooldown");
//setup hud message to show who nuked what team
set_hudmessage(255, 255, 0, -1.0, 0.35, 0, 6.0, 10.0, 1.0, 1.0);
//Show Message
new szPlayerName[32];
get_user_name(id, szPlayerName, 32);
if ( get_user_team ( id ) == 1 )
{
show_hudmessage(0, "Oh My God, Oh SHIT %s Got a fuck Deagle!", szPlayerName);
}
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "DEAGLE USED, WAIT NEXT ROUND", gfDeagleNextUse[id] - fTime);
}
}
actionAutoBhop(id, bool:OverrideTimer)
{
new Float:fTime = halflife_time();
//check if player is outside of cooldown time to use the auto bhop
if (fTime >= gfAutoBhopNextUse[id] || OverrideTimer)
{
new Float:fTimeout = get_cvar_float("bm_autobhoptime");
//set a task to remove the auto bhop after time out amount
set_task(fTimeout, "taskAutoBhopRemove", TASK_AUTOBHOP + id, "", 0, "a", 1);
//set autobhop boolean
gbAutoBhop[id] = true;
//play boots of speed sound
emit_sound(id, CHAN_STATIC, gszAutoBhopSound, 1.0, ATTN_NORM, 0, PITCH_NORM);
gfAutoBhopTimeOut[id] = fTime + fTimeout;
gfAutoBhopNextUse[id] = fTime + fTimeout + get_cvar_float("bm_autobhopcooldown");
}
else
{
set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel);
show_hudmessage(id, "Auto bunnyhop next use: %.1f", gfAutoBhopNextUse[id] - fTime);
}
}
actionTeleport(id, ent)
{
//get end entity id
new tele = entity_get_int(ent, EV_INT_iuser1);
//if teleport end id is valid
if (tele)
{
//get end entity origin
new Float:vTele[3];
entity_get_vector(tele, EV_VEC_origin, vTele);
//if id of entity being teleported is a player and telefrags CVAR is set then kill any nearby players
if ((id > 0 && id <= 32) && get_cvar_num("bm_telefrags") > 0)
{
new player = -1;
do
{
player = find_ent_in_sphere(player, vTele, 16.0);
//if entity found is a player
if (player > 0 && player <= 32)
{
//if player is alive, and is not the player that went through the teleport
if (is_user_alive(player) && player != id)
{
//kill the player
user_kill(player, 1);
}
}
}while(player);
}
//get origin of the start of the teleport
new Float:vOrigin[3];
new origin[3];
entity_get_vector(ent, EV_VEC_origin, vOrigin);
FVecIVec(vOrigin, origin);
//show some teleporting effects
message_begin(MSG_PVS, SVC_TEMPENTITY, origin);
write_byte(TE_IMPLOSION);
write_coord(origin[0]);
write_coord(origin[1]);
write_coord(origin[2]);
write_byte(64); // radius
write_byte(100); // count
write_byte(6); // life
message_end();
//teleport player
entity_set_vector(id, EV_VEC_origin, vTele);
//reverse players Z velocity
new Float:vVelocity[3];
entity_get_vector(id, EV_VEC_velocity, vVelocity);
vVelocity[2] = floatabs(vVelocity[2]);
entity_set_vector(id, EV_VEC_velocity, vVelocity);
//if teleport sound CVAR is set
if (get_cvar_num("bm_teleportsound") > 0)
{
//play teleport sound
emit_sound(id, CHAN_STATIC, gszTeleportSound, 1.0, ATTN_NORM, 0, PITCH_NORM);
}
}
}
actionTimer(id)
{
new Float:origin[3];
new Float:radius = 100.0;
new ent = -1;
new bool:bNearStart = false;
new bool:bNearEnd = false;
//get players origin
entity_get_vector(id, EV_VEC_origin, origin);
//find entities in a sphere around the player
while ((ent = find_ent_in_sphere(ent, origin, radius)))
{
//if entity is a timer
if (isTimer(ent))
{
//get what type of timer it is (start/end)
new timerType = entity_get_int(ent, EV_INT_body);
switch (timerType)
{
case TIMER_START: bNearStart = true;
case TIMER_END: bNearEnd = true;
}
}
}
if (bNearStart && bNearEnd)
{
//start or stop timer depending on whether or not the player has a timer
if (gbHasTimer[id])
{
timerStop(id);
}
else
{
timerStart(id);
}
}
else if (bNearStart)
{
timerStart(id);
}
else if (bNearEnd)
{
timerStop(id);
}
}
public timerStart(id)
{
//if player is alive
if (is_user_alive(id))
{
//store the game time to calculate players time later
gfTimerTime[id] = halflife_time();
//if player already had a timer
if (gbHasTimer[id])
{
client_print(id, print_chat, "%sTimer Re-started.", gszPrefix);
}
else
{
gbHasTimer[id] = true;
client_print(id, print_chat, "%sTimer Started.", gszPrefix);
}
}
}
public timerStop(id)
{
if (gbHasTimer[id])
{
gbHasTimer[id] = false;
//get players name
new szName[33];
get_user_name(id, szName, 32);
//calculate players time in minutes and seconds
new Float:fTime = halflife_time() - gfTimerTime[id];
new Float:fMins = fTime / 60.0;
new mins = floatround(fMins, floatround_floor);
new Float:fSecs = (fMins - mins) * 60.0;
//format the players time into a string
new szTime[17];
format(szTime, 16, "%s%d:%s%.3f", (mins < 10 ? "0" : ""), mins, (fSecs < 10.0 ? "0" : ""), fSecs);
//announce the players time
client_print(0, print_chat, "%s'%s' just completed the course in %s", gszPrefix, szName, szTime);
//player no longer has a timer
gbHasTimer[id] = false;
//add players time to scoreboard
timerCheckScoreboard(id, fTime);
}
}
public timerCheckScoreboard(id, Float:fTime)
{
new szName[32], szSteamId[32];
//get players name, steam ID and time
get_user_name(id, szName, 32);
get_user_authid(id, szSteamId, 32);
fTime = halflife_time() - gfTimerTime[id];
for (new i = 0; i < 15; i++)
{
//if the player was faster than a time on the scoreboard
if (fTime < gfScoreTimes[i])
{
new pos = i;
//get position where the player is already on the scoreboard (if any)
while (!equali(gszScoreSteamIds[pos], szSteamId) && pos < 14)
{
pos++;
}
//shift scores down
for (new j = pos; j > i; j--)
{
format(gszScoreSteamIds[j], 32, gszScoreSteamIds[j - 1]);
format(gszScoreNames[j], 32, gszScoreNames[j - 1]);
gfScoreTimes[j] = gfScoreTimes[j - 1];
}
//put player onto the scoreboard
format(gszScoreSteamIds[i], 32, szSteamId);
format(gszScoreNames[i], 32, szName);
gfScoreTimes[i] = fTime;
//if player got first place on the scoreboard
if ((i + 1) == 1)
{
client_print(0, print_chat, "%s'%s' is now the fastest player on the course!", gszPrefix, szName);
}
else
{
client_print(0, print_chat, "%s'%s' is now rank %d on the scoreboard", gszPrefix, szName, (i + 1));
}
break;
}
//compare steam ID of player with steam ID on scoreboard
if (equali(gszScoreSteamIds[i], szSteamId))
{
//break out of loop because player did not beat their old time
break;
}
}
}
public timerShowScoreboard(id)
{
new szLine[128];
new szMapName[32];
new szConfigsDir[32];
new szHostName[32];
new i = 0, len = 0;
new szTop15File[96];
new szCSS[512];
new szTime[16];
new szName[33];
new szBuffer[2048];
new bufSize = sizeof(szBuffer) - 1;
get_mapname(szMapName, 31);
get_configsdir(szConfigsDir, 31);
get_cvar_string("hostname", szHostName, 31);
format(szTop15File, 96, "%s/blockmaker_scoreboard.css", szConfigsDir);
//get contents of CSS file
getFileContents(szTop15File, szCSS);
len += format(szBuffer[len], bufSize-len, "<style>%s</style>", szCSS);
len += format(szBuffer[len], bufSize-len, "<h1>%s</h1>", szMapName);
// ************* START OF TABLE **************
len += format(szBuffer[len], bufSize-len, "<table><tr><th>#<th>Player<th>Time");
//iterate through the scoreboard
for (i = 0; i < 15; i++)
{
//if top15 entry is blank
if (gfScoreTimes[i] == 999999.9)
{
//create table row
format(szLine, 127, "<tr><td>%d<td id=b><td id=c>", (i+1));
}
else
{
//make name HTML friendly
htmlFriendly(szName);
//calculate players time in minutes and seconds
new Float:fMins = (gfScoreTimes[i] / 60.0);
new mins = floatround(fMins, floatround_floor);
new Float:fSecs = (fMins - mins) * 60.0;
//format the players time into a string
format(szTime, 16, "%s%d:%s%.3f", (mins < 10 ? "0" : ""), mins, (fSecs < 10.0 ? "0" : ""), fSecs);
//create table row
format(szLine, 127, "<tr><td id=a>%d<td id=b>%s<td id=c>%s", (i+1), gszScoreNames[i], szTime);
}
//append table row to szBuffer
len += format(szBuffer[len], bufSize-len, szLine);
}
Last edited by KyeL; 12-12-2009 at 07:35.
|
|