Jump to content
Sign in to follow this  
Skylar

Mod Chainsaw [1.7]

Recommended Posts

Nombre del mod: Mod Chainsaw

Autor/Creador del mod: Skylar

Versión del mod: 1.7

Imágenes: No tengo.

 

Descripción: Al comenzar la ronda, se elegirá al azar/random un usuario que será elegido cómo el Chainsaw, la función del Chainsaw será matar a todos los humanos.

 

Créditos:

Kikizon2 = Algunos plugins suyos, y fixs.

Matians = Algunos bugs/problemas en el código.

Nazi.- = Algunas cosas de sus códigos.

Luchito = Optimizaciones.

NkkI = Bloquear linterna, y algunas otras cosas.

I'mBuggimen = Bitsum y otras cosas.

 

El changelog del mod, está dentro del archivo .sma.

 

Recursos:http://www.mediafire.com/download/2jb1941bu8ucw7q/ArchivosModChainsaw.rar

 

Archivo .sma: https://amxmodx-es.com/attachment.php?aid=3276

Include: https://amxmodx-es.com/attachment.php?aid=3188

 

Bug, error, log, comenten, lo arreglaré enseguida.

 

No sé subír archivos adjuntos, así que dejo el código en php y también dejo el .sma para descargar.

 

Gracias :D

 

/* ==============================================================================================

			[ Mod Chainsaw ]

			Changelog

			 1.0 - Creación del modo.

			 1.1 - 
			       Agregado conteo
			       Model al humano y al chainsaw. 

			 1.2 - Corregido algunos bugs.

			 1.3 - 
			       Corregido algunos bugs.
			       Agregado model y sound al knife chainsaw.
			       Agregado menú de armas.
			       Agregado model al knife humano.

			 1.4 -
			       Corregido algunos bugs.
			       Bloqueado chooseteam.

			 1.5 -
			       Corregido mas bugs.
			       Bloqueado c4.
			       Algunas optimizaciones.

			 1.6 -
			       Agregado bitsum.
			       Bloqueada linterna para el chainsaw.

			 1.7 -
			       Corregido bugs.

============================================================================================== */

// Includes
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

// Register Plugin
new const RegisterPlugin[][] = { "Mod Chainsaw", "1.7", "Skylar" };

// Prefix
new const sPrefix[] = "^3[ M. Chainsaw ]^1";

// Defines
#define TIEMPO 40.0

// Bitsum
#define BitTrue(%1,%2) ( %1 |= ( 1 << ( %2 & 31 ) ) ) 
#define IsBit(%1,%2) ( %1 & ( 1 << ( %2 & 31 ) ) ) 
#define BitFalse(%1,%2) ( %1 &= ~ ( 1 << ( %2 & 31 ) ) ) 

/* =================================================================================

================================================================================= */

new gChainsaw[33];
new gTiempoConteo, gConteoHud;
new gVarHud, iMaxP;
new gUsuarioConectado, gUsuarioVivo;

enum (+=100) { TASK_CONTEO = 2000 };
enum _:ARMAS
{
NOMBRE[90],
ARMA[90],
CSW,
BPAMMO
}

const gVidaHumano = 200;
const gArmorHumano = 200;
const Float:gSpeedHumano = 260.0;
const Float:gGravHumano = 0.5;
new const ModelHumano[] = "Player_Humano";
new const ModelKnifeHumano[] = "models/ModChainsaw/vKnifeHumano.mdl";

const gVidaChainsaw = 5000;
const Float:gSpeedChainsaw = 270.0;
const Float:gGravChainsaw = 0.3;
new const ModelChainsaw[] = "Player_Chainsaw";
new const ModelKnifeChainsaw[] = "models/ModChainsaw/vKnifeChainsaw.mdl";

