Jump to content
Sign in to follow this  
Skylar

GhostMod 1.0

Recommended Posts

Hola gente del foro ^^

 

Nombre del mod: GhostMod.

Versión del mod: 1.0.

Autor: Skylar.

Imágenes: No tengo.

 

Descripción: Al comienzo de la ronda se elige un usuario al azar(random) y es convertido en el Ghost y ese usuario elegido tendrá que matar a los policías.

El Ghost es un terrorista invisible, el título lo dice jaja.

 

Los stocks "PrecacheSound" y "PlaySound" remplazan a "precache_sound" y "client_cmd".

La función de esos stocks, es que precachea y reproduce el sonido sin importa que sea ".mp3" o ".wav".

 

Quizás pronto actualize y le agregue algunas cosas más.

 

Sonidos: http://www.mediafire.com/download/6x28rx15jmwp08n/SonidosGhostMod.rar

 

Código.

 

 

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

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

new const RegisterPlugin[][] = { "GhostMod", "1.0", "Skylar" };

new const gPrefix[] = "^4[ GHOSTMOD ]^1";

#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 gGhost[33];
new gTimeCount, gCountHud;
new gHudGhost, gHudWinTeam;
new gUserConnected, gUserAlive;
new gMaxPlayers;
new gModName[32];

enum (+=100) { TASK_COUNT = 2000, TASK_WELCOMEMSG };

const gHealthHuman = 150;
const gArmorHuman = 200;
const Float:gSpeedHuman = 270.0;
const Float:gGravHuman = 0.6;

const gHealthGhost = 500;
const Float:gSpeedGhost = 280.0;
const Float:gGravGhost = 0.4;

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

new const SoundWin[][] = { "sound/GhostMod/WinTeam/WinGhost.mp3", "sound/GhostMod/WinTeam/WinPolice.mp3" };
new const SoundAmbient[] = "sound/GhostMod/WalkingDeadTheme.mp3";
new const BlockWeapon[][] = { "weaponbox", "armoury_entity", "weapon_shield" };
const IMPULSE_FLASHLIGHT = 100;

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

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

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

public client_disconnect(id)
{
BitFalse(gUserConnected, id);
BitFalse(gUserAlive, id);
}

public plugin_precache()
{
set_lights("b");

precache_sound(SoundAmbient);
PrecacheSound(SoundWin[0]);
PrecacheSound(SoundWin[1]);

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


}

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_event("SendAudio", "event_WinGhost", "a", "2&%!MRAD_terwin");
register_event("SendAudio", "event_WinPolice", "a", "2&%!MRAD_ctwin");

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

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_Spawn, "weapon_c4", "BlockC4", true);

register_impulse(IMPULSE_FLASHLIGHT, "BloquearLinterna");

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

register_forward(FM_GetGameDescription, "fw_GetGameDescription")

formatex(gModName, sizeof gModName - 1, "GhostMod %s", RegisterPlugin[1]);

gCountHud = CreateHudSyncObj();
gHudGhost = CreateHudSyncObj();
gHudWinTeam = CreateHudSyncObj();
gMaxPlayers = get_maxplayers();

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_roundtime", 8);
}

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

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

remove_task(TASK_COUNT);
gTimeCount = 10;
set_task(1.0, "StartCount", TASK_COUNT , .flags="b");

remove_task(TASK_WELCOMEMSG);
set_task(2.0, "WelcomeMsg");
}

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

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

	set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255)
}
}

public event_WinGhost()
{
static RandomR, RandomG, RandomB;
RandomR = random_num(0, 255); RandomG = random_num(0, 255); RandomB = random_num(0, 255);

set_hudmessage(RandomR, RandomG, RandomB, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10);
ShowSyncHudMsg(0, gHudWinTeam, "Ghost aniquilo a todos los humanos.^nGhost gano la partida.");

PlaySound(SoundWin[0]);
}

public event_WinPolice()
{
static RandomR, RandomG, RandomB;
RandomR = random_num(0, 255); RandomG = random_num(0, 255); RandomB = random_num(0, 255);

set_hudmessage(RandomR, RandomG, RandomB, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10);
ShowSyncHudMsg(0, gHudWinTeam, "Ganaron los humanos.");

PlaySound(SoundWin[1]);
}

