[code=php]#include < amxmodx >
#include < cstrike >
#include < hamsandwich >
#include < fakemeta >
#include < engine >
#include < fun >
#include < cellarray >
#include < xs >
#pragma semicolon 1
#define PLUGIN "FMU Gifts"
#define VERSION "0.3.2b"
/* --| ColorChat |-- */
enum Color
{
NORMAL = 1, // Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
GREEN, // Culoare Verde.
TEAM_COLOR, // Culoare Rosu, Albastru, Gri.
GREY, // Culoarea Gri.
RED, // Culoarea Rosu.
BLUE, // Culoarea Albastru.
};
new TeamName[ ][ ] =
{
"",
"TERRORIST",
"CT",
"SPECTATOR"
};
/* --| ColorChat |-- */
/* Extras din Super Spawns */
#define SS_VERSION "1.0"
#define SS_MIN_DISTANCE 250.0
#define SS_MAX_LOOPS 100000
new Array:g_vecSsOrigins;
new Array:g_vecSsSpawns;
new Array:g_vecSsUsed;
new Float:g_flSsMinDist;
new g_iSsTime;
new const g_szStarts[][] =
{
"info_player_start",
"info_player_deathmatch"
};
new const Float:g_flOffsets[] =
{
3500.0,
3500.0,
1500.0
};
enum
{
GIFT_HP,
GIFT_AP,
GIFT_HP_AP,
GIFT_MONEY,
GIFT_GRAVITY,
GIFT_SPEED,
GIFT_HE
}
new const g_szFmuGiftsModels[ 7 ][ ] =
{
"models/fmu_gift_cyan.mdl",
"models/fmu_gift_green.mdl",
"models/fmu_gift_orange.mdl",
"models/fmu_gift_pink.mdl",
"models/fmu_gift_red.mdl",
"models/fmu_gift_yellow.mdl",
"models/fmu_gift_random.mdl"
};
new const g_iFmuGiftsColors[ 7 ][ 3 ] =
{
{ 0, 255, 255 },
{ 0, 255, 125 },
{ 255, 125, 65 },
{ 255, 0, 125 },
{ 255, 25, 25 },
{ 255, 255, 0 },
{ 255, 255, 255 }
};
new const g_szFmuGiftClassName[ ] = "fmu_gift";
new const FMU_TAG[ ] = "[Furien Gifts]";
// Floats
new Float:fMaxs[ 3 ] = { 13.0, 13.0, 35.0 };
new Float:fMins[ 3 ] = { -13.0, -13.0, 0.0 };
new gCvarGiftHP;
new gCvarGiftAP;
new gCvarGiftMoney;
new gCvarEnableRespawn;
new gCvarRespawnTime;
new gCvarGiftsNum;
public plugin_precache( )
{
for( new i = 0; i < 7; i++ )
{
precache_model( g_szFmuGiftsModels[ i ] );
}
}
public plugin_init( )
{
//Autor original al plugin-ului: KronoS .
//Am pornit acest plugin pe baza plugin`ului facut de el.
register_plugin( PLUGIN, VERSION, "Askhanar" );
gCvarGiftHP = register_cvar( "fmu_gifts_hp", "25" );
gCvarGiftAP = register_cvar( "fmu_gifts_ap", "25" );
gCvarGiftMoney = register_cvar( "fmu_gifts_money", "1500" );
gCvarEnableRespawn = register_cvar( "fmu_enable_giftsrespawn", "1" );
gCvarRespawnTime = register_cvar( "fmu_gifts_respawntime", "45" );
gCvarGiftsNum = register_cvar( "fmu_gifts_num", "35" );
register_clcmd( "amx_reloadgifts", "ClCmdReloadGifts" );
register_touch( g_szFmuGiftClassName, "player", "FwdPlayerTouchGift" );
SsInit(800.0);
SsScan();
LoadAllGifts( );
}
public ClCmdReloadGifts( id )
{
if( !( get_user_flags( id ) & ADMIN_CFG ) )
return 1;
SsClean();
SsInit(800.0);
SsScan();
new iFoundEntity;
while ( ( iFoundEntity = find_ent_by_class( iFoundEntity, g_szFmuGiftClassName ) ) != 0 )
{
engfunc( EngFunc_RemoveEntity, iFoundEntity );
}
LoadAllGifts( );
new szName[ 32 ];
get_user_name( id, szName, sizeof ( szName ) -1 );
ColorChat( 0, RED, "^x04%s^x01 Adminul^x03 %s^x01 a reincarcat toate cadourile de pe harta!", FMU_TAG, szName );
return 1;
}
public FwdPlayerTouchGift( const iEnt, const id )
{
if( is_valid_ent( iEnt ) && ( 1 <= id <= 32 ) && is_user_alive( id ) )
{
if( get_pcvar_num( gCvarEnableRespawn ) )
{
new iParm[ 3 ];
new Float:flOrigin[ 3 ], iOrigin[ 3 ];
entity_get_vector( iEnt, EV_VEC_origin, flOrigin );
FVecIVec( flOrigin, iOrigin );
iParm[ 0 ] = iOrigin[ 0 ];
iParm[ 1 ] = iOrigin[ 1 ];
iParm[ 2 ] = iOrigin[ 2 ];
set_task( float( get_pcvar_num( gCvarRespawnTime ) ), "Respawn_Entity", _, iParm, 3 );
}
new iRandomGift = random_num( GIFT_HP, GIFT_HE );
while( iRandomGift == GIFT_HE && user_has_weapon( id, CSW_HEGRENADE ) )
iRandomGift = random_num( GIFT_HP, GIFT_HE );
GivePlayerGift( id, iRandomGift );
remove_entity( iEnt );
}
return 0;
}
public GivePlayerGift( id, const iGiftType )
{
switch( iGiftType )
{
case GIFT_HP:
{
set_user_health( id, get_user_health( id ) + get_pcvar_num( gCvarGiftHP ) );
ColorChat( id, RED, "^x04%s^x01 Mosul ti-a oferit cadou^x03 %i HP^x01!", FMU_TAG, get_pcvar_num( gCvarGiftHP ) );
}
case GIFT_AP:
{
set_user_armor( id, get_user_armor( id ) + get_pcvar_num( gCvarGiftAP ) );
ColorChat( id, RED, "^x04%s^x01 Mosul ti-a oferit cadou^x03 %i AP^x01!", FMU_TAG, get_pcvar_num( gCvarGiftAP ) );
}
case GIFT_HP_AP:
{
static iHP;
iHP = get_pcvar_num( gCvarGiftHP );
static iAP;
iAP = get_pcvar_num( gCvarGiftAP );
set_user_health( id, get_user_health( id ) + iHP );
set_user_armor( id, get_user_armor( id ) + iAP );
ColorChat( id, RED, "^x04%s^x01 Mosul ti-a oferit cadou^x03 %i HP^x01 si^x03 %i AP^x01!", FMU_TAG, iHP, iAP );
}
case GIFT_MONEY:
{
cs_set_user_money( id, clamp( cs_get_user_money( id ) + get_pcvar_num( gCvarGiftMoney ), 0, 16000 ) );
ColorChat( id, RED, "^x04%s^x01 Mosul ti-a oferit cadou^x03 %i$^x01!", FMU_TAG, get_pcvar_num( gCvarGiftMoney ) );
}
case GIFT_GRAVITY:
{
set_user_gravity(id, 0.5);
ColorChat( id, RED, "^x04%s^x01 Mosul ti-a oferit cadou^x03 GRAVITATIE^x01!", FMU_TAG );
}
case GIFT_SPEED:
{
set_user_maxspeed(id, 500.0);
ColorChat( id, RED, "^x04%s^x01 Mosul ti-a oferit cadou^x03 SPEED^x01!", FMU_TAG );
}
case GIFT_HE:
{
give_item( id, "weapon_hegrenade" );
ColorChat( id, RED, "^x04%s^x01 Mosul ti-a oferit cadou un^x03 HE^x01!", FMU_TAG );
}
}
}
public Respawn_Entity( iParm[ ] )
{
new Float:flOrigin[ 3 ], iOrigin[ 3 ];
iOrigin[ 0 ] = iParm[ 0 ];
iOrigin[ 1 ] = iParm[ 1 ];
iOrigin[ 2 ] = iParm[ 2 ];
IVecFVec( iOrigin, flOrigin );
CreateGift( flOrigin );
return 0;
}
public CreateGift( const Float:fOrigin[ 3 ] )
{
new iEnt = create_entity( "info_target" );
if ( !is_valid_ent(iEnt) ) return 0;
new iRandom = random_num( 0, 6 );
entity_set_string( iEnt, EV_SZ_classname, g_szFmuGiftClassName );
entity_set_origin( iEnt, fOrigin );
entity_set_model( iEnt, g_szFmuGiftsModels[ iRandom ] );
entity_set_int( iEnt, EV_INT_movetype, MOVETYPE_NONE );
entity_set_int( iEnt, EV_INT_solid, SOLID_BBOX );
entity_set_size( iEnt, fMins, fMaxs );
set_rendering( iEnt,
kRenderFxGlowShell,
g_iFmuGiftsColors[ iRandom ][ 0 ],
g_iFmuGiftsColors[ iRandom ][ 1 ],
g_iFmuGiftsColors[ iRandom ][ 2 ],
kRenderNormal,
255 );
drop_to_floor( iEnt );
return 1;
}
public LoadAllGifts( )
{
new Float:fOrigin[ 3 ];
for( new i = 1; i <= get_pcvar_num( gCvarGiftsNum ); i++ )
if( SsGetOrigin( fOrigin ) )
CreateGift( fOrigin );
}
/*====================================
========Inceput Super Spawns========*/
public SsInit(Float:mindist)
{
register_cvar("sv_superspawns", SS_VERSION, (FCVAR_SERVER|FCVAR_SPONLY));
register_concmd("_ss_dump", "SsDump");
g_flSsMinDist = mindist;
g_vecSsOrigins = ArrayCreate(3, 1);
g_vecSsSpawns = ArrayCreate(3, 1);
g_vecSsUsed = ArrayCreate(3, 1);
}
stock SsClean()
{
g_flSsMinDist = 0.0;
ArrayClear(g_vecSsOrigins);
ArrayClear(g_vecSsSpawns);
ArrayClear(g_vecSsUsed);
}
stock SsGetOrigin(Float:origin[3])
{
new Float:data[3], size;
new ok = 1;
while((size = ArraySize(g_vecSsOrigins)))
{
new idx = random_num(0, size - 1);
ArrayGetArray(g_vecSsOrigins, idx, origin);
new used = ArraySize(g_vecSsUsed);
for(new i = 0; i < used; i++)
{
ok = 0;
ArrayGetArray(g_vecSsUsed, i, data);
if(get_distance_f(data, origin) >= g_flSsMinDist)
{
ok = 1;
break;
}
}
ArrayDeleteItem(g_vecSsOrigins, idx);
if(ok)
{
ArrayPushArray(g_vecSsUsed, origin);
return true;
}
}
return false;
}
public SsDump()
{
new Float:origin[3];
new count = ArraySize(g_vecSsOrigins);
server_print("-------------------------------------------------------");
for(new i = 0; i < count; i++)
{
ArrayGetArray(g_vecSsOrigins, i, origin);
server_print("Origin: %f %f %f", origin[0], origin[1], origin[2]);
}
server_print("-------------------------------------------------------");
server_print("Number of origins: %i", count);
server_print("Time: %i", g_iSsTime);
server_print("-------------------------------------------------------");
}
public SsScan()
{
new start, Float:origin[3], starttime;
starttime = get_systime();
for(start = 0; start < sizeof(g_szStarts); start++)
{
server_print("Searching for %s", g_szStarts[start]);
new ent;
if((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", g_szStarts[start])))
{
new counter;
pev(ent, pev_origin, origin);
ArrayPushArray(g_vecSsSpawns, origin);
while(counter < SS_MAX_LOOPS)
{
counter = GetLocation(origin, counter);
}
}
}
g_iSsTime = get_systime();
g_iSsTime -= starttime;
}
GetLocation(Float:start[3], &counter)
{
new Float:end[3];
for(new i = 0; i < 3; i++)
{
end += random_float(0.0 - g_flOffsets, g_flOffsets);
}
if(IsValid(start, end))
{
start[0] = end[0];
start[1] = end[1];
start[2] = end[2];
ArrayPushArray(g_vecSsOrigins, end);
}
counter++;
return counter;
}
IsValid(Float:start[3], Float:end[3])
{
SetFloor(end);
end[2] += 36.0;
new point = engfunc(EngFunc_PointContents, end);
if(point == CONTENTS_EMPTY)
{
if(CheckPoints(end) && CheckDistance(end) && CheckVisibility(start, end))
{
if(!trace_hull(end, HULL_LARGE, -1))
{
return true;
}
}
}
return false;
}
CheckVisibility(Float:start[3], Float:end[3])
{
new tr;
engfunc(EngFunc_TraceLine, start, end, IGNORE_GLASS, -1, tr);
return (get_tr2(tr, TR_pHit) < 0);
}
SetFloor(Float:start[3])
{
new tr, Float:end[3];
end[0] = start[0];
end[1] = start[1];
end[2] = -99999.9;
engfunc(EngFunc_TraceLine, start, end, DONT_IGNORE_MONSTERS, -1, tr);
get_tr2(tr, TR_vecEndPos, start);
}
CheckPoints(Float:origin[3])
{
new Float:data[3], tr, point;
data[0] = origin[0];
data[1] = origin[1];
data[2] = 99999.9;
engfunc(EngFunc_TraceLine, origin, data, DONT_IGNORE_MONSTERS, -1, tr);
get_tr2(tr, TR_vecEndPos, data);
point = engfunc(EngFunc_PointContents, data);
if(point == CONTENTS_SKY && get_distance_f(origin, data) < 250.0)
{
return false;
}
data[2] = -99999.9;
engfunc(EngFunc_TraceLine, origin, data, DONT_IGNORE_MONSTERS, -1, tr);
get_tr2(tr, TR_vecEndPos, data);
point = engfunc(EngFunc_PointContents, data);
if(point < CONTENTS_SOLID)
return false;
return true;
}
CheckDistance(Float:origin[3])
{
new Float:dist, Float:data[3];
new count = ArraySize(g_vecSsSpawns);
for(new i = 0; i < count; i++)
{
ArrayGetArray(g_vecSsSpawns, i, data);
dist = get_distance_f(origin, data);
if(dist < SS_MIN_DISTANCE)
return false;
}
count = ArraySize(g_vecSsOrigins);
for(new i = 0; i < count; i++)
{
ArrayGetArray(g_vecSsOrigins, i, data);
dist = get_distance_f(origin, data);
if(dist < SS_MIN_DISTANCE)
return false;
}
return true;
}
/*====================================
========Sfarsit Super Spawns========*/
/* --| ColorChat |-- */
ColorChat( id, Color:iType, const msg[ ], { Float, Sql, Result, _}:... )
{
// Daca nu se afla nici un jucator pe server oprim TOT. Altfel dam de erori..
if( !get_playersnum( ) ) return;
new szMessage[ 256 ];
switch( iType )
{
// Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
case NORMAL: szMessage[ 0 ] = 0x01;
// Culoare Verde.
case GREEN: szMessage[ 0 ] = 0x04;
// Alb, Rosu, Albastru.
default: szMessage[ 0 ] = 0x03;
}
vformat( szMessage[ 1 ], 251, msg, 4 );
// Ne asiguram ca mesajul nu este mai lung de 192 de caractere.Altfel pica server-ul.
szMessage[ 192 ] = '^0';
new iTeam, iColorChange, iPlayerIndex, MSG_Type;
if( id )
{
MSG_Type = MSG_ONE_UNRELIABLE;
iPlayerIndex = id;
}
else
{
iPlayerIndex = CC_FindPlayer( );
MSG_Type = MSG_ALL;
}
iTeam = get_user_team( iPlayerIndex );
iColorChange = CC_ColorSelection( iPlayerIndex, MSG_Type, iType);
CC_ShowColorMessage( iPlayerIndex, MSG_Type, szMessage );
if( iColorChange ) CC_Team_Info( iPlayerIndex, MSG_Type, TeamName[ iTeam ] );
}
CC_ShowColorMessage( id, const iType, const szMessage[ ] )
{
static bool:bSayTextUsed;
static iMsgSayText;
if( !bSayTextUsed )
{
iMsgSayText = get_user_msgid( "SayText" );
bSayTextUsed = true;
}
message_begin( iType, iMsgSayText, _, id );
write_byte( id );
write_string( szMessage );
message_end( );
}
CC_Team_Info( id, const iType, const szTeam[ ] )
{
static bool:bTeamInfoUsed;
static iMsgTeamInfo;
if( !bTeamInfoUsed )
{
iMsgTeamInfo = get_user_msgid( "TeamInfo" );
bTeamInfoUsed = true;
}
message_begin( iType, iMsgTeamInfo, _, id );
write_byte( id );
write_string( szTeam );
message_end( );
return 1;
}
CC_ColorSelection( id, const iType, Color:iColorType)
{
switch( iColorType )
{
case RED: return CC_Team_Info( id, iType, TeamName[ 1 ] );
case BLUE: return CC_Team_Info( id, iType, TeamName[ 2 ] );
case GREY: return CC_Team_Info( id, iType, TeamName[ 0 ] );
}
return 0;
}
CC_FindPlayer( )
{
new iMaxPlayers = get_maxplayers( );
for( new i = 1; i <= iMaxPlayers; i++ )
if( is_user_connected( i ) )
return i;
return -1;
}
/* --| ColorChat |-- */
[/code]