new const gSonidosConteo[][] = 
{ 
0,
"ModChainsaw/Conteo/one.wav",
"ModChainsaw/Conteo/two.wav",
"ModChainsaw/Conteo/three.wav",
"ModChainsaw/Conteo/four.wav",
"ModChainsaw/Conteo/five.wav",
"ModChainsaw/Conteo/six.wav",
"ModChainsaw/Conteo/seven.wav",
"ModChainsaw/Conteo/eight.wav",
"ModChainsaw/Conteo/nine.wav",
"ModChainsaw/Conteo/ten.wav"
};

new const gChainsawSounds[][] = 
{ 
"ModChainsaw/Knife/chainsaw2_miss.wav", 
"ModChainsaw/Knife/chainsaw1_miss.wav", 
"ModChainsaw/Knife/chainsaw2_miss.wav", 
"ModChainsaw/Knife/chainsaw1_hit.wav", 
"ModChainsaw/Knife/chainsaw2_hit.wav", 
"ModChainsaw/Knife/chainsaw1_hit.wav", 
"ModChainsaw/Knife/chainsaw1_miss.wav", 
"ModChainsaw/Knife/chainsaw2_miss.wav", 
"ModChainsaw/Knife/chainsaw1_hit.wav" 
};

new const gKnifeSounds[][] = 
{ 
"weapons/knife_deploy1.wav", 
"weapons/knife_hit1.wav", 
"weapons/knife_hit2.wav", 
"weapons/knife_hit3.wav", 
"weapons/knife_hit4.wav", 
"weapons/knife_hitwall1.wav", 
"weapons/knife_slash1.wav", 
"weapons/knife_slash2.wav", 
"weapons/knife_stab.wav" 
};

new const SoundAmbient[] = "sound/ModChainsaw/Ambient.mp3";

new const BlockWeapon[][] = { "weaponbox", "armoury_entity", "weapon_shield" };

new const PRIMARIAS[][ARMAS] =
{
{ "Ingram MAC-10", "weapon_mac10", CSW_MAC10, 999 },
{ "Schmidt TMP", "weapon_tmp", CSW_TMP, 999 },
{ "UMP 45", "weapon_ump45", CSW_UMP45, 999 },
{ "MP5 Navy", "weapon_mp5navy", CSW_MP5NAVY, 999 },
{ "ES P90", "weapon_p90", CSW_P90, 999 },
{ "IMI Galil", "weapon_galil", CSW_GALIL, 999 },
{ "Famas", "weapon_famas", CSW_FAMAS, 999 },
{ "SG-552 Commando", "weapon_sg552", CSW_SG552, 999 },
{ "M4A1 Carbine", "weapon_m4a1", CSW_M4A1, 999 },
{ "AK-47 Kalashnikov", "weapon_ak47", CSW_AK47, 999 }
};
new const SECUNDARIAS[][ARMAS] =
{
{ "USP .45 ACP Tactical", "weapon_usp", CSW_USP, 999 },
{ "Glock 18C", "weapon_glock18", CSW_GLOCK18, 999 },
{ "P228 Compact", "weapon_p228", CSW_P228, 999 },
{ "FiveseveN", "weapon_fiveseven", CSW_FIVESEVEN, 999 },
{ "Desert Eagle .50 AE", "weapon_deagle", CSW_DEAGLE, 999 },
{ "Dual Elite Berettas", "weapon_elite", CSW_ELITE, 999 }
};

new const MensajesMod[][] =
{
"%s Mod creado por^4 Skylar^1.",
"%s Puedes encontrar el mod en^4 amxmodx-es.com^1.",
"%s Nombre:^4 Chainsaw Mod ^3||^1 Version:^4 1.7^1."
};

const PEV_SPEC_TARGET = pev_iuser2;
const IMPULSE_FLASHLIGHT = 100;

/* =================================================================================

================================================================================= */

public client_putinserver(id) BitTrue(gUsuarioConectado, id);

public client_disconnect(id)
{
BitFalse(gUsuarioConectado, id);
BitFalse(gUsuarioVivo, id);
}

