Участник
Пользователь
- Сообщения
- 317
- Реакции
- 131
- Помог
- 4 раз(а)
shelru,
Код:
/* CVARs
mc_enable — 0/1 — плагин выключен/включен. При установке значения больше 1, плагин автоматически выставляет 0 и выключается.
mc_bodycoin — количество монет, выпадающих с противника после его убийства.
mc_maxcoins — количество монет, необходимых для получения возможности возрождения.
mc_defusecoins — количество монет, дающихся игроку после разминирования бомбы. Если значение равно 0, то функция отключается.
mc_explodecoins — количество монет, дающихся игроку после взрыва бомбы. Если значение равно 0, то функция отключается.
mc_coinstype — 0/1 — обычные монетки/динамичные(после выпадения монетки будут отскакивать от стен, пола, ящиков и т.д.).
При установке значения больше 1, плагин автоматически выставляет 0 и включаются обычные монетки.
*/
#include <amxmodx>
#include <engine>
#include <hamsandwich>
//#include <dhudmessage>
#define Mplayers 32 + 1
#define TASKID_COINS 123
new bCountTokenCoins[Mplayers];
new gCvarPluginEnable;
new gCvarPluginCoinsType;
new gCvarPluginMaxCoinsForLife;
new gCvarPluginCoinsPerBody;
new gCvarPluginCoinsForDefuse;
new gCvarPluginCoinsForExplode;
//new gHudSyncronizer;
/* defolt
new const gCoinModel[] = "models/MarioCoins/mario_coin1.mdl";
new const gCoinGained[] = "MarioCoins/coingained.wav";
new const gLifeGained[] = "MarioCoins/lifegained.wav";
new const gRespawned[] = "MarioCoins/respawned.wav";
*/
// Precache
/*
public plugin_precache()
{
new const gCoinModel[] = precache_model("models/MarioCoins/mario_coin1.mdl")
new const gCoinGained[] = precache_sound("MarioCoins/coingained.wav")
new const gLifeGained[] = precache_sound("MarioCoins/lifegained.wav")
new const gRespawned[] = precache_sound("MarioCoins/respawned.wav")
}
*/
new const gCoinModel[] = "models/MarioCoins/mario_coin4.mdl";
new const gCoinGained[] = "MarioCoins/coingained.wav";
new const gLifeGained[] = "MarioCoins/lifegained.wav";
new const gRespawned[] = "MarioCoins/respawned.wav";
public plugin_precache()
{
precache_model(gCoinModel);
precache_sound(gCoinGained);
precache_sound(gLifeGained);
precache_sound(gRespawned);
}
public plugin_init()
{
register_plugin("Mario Coins","2.1","EvilCoder/tuty");
register_dictionary("MarioCoins.txt");
gCvarPluginEnable = register_cvar("mc_enable","1");
if(get_pcvar_num(gCvarPluginEnable) != 1)
{
set_pcvar_num(gCvarPluginEnable,0);
return;
}
register_event("TextMsg","EVENT_TextMsg","a","2&#Game_C","2&#Game_w","2&#Game_will_restart_in");
register_logevent("LOG_RoundEnd",2,"1=Round_End");
register_touch("MarioCoin$","player","TouchCoin");
RegisterHam(Ham_Killed,"player","bacon_PlayerKilled",1);
RegisterHam(Ham_Player_PreThink,"player","bacon_PlayerPreThink");
gCvarPluginCoinsType = register_cvar("mc_coinstype","0");
if(get_pcvar_num(gCvarPluginCoinsType) != 1)
{
set_pcvar_num(gCvarPluginCoinsType,0);
}
gCvarPluginCoinsPerBody = register_cvar("mc_bodycoin","1");
gCvarPluginMaxCoinsForLife = register_cvar("mc_maxcoins","10");
gCvarPluginCoinsForDefuse = register_cvar("mc_defusecoins","1");
gCvarPluginCoinsForExplode = register_cvar("mc_explodecoins","1");
//gHudSyncronizer = CreateHudSyncObj();
set_task(1.0, "bacon_PlayerPreThink", TASKID_COINS, .flags = "b");
}
public client_connect(iVictim)
{
bCountTokenCoins[iVictim] = 0;
}
public EVENT_TextMsg()
{
remove_entity_name("MarioCoin$");
}
public LOG_RoundEnd()
{
remove_entity_name("MarioCoin$");
}
public bomb_defused(defuser)
{
if(get_pcvar_num(gCvarPluginCoinsForDefuse) == 0)
{
return PLUGIN_CONTINUE;
}
bCountTokenCoins[defuser] += get_pcvar_num(gCvarPluginCoinsForDefuse);
new iMaxCoins = get_pcvar_num(gCvarPluginMaxCoinsForLife);
if(bCountTokenCoins[defuser] >= iMaxCoins)
{
emit_sound(defuser,CHAN_ITEM,gLifeGained,VOL_NORM,ATTN_NORM,0,PITCH_NORM);
bCountTokenCoins[defuser] = iMaxCoins;
return PLUGIN_CONTINUE;
}
emit_sound(defuser,CHAN_ITEM,gCoinGained,VOL_NORM,ATTN_NORM,0,PITCH_NORM);
remove_entity_name("MarioCoin$");
return PLUGIN_CONTINUE;
}
public bomb_explode(planter)
{
if(get_pcvar_num(gCvarPluginCoinsForExplode) == 0)
{
return PLUGIN_CONTINUE;
}
bCountTokenCoins[planter] += get_pcvar_num(gCvarPluginCoinsForExplode);
new iMaxCoins = get_pcvar_num(gCvarPluginMaxCoinsForLife);
if(bCountTokenCoins[planter] >= iMaxCoins)
{
emit_sound(planter,CHAN_ITEM,gLifeGained,VOL_NORM,ATTN_NORM,0,PITCH_NORM);
bCountTokenCoins[planter] = iMaxCoins;
return PLUGIN_CONTINUE;
}
emit_sound(planter,CHAN_ITEM,gCoinGained,VOL_NORM,ATTN_NORM,0,PITCH_NORM);
remove_entity_name("MarioCoin$");
return PLUGIN_CONTINUE;
}
public bacon_PlayerKilled(iVictim, iKiller, iGib)
{
// new iKiller = read_data(1);
// new iVictim = read_data(2);
if(iKiller == iVictim || get_user_team(iKiller) == get_user_team(iVictim))
{
return;
}
if(bCountTokenCoins[iVictim] >= get_pcvar_num(gCvarPluginMaxCoinsForLife))
{
/* if(!is_user_alive(iVictim)) ???*/
{
set_task(0.1,"RegMenu",iVictim);
}
}
new Float:flPlayerOrigin[3];
entity_get_vector(iVictim,EV_VEC_origin,flPlayerOrigin);
flPlayerOrigin[2] -= 36;
new packedOrigin[3];
FVecIVec(flPlayerOrigin,packedOrigin);
set_task(0.1,"spawnCoins",4142,packedOrigin,3,"a",get_pcvar_num(gCvarPluginCoinsPerBody));
}
public RegMenu(iVictim)
{
new regmenu[512 char];
formatex(regmenu,charsmax(regmenu),"%L",iVictim,"DO_YOU_WANT_RESPAWN");
new menu = menu_create(regmenu,"ShowMenu");
formatex(regmenu,charsmax(regmenu),"%L",iVictim,"YES_I_WANT");
menu_additem(menu,regmenu,"1",0);
formatex(regmenu,charsmax(regmenu),"%L",iVictim,"NO_I_DO_NOT");
menu_additem(menu,regmenu,"2",0);
menu_setprop(menu,MPROP_EXIT,MEXIT_NEVER,-1);
menu_display(iVictim,menu,0);
return PLUGIN_CONTINUE;
}
public ShowMenu(iVictim,menu,item)
{
new data[6],iName[64],access,callback;
menu_item_getinfo(menu,item,access,data,charsmax(data),iName,charsmax(iName),callback);
new key = str_to_num(data);
switch(key)
{
case 1:
{
set_task(0.1,"RespawnPlayerAndResetCoins",iVictim);
menu_destroy(menu);
}
case 2:
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED;
}
public spawnCoins(packedOrigin[3])
{
new Float:origin[3];
IVecFVec(packedOrigin,origin);
new iEntity = create_entity("info_target");
if(!is_valid_ent(iEntity))
{
return;
}
origin[2] += 65.0;
entity_set_origin(iEntity,origin);
new Float:velocity[3];
velocity[0] = (random_float(0.0,256.0) - 128.0);
velocity[1] = (random_float(0.0,256.0) - 128.0);
velocity[2] = (random_float(0.0,300.0) + 75.0);
entity_set_vector(iEntity,EV_VEC_velocity,velocity);
static modelName[64];
formatex(modelName,63,"models/MarioCoins/mario_coin4.mdl");
//entity_set_model(iEntity,modelName);
entity_set_model(iEntity, gCoinModel)
entity_set_string(iEntity,EV_SZ_classname,"MarioCoin$");
entity_set_int(iEntity,EV_INT_solid,SOLID_TRIGGER);
if(get_pcvar_num(gCvarPluginCoinsType) != 1)
{
entity_set_int(iEntity,EV_INT_movetype,MOVETYPE_TOSS);
}
else
{
entity_set_int(iEntity,EV_INT_movetype,MOVETYPE_BOUNCE);
}
drop_to_floor(iEntity);
set_rendering(iEntity,kRenderFxGlowShell,255,255,0,kRenderNormal,10);
}
public TouchCoin(iEntity,id)
{
if(is_valid_ent(iEntity))
{
new iMaxCoins = get_pcvar_num(gCvarPluginMaxCoinsForLife);
bCountTokenCoins[id]++;
if(bCountTokenCoins[id] >= iMaxCoins)
{
emit_sound(id,CHAN_ITEM,gLifeGained,VOL_NORM,ATTN_NORM,0,PITCH_NORM);
set_entity_flags(iEntity,FL_KILLME,1);
bCountTokenCoins[id] = iMaxCoins;
return PLUGIN_CONTINUE;
}
emit_sound(id,CHAN_ITEM,gCoinGained,VOL_NORM,ATTN_NORM,0,PITCH_NORM);
set_entity_flags(iEntity,FL_KILLME,1);
}
remove_entity(iEntity);
return PLUGIN_CONTINUE;
}
public bacon_PlayerPreThink(id)
{
if(is_user_alive(id) && !is_user_bot(id))
{
//set_hudmessage(255,127,42,0.0,0.90,0,6.0);
set_hudmessage(255,127,42,0.03,0.88,0,6.0);
new iMaxCoins = get_pcvar_num(gCvarPluginMaxCoinsForLife);
//new szFormatHUDMessage[300];
if(bCountTokenCoins[id] == iMaxCoins)
{
//formatex(szFormatHUDMessage,charsmax(szFormatHUDMessage),"%L",id,"CAN_RESPAWN");
show_hudmessage(id,"%L","CAN_RESPAWN");
}
else
{
//formatex(szFormatHUDMessage,charsmax(szFormatHUDMessage),"%L: [%d/%d]",id,"COINS_COUNT",bCountTokenCoins[id],iMaxCoins);
show_hudmessage(id,"%L: [%d/%d]","COINS_COUNT",bCountTokenCoins[id],iMaxCoins);
}
//ShowSyncHudMsg(id,gHudSyncronizer,szFormatHUDMessage);
}
}
public RespawnPlayerAndResetCoins(iVictim)
{
if(is_user_connected(iVictim) && !is_user_alive(iVictim) && get_user_team(iVictim) != 3)
{
ExecuteHamB(Ham_CS_RoundRespawn,iVictim);
emit_sound(iVictim,CHAN_ITEM,gRespawned,VOL_NORM,ATTN_NORM,0,PITCH_NORM);
bCountTokenCoins[iVictim] = 0;
}
}