public ClcmdBlock(id) return PLUGIN_HANDLED;

public ham_PlayerSpawn(id)
{
if (IsBit(gUserConnected, id) && !IsBit(gUserAlive, id) && is_user_alive(id))
	BitTrue(gUserAlive, id);

if (IsBit(gUserAlive, id))
{
	set_task(0.4, "SetAttributes");
	set_task(0.4, "RemoveWeapons");
}
}

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

set_user_maxspeed(id, (!gGhost[id]) ? gSpeedHuman : gSpeedGhost);
set_user_gravity(id, (!gGhost[id]) ? gGravHuman : gGravGhost);
}

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

return HAM_SUPERCEDE;
}

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 BloquearLinterna(id)
{
if (gGhost[id])
	return PLUGIN_HANDLED;

return PLUGIN_CONTINUE;
}

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 fw_GetGameDescription()
{
// Return the mod name so it can be easily identified
forward_return(FMV_STRING, gModName)

return FMRES_SUPERCEDE;
}

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

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

public StartCount()
{   
static RandomR, RandomG, RandomB;
RandomR = random_num(10, 255); RandomG = random_num(0, 255); RandomB = random_num(10, 255);

emit_sound(0, CHAN_VOICE, gSoundCount[gTimeCount], 1.0, ATTN_NORM, 0, PITCH_NORM);

set_hudmessage(RandomR, RandomG, RandomB, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10);
ShowSyncHudMsg(0, gCountHud, "El modo sera lanzado en: %i.", gTimeCount);

gTimeCount--;

if (!gTimeCount)
{
	set_task(0.3, "StartGhostMod");
	remove_task(TASK_COUNT);
}
}

public StartGhostMod()
{
new gName[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);
	SetAttributes(gPlayer);
}

new gUserGhost = ChooseGhost("a");
get_user_name(gUserGhost, gName, charsmax(gName));

static RandomR, RandomG, RandomB;
RandomR = random_num(55, 255); RandomG = random_num(10, 255); RandomB = random_num(55, 255);

SetGhost(gUserGhost);
set_hudmessage(RandomR, RandomG, RandomB, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10);
ShowSyncHudMsg(0, gHudGhost, "El usuario %s se ha convertido en el ghost !", gName);

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

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

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

SetGhost(id)
{
if (!is_user_alive(id)) return;

gGhost[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);
SetAttributes(id);
}

public SetAttributes(id)
{
if (!IsBit(gUserAlive, id)) return;

if (gGhost[id])
{
	set_user_health(id, gHealthGhost);
	set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 10);
}
else
{
	set_user_health(id, gHealthHuman);
	set_user_armor(id, gArmorHuman);
	give_item(id, "weapon_m4a1");
	cs_set_user_bpammo(id, CSW_M4A1, 999);
}
}

public RemoveWeapons(id)
{
if (!IsBit(gUserAlive, id)) return;

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

public WelcomeMsg(id)
{
if (!IsBit(gUserConnected, id)) return;

ClientPrint(id, "^3--^4 Modo Ghost %s ^3--", RegisterPlugin[1]);
ClientPrint(id, "%s Creado por^4 Skylar^1.", gPrefix);
}

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

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

stock ClientPrint(const id, const input[], any:...)
{
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);

replace_all(msg, 190, "!g", "^4");
replace_all(msg, 190, "!y", "^1");
replace_all(msg, 190, "!t", "^3");

if (id) players[0] = id; else get_players(players, count, "ch");
{
	for (new i = 0; i < count; i++)
	{
		if (is_user_connected(players[i]))
		{
			message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
			write_byte(players[i]);
			write_string(msg);
			message_end();
		}
	}
}
}

stock PrecacheSound(gFile[])
{
if (equal(gFile[strlen(gFile) - 4], ".mp3"))
	precache_generic(gFile);
else
	precache_sound(gFile);
}

stock PlaySound(const gFile[])
{
if (equal(gFile[strlen(gFile) - 4], ".mp3"))
	client_cmd(0, "mp3 play ^"%s^"", gFile);
else
	client_cmd(0, "spk ^"%s^"" , gFile);
}

 

 

 

Espero que les guste :D

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...