public plugin_precache()
{
static i;

set_lights("b");

static gPrecache[64];

formatex(gPrecache, charsmax(gPrecache), "models/player/%s/%s.mdl", ModelHumano, ModelHumano);
precache_model(gPrecache);

formatex(gPrecache, charsmax(gPrecache), "models/player/%s/%s.mdl", ModelChainsaw, ModelChainsaw);
precache_model(gPrecache);

precache_model(ModelKnifeHumano);
precache_model(ModelKnifeChainsaw);

for(i = 0; i < sizeof gSonidosConteo; i++)
	engfunc(EngFunc_PrecacheSound, gSonidosConteo[i]);

for(i = 0; i < sizeof gChainsawSounds; i++) 
	precache_sound(gChainsawSounds[i]);

precache_sound(SoundAmbient);
}

public plugin_init()
{
register_plugin(RegisterPlugin[0], RegisterPlugin[1], RegisterPlugin[2]);

register_event("HLTV", "event_RoundStart", "a", "1=0", "2=0" );
register_logevent("event_RoundEnd", 2, "1=Round_End");

register_clcmd("drop", "ClcmdBlock");
register_clcmd("kill", "ClcmdBlock");
register_clcmd("chooseteam", "ClcmdBlockJoin");

RegisterHam(Ham_Spawn, "player", "ham_PlayerSpawn");
RegisterHam(Ham_Item_PreFrame, "player", "ham_Item_Preframe");
for(new i = 0; i < sizeof BlockWeapon; ++i)
	RegisterHam(Ham_Touch, BlockWeapon[i], "ham_TouchWeapon");
RegisterHam(Ham_Item_Deploy, "weapon_knife", "ham_Item_Deploy_Post", 1)
RegisterHam(Ham_Spawn, "weapon_c4", "BlockC4", true);

register_forward(FM_EmitSound, "fw_EmitSound");

register_message(get_user_msgid("StatusIcon"), "message_statusicon");

register_impulse(IMPULSE_FLASHLIGHT, "BloquearLinterna")

gConteoHud = CreateHudSyncObj();
gVarHud = CreateHudSyncObj();
iMaxP = get_maxplayers();

set_task(TIEMPO, "MensajesRandom", .flags = "b");
set_task(1.0, "plugin_cfg");
}

public plugin_cfg()
{
set_cvar_num("mp_autoteambalance", 0);
set_cvar_num("mp_freezetime", 0);
set_cvar_num("mp_flashlight", 1);
set_cvar_num("mp_roundtime", 8);
}

public event_RoundStart()
{
new gPlayers[32], gNum, gPlayer;
get_players(gPlayers, gNum);

for(new i = 0; i < gNum; i++)
{
	gPlayer = gPlayers[i];
	gChainsaw[gPlayer] = false;
}

remove_task(TASK_CONTEO);
gTiempoConteo = 10;
set_task(1.0, "IniciarConteo", TASK_CONTEO , .flags="b");
}

public event_RoundEnd()
{
client_cmd(0, "mp3 stop");

for(new id = 1 ; id <= iMaxP ; id++)
{
	if (!IsBit(gUsuarioConectado, id)) continue;

	set_user_rendering(id);
	cs_reset_user_model(id);
}
}

public ham_PlayerSpawn(id)
{
if (IsBit(gUsuarioConectado, id) && !IsBit(gUsuarioVivo, id) && is_user_alive(id))
	BitTrue(gUsuarioVivo, id);

if (IsBit(gUsuarioVivo, id))
{
	set_task(0.4, "DarAtrib");
}
}

public ham_Item_Preframe(id)
{
if (!IsBit(gUsuarioVivo, id)) return;

set_user_gravity(id, (!gChainsaw[id]) ? gGravHumano : gGravChainsaw);
set_user_maxspeed(id, (!gChainsaw[id]) ? gSpeedHumano : gSpeedChainsaw);
}

public ham_TouchWeapon(wpn, id)
{
if (!IsBit(gUsuarioConectado, id))
	return HAM_IGNORED;

return HAM_SUPERCEDE;
}

