View Single Post
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 07-01-2010 , 22:38   Re: Blockmaker (All-in-One Tutorial)
Reply With Quote #2

Adding Blocks Step-By-Step


O-k, I've seen a couple tutorials around the internet, the most recent one I seen, just taught you how to change the nuke.. (Wtf?), thats not even adding anything.. Here is a more in depth tutorial. Simple, but gets you what you want.

So were gonna add a deagle block! We're gonna be using the original blockmaker: Blockmaker v4.01

(Note: everything you see in my code, thats not in yours, add to yours! Or just copy and paste.)

Open the .sma (Which I'm assuming you already have), and look at the beginning where it says:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <cstrike>
#include <fakemeta>
 
#pragma semicolon 1;
 
#define PLUGIN "blockmaker"
#define VERSION "4.01"
#define AUTHOR "Necro"
#define BM_ADMIN_LEVEL ADMIN_MENU    //admin access level to use this plugin. ADMIN_MENU = flag 'u'
 
new DeagleUsed[42]; 
That is just a cvar, that tells rather or not it has been used

Now search for:

PHP Code:
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_default.mdl"
Thats what the block model looks like

Now search for:

PHP Code:
// block & teleport types
const gBlockMax 25;
new 
gSelectedBlockType[gBlockMax];
new 
gRender[gBlockMax];
new 
gRed[gBlockMax];
new 
gGreen[gBlockMax];
new 
gBlue[gBlockMax];
new 
gAlpha[gBlockMax]; 
What your looking at here is really just "const gBlockMax = 25;" that describes to the blockmaker how many blocks there are, this is vital, if you dont change this every time you add a block, the server wont work.

Now search for:
(Note: All the letters in yours are different than mine, fix that!)

PHP Code:
    BM_PLATFORM,        //A
    
BM_BHOP,        //B
    
BM_DAMAGE,        //C
    
BM_HEALER,        //D
    
BM_NOFALLDAMAGE,    //E
    
BM_ICE,            //F
    
BM_TRAMPOLINE,        //G
    
BM_SPEEDBOOST,        //H
    
BM_INVINCIBILITY,    //I
    
BM_STEALTH,        //J
    
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 
This is kind of a bind (not to a key), it binds a certain tag with a letter, so if it is used again in some other portion of coding, it knows your talking about that tag.

Now search for:

PHP Code:
    "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" 
This is the list that shows in the game, you can rename any of these, but it will not effect the creation of the block.

Now right below it is:

PHP Code:
new const gBlockSaveIds[gBlockMax] =
{
    
'A''B''C''D''E''F''G''H''I''J''K''L''M''N''O''P''Q''R''S''T''U''V''W''X''Y' 
Remember what I said before, they are binded to tags. Such as Y, Y is binded to BM_DEAGLE.

When you run out of letters, go to numbers.

Now search for:

PHP Code:
    //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
This makes the model look like what it does (confusing)

Now search for:

PHP Code:
        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
This just says: If szType is DEAGLE, the blockType that is created is BM_DEAGLE

Now search for:

PHP Code:
                        case BM_HEALERactionHeal(id);
                        case 
BM_DAMAGEactionDamage(id);
                        case 
BM_INVINCIBILITYactionInvincible(idfalse);
                        case 
BM_STEALTHactionStealth(idfalse);
                        case 
BM_TRAMPOLINEactionTrampoline(id);
                        case 
BM_SPEEDBOOSTactionSpeedBoost(id);
                        case 
BM_DEATHactionDeath(id);
                        case 
BM_NUKEactionNuke(idfalse);
                        case 
BM_LOWGRAVITYactionLowGravity(id);
                        case 
BM_CAMOUFLAGEactionCamouflage(idfalse);
                        case 
BM_FIREactionFire(ident);
                        case 
BM_SLAPactionSlap(id);
                        case 
BM_RANDOMactionRandom(ident);
                        case 
BM_HONEYactionHoney(id);
                        case 
BM_BOOTSOFSPEEDactionBootsOfSpeed(idfalse);
                        case 
BM_AUTO_BHOPactionAutoBhop(idfalse);
                        case 
BM_DEAGLEactionDeagle(id); 
this says what action the tag will use such as:
case BM_DEAGLE: actionDeagle(id);
this means BM_DEAGLE will use the action named "actionDeagle(id);"

Now search for:

PHP Code:
public eventRoundRestart()
{
    
//iterate through all players
    
for (new id 1id <= 32; ++id)
    {
        
//reset all players timers
        
resetTimers(id);
 
        
DeagleUsed[id] = false;
    }

public eventRoundRestart is just a list of what resets when the round restarts, in the action "actionDeagle(id);", it is set to make "DeagleUsed[id] = true;" which means that you have used a deagle block and you cant use it again, but, since I put "DeagleUsed[id] = false;" under public eventRoundRestart, it lets the server know at the beginning of each round that I can use the deagle block again.

Now search for:

PHP Code:
/***** BLOCK ACTIONS *****/
actionDeagle(id)
{
    if (
is_user_alive(id) && !DeagleUsed[id] && get_user_team(id) == 1)
        {
        
give_item(id"weapon_deagle");
        
cs_set_weapon_ammo(find_ent_by_owner(1"weapon_deagle"id), 1);
        
DeagleUsed[id] = true;
        new 
deaglename[42];
        
get_user_name(iddeaglename32);
        
set_hudmessage(255255255, -1.0, -1.006.04.0);
        
show_hudmessage(0"Be careful CT! %s has a Deagle!"deaglename);
    }
}
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"amountDMG_CRUSH);
        }
 
        
gfNextDamageTime[id] = halflife_time() + 0.5;
    }

This is the action of course

Now search for:

PHP Code:
                        case 'A'createBlock(0BM_PLATFORMvVec1axissize);
                        case 
'B'createBlock(0BM_BHOPvVec1axissize);
                        case 
'C'createBlock(0BM_DAMAGEvVec1axissize);
                        case 
'D'createBlock(0BM_HEALERvVec1axissize);
                        case 
'E'createBlock(0BM_NOFALLDAMAGEvVec1axissize);
                        case 
'F'createBlock(0BM_ICEvVec1axissize);
                        case 
'G'createBlock(0BM_TRAMPOLINEvVec1axissize);
                        case 
'H'createBlock(0BM_SPEEDBOOSTvVec1axissize);
                        case 
'I'createBlock(0BM_INVINCIBILITYvVec1axissize);
                        case 
'J'createBlock(0BM_STEALTHvVec1axissize);
                        case 
'K'createBlock(0BM_DEATHvVec1axissize);
                        case 
'L'createBlock(0BM_NUKEvVec1axissize);
                        case 
'M'createBlock(0BM_CAMOUFLAGEvVec1axissize);
                        case 
'N'createBlock(0BM_LOWGRAVITYvVec1axissize);
                        case 
'O'createBlock(0BM_FIREvVec1axissize);
                        case 
'P'createBlock(0BM_SLAPvVec1axissize);
                        case 
'Q'createBlock(0BM_RANDOMvVec1axissize);
                        case 
'R'createBlock(0BM_HONEYvVec1axissize);
                        case 
'S'createBlock(0BM_BARRIER_CTvVec1axissize);
                        case 
'T'createBlock(0BM_BARRIER_TvVec1axissize);
                        case 
'U'createBlock(0BM_BOOTSOFSPEEDvVec1axissize);
                        case 
'V'createBlock(0BM_GLASSvVec1axissize);
                        case 
'W'createBlock(0BM_BHOP_NOSLOWvVec1axissize);
                        case 
'X'createBlock(0BM_AUTO_BHOPvVec1axissize);
                        case 
'Y'createBlock(0BM_DEAGLEvVec1axissize); 
And this is the bind again!


Other actions

Awp:

PHP Code:
actionAwp(id)
{
    if (
is_user_alive(id) && !AwpUsed[id] && get_user_team(id) == 1)
        {
        
give_item(id"weapon_awp");
        
cs_set_weapon_ammo(find_ent_by_owner(1"weapon_awp"id), 1);
        
AwpUsed[id] = true;
        new 
awpname[42];
        
get_user_name(idawpname32);
        
set_hudmessage(255255255, -1.0, -1.006.04.0);
        
show_hudmessage(0"Be careful CT! %s has a awp!"awpname);
    }

Damage Bhop:

PHP Code:
action_DMGBhop(ident)
{
    if ( 
get_gametime() >= gfDmgBhopNextUse[id] )
        {
            new 
fDamage 10;
            
fakedamage(id"Damage block"fDamageDMG_CRUSH);
 
            
gfDmgBhopNextUse[id] = get_gametime() + 0.5;
 
            if ( !
task_exists(TASK_SOLIDNOT ent) && !task_exists(TASK_SOLID ent) )
            {
            
set_task(0.1"task_SolidNot"TASK_SOLIDNOT ent);
            }
        }

Frost Grenade:

PHP Code:
actionFrostGrenade(idOverrideTimer)
{
    
//get game time
    
new Float:fTime halflife_time();
 
    
//make sure player is alive
    
if (fTime >= gfFrostGrenadeNextUse[id] || OverrideTimer)
    {
        if ( 
get_user_team id ) == )
        {
        
give_item(id"weapon_smokegrenade");
        }
 
        
//set the time when player can use frost grenade again
        
gfFrostNextUse[id] = fTime get_cvar_float("bm_frostgrenadecooldown");
 
        
//setup hud message to show who nuked what team
        
set_hudmessage(2552550, -1.00.3506.010.01.01.0);
 
    }
    else
    {
        
set_hudmessage(gHudRedgHudGreengHudBluegfTextXgfTextYgHudEffectsgfHudFxTimegfHudHoldTimegfHudFadeInTimegfHudFadeOutTimegHudChannel);
        
show_hudmessage(id"FROSTNADE BLOCK NEXT USE AFTER 1 ROUND"gfFrostNextUse[id] - fTime);
    }

Flash Grenade:

PHP Code:
actionFlashGrenade(idOverrideTimer)
{
    
//get game time
    
new Float:fTime halflife_time();
 
    
//make sure player is alive
    
if (fTime >= gfFlashGrenadeNextUse[id] || OverrideTimer)
    {
        
give_item(id"weapon_flashbang");
        {
            
//omg
        
}
 
        
//set the time when player can use flash grenade again
        
gfFlashNextUse[id] = fTime get_cvar_float("bm_flashgrenadecooldown");
 
        
//setup hud message to show who nuked what team
        
set_hudmessage(2552550, -1.00.3506.010.01.01.0);
 
    }
    else
    {
        
set_hudmessage(gHudRedgHudGreengHudBluegfTextXgfTextYgHudEffectsgfHudFxTimegfHudHoldTimegfHudFadeInTimegfHudFadeOutTimegHudChannel);
        
show_hudmessage(id"FLASH BLOCK NEXT USE AFTER 1 ROUND"gfFlashNextUse[id] - fTime);
    }

He Grenade:


PHP Code:
actionHeGrenade(idOverrideTimer)
{
    
//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(2552550, -1.00.3506.010.01.01.0);
 
    }
    else
    {
        
set_hudmessage(gHudRedgHudGreengHudBluegfTextXgfTextYgHudEffectsgfHudFxTimegfHudHoldTimegfHudFadeInTimegfHudFadeOutTimegHudChannel);
        
show_hudmessage(id"NEXT USE AFTER 1 ROUND"gfHENextUse[id] - fTime);
    }

Money:

PHP Code:
actionMoney(idOverrideTimer)
{
    
//get game time
    
new Float:fTime halflife_time();
 
    
//make sure player is alive
    
if (fTime >= gfMoneyNextUse[id] || OverrideTimer)
    {
        
cs_set_user_money(idcs_get_user_money (id) + 5000) ;
        {
            
//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(2552550, -1.00.3506.010.01.01.0);
 
    }
    else
    {
        
set_hudmessage(gHudRedgHudGreengHudBluegfTextXgfTextYgHudEffectsgfHudFxTimegfHudHoldTimegfHudFadeInTimegfHudFadeOutTimegHudChannel);
        
show_hudmessage(id"MONEY NEXT USE AFTER 1 ROUND"gfMoneyNextUse[id] - fTime);
    }

Low Trampoline:

PHP Code:
actionLowTrampoline(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(idEV_VEC_velocityvelocity);
        
velocity[2] = 250.0;                    //jump velocity
        
entity_set_vector(idEV_VEC_velocityvelocity);
 
        
entity_set_int(idEV_INT_gaitsequence6);           //play the Jump Animation
 
        
gfTrampolineTimeout[id] = halflife_time() + 0.5;
    }

High Trampoline:

PHP Code:
actionHighTrampoline(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(idEV_VEC_velocityvelocity);
        
velocity[2] = 750.0;                    //jump velocity
        
entity_set_vector(idEV_VEC_velocityvelocity);
 
        
entity_set_int(idEV_INT_gaitsequence6);           //play the Jump Animation
 
        
gfTrampolineTimeout[id] = halflife_time() + 0.5;
    }

USP
PHP Code:
actionUsp(id)
{
    if (
is_user_alive(id) && !UspUsed[id] && get_user_team(id) == 1)
        {
        
give_item(id"weapon_usp");
        
cs_set_weapon_ammo(find_ent_by_owner(1"weapon_usp"id), 1);
        
UspUsed[id] = true;
        new 
uspname[42];
        
get_user_name(iduspname32);
        
set_hudmessage(255255255, -1.0, -1.006.04.0);
        
show_hudmessage(0"All CTs Run , %s has a USP !!!!!"uspname);
    }

If you have any other actions for other weapons, just post them and I will add them to this section. Hope this was useful for you guys!
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 07-01-2010 at 22:44.
GXLZPGX is offline