求高手帮忙修改一下这个插件[已解决]
本帖最后由 593727013 于 2010-6-17 14:25 编辑[该问题已被解决]
下面是 玩家被击毙时掉落急救包 的插件,我做了一些小改动,现请高手就此源码的基础上为插件添加以下功能:
1.添加新的CVAR"amx_kitmaxhp",如果玩家的生命值等于"amx_kitmaxhp"的设定值,则玩家无法捡起急救包;
2.玩家捡到急救包时,检查玩家在捡起急救包后,"原生命值+急救包恢复HP值"是否大于"amx_kitmaxhp"的设定值,如果大于则将玩家生命值设定为"amx_kitmaxhp"的值,否则将玩家生命值设定为"原生命值+急救包恢复HP值".
3.在玩家捡到急救包时,在该玩家附近500英尺范围内的其他玩家可以看到该玩家捡到急救包的信息.信息内容大体为"玩家^x03%s^x01拾获了^x04急救包^x01,生命值恢复到了^x03%d^x01点HP."其中^x03是拾获急救包玩家的团队色彩,且只要处于划定范围内的玩家不分队别都可以看到该信息,包括使用者本身.
注:第1,2步如果太麻烦可以省去CVAR,能够直接在源码中设置亦可,第3步如果太麻烦可以忽略.当然能够完全实现最好.
我愚钝,鼓捣半天实在是弄不出来他,还请高手们帮忙制作一下,制作完成后,请高手将源码(*.sma)在下面跟帖进行收费发布(我也好酬谢,况且好成果一定要收费),贵点我不在乎,只求功能能被完善.
[感谢高手相助.如果哪位高手已经打算帮我,请先行跟帖说一下.谢谢!]
#include <amxmod>
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("AMX Medkit","1.0","duper/Rockell & X-man")
register_cvar("amx_medkit", "1")
register_cvar("amx_medkithealth", "30")
register_event("ResetHUD", "newRound","b")
register_event("DeathMsg","deathevent","a")
}
//----------------------------------------------------------------------------------------------
public newRound()
{
new chocolate = find_ent_by_class(-1, "chocolate")
while(chocolate) {
remove_entity(chocolate)
chocolate = find_ent_by_class(chocolate, "chocolate")
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public deathevent()
{
if ( !get_cvar_num("amx_medkit") )
return PLUGIN_CONTINUE
new killer = read_data(1)
new victim = read_data(2)
if ( killer != victim )
{
createChocolate(victim)
}
if(is_user_connected(victim))
cs_reset_user_model(victim)
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public createChocolate(victim)
{
new Float:vAim, Float:vOrigin
entity_get_vector(victim, EV_VEC_origin, vOrigin)
VelocityByAim(victim, random_num(2, 4), vAim)
vOrigin += vAim
vOrigin += vAim
vOrigin += 30.0
new chocolate = create_entity("info_target")
entity_set_string(chocolate, EV_SZ_classname, "chocolate")
entity_set_model(chocolate, "models/w_medkit.mdl")
entity_set_size(chocolate, Float:{-2.5, -2.5, -1.5}, Float:{2.5, 2.5, 1.5})
entity_set_int(chocolate, EV_INT_solid, 2)
entity_set_int(chocolate, EV_INT_movetype, 6)
entity_set_vector(chocolate, EV_VEC_origin, vOrigin)
}
//----------------------------------------------------------------------------------------------
public plugin_precache() {
precache_model("models/w_medkit.mdl")
precache_sound( "items/smallmedkit1.wav")
}
//----------------------------------------------------------------------------------------------
public pfn_touch(ptr, ptd){
if(!is_valid_ent(ptd) || !is_valid_ent(ptr))
return PLUGIN_CONTINUE
if(!is_user_connected(ptd) || !is_user_alive(ptd))
return PLUGIN_CONTINUE
new classname
entity_get_string(ptr, EV_SZ_classname, classname, 31)
if(equal(classname, "chocolate"))
{
new gOrigHealth = get_user_health(ptd)
new health = gOrigHealth + get_cvar_num("amx_medkithealth")
set_user_health(ptd, health)
emit_sound(ptd,CHAN_VOICE,"items/smallmedkit1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
remove_entity(ptr)
}
return PLUGIN_CONTINUE
}
public client_death(killer, victim, wpnindex, hitplace, TK)
{
if(wpnindex == CSW_C4&& is_user_connected(victim))
cs_reset_user_model(victim)
} 对相助者万分感激! 本帖最后由 yesterday 于 2010-6-17 11:55 编辑
可以编译,没试效果,你试试看吧,应该没问题
#include <amxmod>
#include <cstrike>
#include <fakemeta>
#include <fun>
//----------------------------------------------------------------------------------------------
new g_medkit, g_medkithealth, g_kitmaxhp
new max_players
public plugin_init()
{
// Plugin Info
register_plugin("AMX Medkit","1.0","duper/Rockell X-man")
register_cvar("amx_medkit", "1")
register_cvar("amx_medkithealth", "30")
register_cvar("amx_kitmaxhp","120")
register_event("ResetHUD", "newRound","b")
register_event("DeathMsg","deathevent","a")
max_players = get_maxplayers()
}
//----------------------------------------------------------------------------------------------
public plugin_cfg()
{
set_task(0.5, "cache_cvars")
}
public cache_cvars()
{
g_medkit = get_cvar_num("amx_medkit")
g_medkithealth = get_cvar_num("amx_medkithealth")
g_kitmaxhp = get_cvar_num("amx_kitmaxhp")
}
public newRound()
{
new chocolate = find_ent_by_class(-1, "chocolate")
while(chocolate) {
remove_entity(chocolate)
chocolate = find_ent_by_class(chocolate, "chocolate")
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public deathevent()
{
if ( !g_medkit)
return PLUGIN_CONTINUE
new killer = read_data(1)
new victim = read_data(2)
if ( killer != victim )
{
createChocolate(victim)
}
if(is_user_connected(victim))
cs_reset_user_model(victim)
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public createChocolate(victim)
{
new Float:vAim, Float:vOrigin
entity_get_vector(victim, EV_VEC_origin, vOrigin)
VelocityByAim(victim, random_num(2, 4), vAim)
vOrigin += vAim
vOrigin += vAim
vOrigin += 30.0
new chocolate = create_entity("info_target")
entity_set_string(chocolate, EV_SZ_classname, "chocolate")
entity_set_model(chocolate, "models/w_medkit.mdl")
entity_set_size(chocolate, Float:{-2.5, -2.5, -1.5}, Float:{2.5, 2.5, 1.5})
entity_set_int(chocolate, EV_INT_solid, 2)
entity_set_int(chocolate, EV_INT_movetype, 6)
entity_set_vector(chocolate, EV_VEC_origin, vOrigin)
}
//----------------------------------------------------------------------------------------------
public plugin_precache() {
precache_model("models/w_medkit.mdl")
precache_sound( "items/smallmedkit1.wav")
}
//----------------------------------------------------------------------------------------------
public pfn_touch(ptr, ptd){
if(!is_valid_ent(ptd) || !is_valid_ent(ptr))
return PLUGIN_CONTINUE
if(!is_user_connected(ptd) || !is_user_alive(ptd))
return PLUGIN_CONTINUE
new classname
entity_get_string(ptr, EV_SZ_classname, classname, 31)
if(equal(classname, "chocolate"))
{
new gOrigHealth = get_user_health(ptd)
new health = gOrigHealth + g_medkithealth
if(health > g_kitmaxhp)
{
set_user_health(ptd, g_kitmaxhp)
}
else
{
set_user_health(ptd, health)
}
emit_sound(ptd,CHAN_VOICE,"items/smallmedkit1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
remove_entity(ptr)
new sMsg, sName
new hp1 = get_user_health(ptd)
get_user_name(ptd,sName,32)
for(new id=1;id<=max_players;id++)
{
if(ptd == id)
{
format(sMsg, 128, "你拾获了^x04急救包^x01,生命值恢复到了^x03%d^x01点HP." , hp1)
client_color(ptd, ptd, sMsg)
}
else
{
if(fm_entity_range(ptd, id) <= 500.0)
{
format(sMsg, 128, "玩家^x03%s^x01拾获了^x04急救包^x01,生命值恢复到了^x03%d^x01点HP." ,sName , hp1)
client_color(ptd, ptd, sMsg)
}
}
}
}
return PLUGIN_CONTINUE
}
public client_color(playerid, colorid, sMsg[])
{
message_begin(playerid?MSG_ONE:MSG_ALL,get_user_msgid("SayText"),{0,0,0},playerid)
write_byte(colorid)
write_string(sMsg)
message_end()
}
public client_death(killer, victim, wpnindex, hitplace, TK)
{
if(wpnindex == CSW_C4&& is_user_connected(victim))
cs_reset_user_model(victim)
}
stock Float:fm_entity_range(ent1, ent2)
{
new Float:origin1, Float:origin2;
pev(ent1, pev_origin, origin1);
pev(ent2, pev_origin, origin2);
return get_distance_f(origin1, origin2);
}
本帖最后由 593727013 于 2010-6-17 14:25 编辑
可以编译.太感谢你的帮助了!谢谢!
但是使用时发现这个问题:文字并没有着色而且信息会重复显示,如图
貌似附近有多少人就显示多少遍呢..
我修改了一下 去掉了对别人的信息显示 除满血也能拣包外,基本符合要求了 谢谢! 希望能共享下
页:
[1]