public ham_Item_Deploy_Post(wpn)
{
static id; id = get_weapon_ent_owner(wpn);

if (!pev_valid(id) || !IsBit(gUsuarioVivo, id)) return;

static WeaponID; WeaponID = cs_get_weapon_id(wpn);

if (WeaponID != CSW_KNIFE) return;

set_pev(id, pev_viewmodel2, (gChainsaw[id]) ? ModelKnifeChainsaw : ModelKnifeHumano);
}

public BlockC4(ent)
{
static const OBJETIVOS[][] =
{
	"func_bomb_target", "info_bomb_target", "info_vip_start", 
	"func_vip_safetyzone", "func_escapezone", "hostage_entity",
	"monster_scientist", "func_hostage_rescue", "info_hostage_rescue", 
	"env_fog", "env_rain", "env_snow", "item_longjump", "func_vehicle", "weapon_c4"
};

if (!is_valid_ent(ent)) return;

static classname[32], i;
entity_get_string(ent, EV_SZ_classname, classname, charsmax(classname));

for (i = 0; i < sizeof(OBJETIVOS); i++)
{
	if (equal(OBJETIVOS[i], classname))
	{
		remove_entity(ent);
		return;
	}
}
}

public fw_EmitSound(id, channel, const sound[])
{
if (!IsBit(gUsuarioVivo, id) || !gChainsaw[id]) return FMRES_IGNORED;

for(new i = 0; i < sizeof gChainsawSounds; i++)
{
	if (equal(sound, gKnifeSounds[i])) 
	{
		emit_sound(id, channel, gChainsawSounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
		return FMRES_SUPERCEDE;
	}
}

return FMRES_IGNORED;
}

public message_statusicon(msg_id, msg_dest, id)
{
static szIcon[8];
get_msg_arg_string(2, szIcon, charsmax(szIcon));

if (equal(szIcon, "buyzone") && get_msg_arg_int(1))
{
	set_pdata_int(id, 235, get_pdata_int(id, 235) & ~(1<<0));
	return PLUGIN_HANDLED;
}

return PLUGIN_CONTINUE;
} 

public BloquearLinterna(id)
{
if (gChainsaw[id])
	return PLUGIN_HANDLED;

return PLUGIN_CONTINUE;
}

/* =================================================================================

================================================================================= */

public ClcmdBlock(id) return PLUGIN_HANDLED;

public DarAtrib(id)
{
if (!IsBit(gUsuarioVivo, id)) return;

strip_user_weapons(id);
give_item(id, "weapon_knife");

if (gChainsaw[id])
{
	set_user_health(id, gVidaChainsaw);
	cs_set_user_model(id, ModelChainsaw);
	set_user_rendering(id, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 20);
}
else
{
	set_user_health(id, gVidaHumano);
	set_user_armor(id, gArmorHumano);
	cs_set_user_model(id, ModelHumano);
}
}

public IniciarConteo()
{   
emit_sound(0, CHAN_VOICE, gSonidosConteo[gTiempoConteo], 1.0, ATTN_NORM, 0, PITCH_NORM);

set_hudmessage(0, 255, 0, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10);
ShowSyncHudMsg(0, gConteoHud, "------ [ MODO EN %i ] ------", gTiempoConteo);

gTiempoConteo--;

if (!gTiempoConteo)
{
	ModoChainsaw();
	remove_task(TASK_CONTEO);
}
}

public ModoChainsaw()
{
new gCName[32];

new gPlayers[32], gNum, gPlayer;
get_players(gPlayers, gNum, "a");

for(new i = 0; i < gNum; i++)
{
	gPlayer = gPlayers[i];
	cs_set_user_team(gPlayer, CS_TEAM_CT);
	DarAtrib(gPlayer);
}

new gMChainsaw = ElegirChainsaw("a");
get_user_name(gMChainsaw, gCName, charsmax(gCName));

DarChainsaw(gMChainsaw);
set_hudmessage(255, 0, 0, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10);
ShowSyncHudMsg(0, gVarHud, "EL CHAINSAW ES %s.", gCName);

client_cmd(0, "mp3 play ^"%s^"", SoundAmbient);

for(new id = 1 ; id <= iMaxP ; id++)
{
	if (!IsBit(gUsuarioConectado, id) || gChainsaw[id]) continue;
	if (cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED) 
		continue;

	set_task(0.5, "MenuArmas", id);
}
}

ElegirChainsaw(const Flags[]="", const Team[]="")
{
static gPlayers[32], gNum;
get_players(gPlayers, gNum, Flags, Team);

return (gNum > 0) ? gPlayers[random(gNum)] : 0;
}

DarChainsaw(id)
{
if (!IsBit(gUsuarioVivo, id)) return;

gChainsaw[id] = true;

cs_set_user_team(id, CS_TEAM_T);
strip_user_weapons(id);
give_item(id, "weapon_knife");

cs_set_user_nvg(id, 1);

DarAtrib(id);
}

public MenuArmas(id)
{
if (!IsBit(gUsuarioVivo, id)) return;

new i, menu, text[100], temp[16];
menu = menu_create("\r[\dM. Chainsaw\r]\w Menu de Armas \r(\dPrimarias\r)", "HandPriMenuArmas");

for(i = 0; i < sizeof PRIMARIAS; i++)
{
	formatex(text, charsmax(text), "\w%s", PRIMARIAS[i][NOMBRE]);
	num_to_str(i, temp, 2);
	menu_additem(menu, text, temp);
}
menu_setprop(menu, MPROP_EXITNAME, "Salir");
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu);
}
public HandPriMenuArmas(id, menu, item)
{
if(item == MENU_EXIT)
{
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

strip_user_weapons(id);
give_item(id, "weapon_knife");
give_item(id, PRIMARIAS[item][ARMA]);
cs_set_user_bpammo(id, PRIMARIAS[item][CSW], PRIMARIAS[item][bPAMMO]);
ColorChat(id, NORMAL, "%s Elegiste la arma primaria:^4 %s^1.", sPrefix, PRIMARIAS[item][NOMBRE]);
ArmasSec(id);

return PLUGIN_HANDLED;
}

public ArmasSec(id)
{
if (!IsBit(gUsuarioVivo, id)) return;

new i, menu, text[100], temp[16];
menu = menu_create("\r[\dM. Chainsaw\r]\w Menu de Armas \r(\dSecundarias\r)", "HandSecundarias");

for(i = 0; i < sizeof SECUNDARIAS; i++)
{
	formatex(text, charsmax(text), "\w%s", SECUNDARIAS[i][NOMBRE]);
	num_to_str(i, temp, 2);
	menu_additem(menu, text, temp);
}
menu_setprop(menu, MPROP_EXITNAME, "Salir");
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu);
}

public HandSecundarias(id, menu, item)
{
if(item == MENU_EXIT)
{
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

give_item(id, SECUNDARIAS[item][ARMA]) 
cs_set_user_bpammo(id, SECUNDARIAS[item][CSW], SECUNDARIAS[item][bPAMMO]);
ColorChat(id, NORMAL, "%s Elegiste la arma secundaria:^4 %s^1.", sPrefix, SECUNDARIAS[item][NOMBRE]);

return PLUGIN_HANDLED;
}

public MensajesRandom() ColorChat(0, NORMAL, MensajesMod[random(sizeof MensajesMod-1)], sPrefix);

public ClcmdBlockJoin() return PLUGIN_HANDLED;

/* =================================================================================

================================================================================= */

stock get_weapon_ent_owner(ent)
{
if (pev_valid(ent) != 2)
	return -1;

return get_pdata_cbase(ent, 41, 4);
}

Edited by Skylar

Share this post


Link to post
Share on other sites

Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...