Well, I've been modifying this plugin on and off for the past day or two, and I implemented ColorChat but it seems for some reason, when I do this, the compiler doesn't pick up my Ham Registries.
Here's the code, line 1 to the end.
PHP Code:
/* Grenade Slaps @ wrecked
Personal Hungarian Notation:
pl_ = Player Index
pCvar_ = PCvar...
reg_ = Engine registry
hfw_ = Ham Forward
e_ = Entity
Credits:
Exolent[jNr] - Help with the unit conversion and the idea
r4nd0mz - Original and simple idea
Changelog:
v0.1.0 - Plugin start + Dumb user_slap command
v0.1.1 - Distance calculator + ColorChat
*/
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>
#include <fun>
enum Color
{
NORMAL = 1,
GREEN,
TEAM_COLOR,
GREY,
RED,
BLUE,
}
new const VERSION[] = "0.0.1"
// Pcvars
new pCvar_SlapDmg
new pCvar_Prefix
// Origins
new Float:f_ThrowOrigin[ 3 ]
new Float:f_HitOrigin[ 3 ]
new Float:f_SlapVelocity[ 3 ]
// Player names
new sz_ThrowerName[ 64 ]
new pl_Owner
new ownerTeam
public plugin_init()
{
register_plugin("Grenade Slap", VERSION, "wrecked") // <--- This guy's cool
pCvar_SlapDmg = register_cvar( "gs_damage", "25" )
pCvar_Prefix = register_cvar( "gs_prefix", "[NADE]" )
register_touch( "grenade", "player", "reg_NadeTouch" ) // When it hits the reciever
RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_hegrenade", "hfw_NadeThrow", 1 ) // If the user throws a nade, we get the origin of it in the function
RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_flashbang", "hfw_NadeThrow", 1 )
RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_smokegrenade", "hfw_NadeThrow", 1 )
}
public reg_NadeTouch( e_NadeHit, pl_Receiver )
{
new hitTeam = cs_get_user_team( pl_Receiver )
if( ownerTeam == hitTeam )
{
return;
}
else
{
pev( e_NadeHit, pev_origin, f_HitOrigin ) // Get the origin of the nade as it hits the reciever, pl_Player
new iHealth = get_user_health( pl_Receiver )
new sz_ReceiverName[ 64 ]
get_user_name( pl_Receiver, sz_ReceiverName, charsmax( sz_ReceiverName ) )
new Float:f_NadeDistance = get_distance_f( f_ThrowOrigin, f_HitOrigin ) // Get the distance
f_SlapVelocity[0] = f_NadeDistance * ( random_num(0,1) ? 1.0 : -1.0 ) // Set velocity of the slap based on the distance
f_SlapVelocity[1] = f_NadeDistance * ( random_num(0,1) ? 1.0 : -1.0 )
f_SlapVelocity[2] = f_NadeDistance * ( random_num(0,1) ? 1.0 : -1.0 )
set_user_health( pl_Receiver, iHealth - get_pcvar_num( pCvar_SlapDmg ) ) // Slap damage
set_pev( pl_Receiver, pev_velocity, f_SlapVelocity ) // Blast off!
if( f_NadeDistance > 499.9 )
{
ColorChat( 0, RED, "%s Wow! %s just hit %s with a nade from %f units away!", pCvar_Prefix, sz_ThrowerName, sz_ReceiverName, f_NadeDistance )
}
}
public hfw_NadeThrow( e_NadeThrown )
{
pev( e_NadeThrown, pev_origin, f_ThrowOrigin ) // Get the origin of the nade right as it is thrown
pev( e_NadeThrown, pev_owner, pl_Owner ) // Get ID of player who throws the nade
ownerTeam = cs_get_user_team( pl_Owner ) // His team
get_user_name( pl_Owner, sz_ThrowerName, charsmax( sz_ThrowerName ) ) // His name
}
stock ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
{
new message[256];
switch(type)
{
case NORMAL: // clients scr_concolor cvar color
{
message[0] = 0x01;
}
case GREEN: // Green
{
message[0] = 0x04;
}
default: // White, Red, Blue
{
message[0] = 0x03;
}
}
vformat(message[1], 251, msg, 4);
// Make sure message is not longer than 192 character. Will crash the server.
message[192] = '^0';
new team, ColorChange, index, MSG_Type;
if(id)
{
MSG_Type = MSG_ONE;
index = id;
} else {
index = FindPlayer();
MSG_Type = MSG_ALL;
}
team = get_user_team(index);
ColorChange = ColorSelection(index, MSG_Type, type);
ShowColorMessage(index, MSG_Type, message);
if(ColorChange)
{
Team_Info(index, MSG_Type, TeamName[team]);
}
}
and here are the errors that I get when trying to compile:
Code:
/home/groups/amxmodx/tmp3/phpe35uKY.sma(73) : warning 213: tag mismatch
/home/groups/amxmodx/tmp3/phpe35uKY.sma(98) : error 017: undefined symbol "ColorChat"
/home/groups/amxmodx/tmp3/phpe35uKY.sma(102) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpe35uKY.sma(102) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpe35uKY.sma(102) : error 017: undefined symbol "hfw_NadeThrow"
/home/groups/amxmodx/tmp3/phpe35uKY.sma(104) : error 017: undefined symbol "e_NadeThrown"
/home/groups/amxmodx/tmp3/phpe35uKY.sma(104) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpe35uKY.sma(104) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpe35uKY.sma(104) : error 001: expected token: ";", but found ")"
/home/groups/amxmodx/tmp3/phpe35uKY.sma(104) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpe35uKY.sma(104) : fatal error 107: too many error messages on one line
Compilation aborted.
I seem to recall my friend saying that the compiler doesn't have colorchat included, but I figured it wouldn't have any effect on the stock. Could it be that? If it is, why would the compiler completely disregard my HamRegistries just because it doesn't like the stock?
PS : It compiled perfectly fine before I added the colorchat.
7 Errors.
__________________