#include < amxmodx >
#include < engine >
#define ID_PISS ( taskid - TASK_PISS )
new Float:g_EST_PillarDone[ 33 ];
new Float:g_EST_CagarDone[ 33 ];
new TASK_PISS;
new const SOUND_PISS[ ] = "piss.wav";
new const SOUND_MIERDA[ ][ ] = { "cagar.wav", "cagar2.wav" };
new const MODELO_MIERDA[ ] = "cagar.mdl";
public plugin_init()
{
register_plugin( "asd", "asd", "asd" );
register_clcmd( "/mear", "clcmd_Mear" );
register_clcmd( "/cagar", "clcmd_Cagar" );
}
public plugin_precache( )
{
precache_sound( SOUND_PISS );
for( new iEnt = 0; iEnt < sizeof( SOUND_MIERDA ); ++iEnt )
precache_sound( SOUND_MIERDA[ iEnt ] );
precache_model( MODELO_MIERDA );
}
public client_disconnected( id )
{
if( task_exists( TASK_PISS ) )
remove_task( id + TASK_PISS );
}
public clcmd_Mear(const id)
{
if(!(get_user_flags(id) & ADMIN_RESERVATION ) )
{
client_print_color( id, get_user_team( id ), "^4[MEAR]^1 Para poder mear tenes que ser ^4ADMIN/PREMIUM^1." );
return PLUGIN_HANDLED;
}
if(!is_user_alive(id))
return PLUGIN_HANDLED;
if( g_EST_PillarDone[id] > get_gametime( ) )
{
client_print_color( id, get_user_team( id ), "^4[MEAR]^1 Podés mear cada dos minutos." );
return PLUGIN_HANDLED;
}
emit_sound( id, CHAN_VOICE, SOUND_PISS, 1.0, ATTN_NORM, 0, PITCH_NORM );
set_task( 0.1, "makePiss", TASK_PISS + id, _, _,"a", 100 );
return PLUGIN_HANDLED;
}
public makePiss(const taskid)
{
if( !( is_user_alive( taskid ) ) )
return;
new vecOrigin[3];
new vecAim[3];
new vecVelocity[3];
new iLenght;
new iDistance;
new iSpeed;
get_user_origin(ID_PISS, vecOrigin);
get_user_origin(ID_PISS, vecAim, 3);
iDistance = get_distance(vecOrigin, vecAim);
iSpeed = floatround(iDistance * 1.9);
vecVelocity[0] = vecAim[0] - vecOrigin[0];
vecVelocity[1] = vecAim[1] - vecOrigin[1];
vecVelocity[2] = vecAim[2] - vecOrigin[2];
iLenght = squareRoot((vecVelocity[0] * vecVelocity[0]) + (vecVelocity[1] * vecVelocity[1]) + (vecVelocity[2] * vecVelocity[2]));
if(iLenght != 0) {
vecVelocity[0] = (vecVelocity[0] * iSpeed) / iLenght;
vecVelocity[1] = (vecVelocity[1] * iSpeed) / iLenght;
vecVelocity[2] = (vecVelocity[2] * iSpeed) / iLenght;
} else {
vecVelocity[0] = vecVelocity[0] * iSpeed;
vecVelocity[1] = vecVelocity[1] * iSpeed;
vecVelocity[2] = vecVelocity[2] * iSpeed;
}
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BLOODSTREAM);
write_coord(vecOrigin[0]);
write_coord(vecOrigin[1]);
write_coord(vecOrigin[2]);
write_coord(vecVelocity[0]);
write_coord(vecVelocity[1]);
write_coord(vecVelocity[2]);
write_byte(102);
write_byte(random_num(200, 250));
message_end();
}
public clcmd_Cagar(const id)
{
if(!(get_user_flags(id) & ADMIN_RESERVATION))
{
client_print_color( id, get_user_team( id ), "^4[CAGAR]^1 Para poder cagar tenes que ser ^4ADMIN/PREMIUM^1." );
return PLUGIN_HANDLED;
}
if(!is_user_alive(id)) return PLUGIN_HANDLED;
if(g_EST_CagarDone[id] > get_gametime())
{
client_print_color( id, get_user_team( id ), "^4[CAGAR]^1 Podés cagar cada dos minutos." );
return PLUGIN_HANDLED;
}
new Float:vecOrigin[3];
entity_get_vector(id, EV_VEC_origin, vecOrigin);
new iEnt;
iEnt = create_entity("info_target");
if( is_valid_ent( iEnt ) )
{
entity_set_string( iEnt, EV_SZ_classname, "entMierda" );
entity_set_model( iEnt, MODELO_MIERDA );
entity_set_int( iEnt, EV_INT_movetype, MOVETYPE_TOSS );
entity_set_origin( iEnt, vecOrigin );
emit_sound( iEnt, CHAN_BODY, SOUND_MIERDA[ random_num( 0, 1 ) ], 1.0, ATTN_NORM, 0, PITCH_NORM );
}
return PLUGIN_HANDLED;
}
public squareRoot(const num)
{
new iDiv = num;
new iResult = 1;
while(iDiv > iResult)
{
iDiv = (iDiv + iResult) / 2;
iResult = num / iDiv;
}
return iDiv;
}