|
楼主 |
发表于 2006-2-9 16:33:46
|
显示全部楼层
来自 中国–重庆–重庆
回复: nwb13和各位高手进关于抢夺旗子模式问题
好象设置成保护时间20秒不行~是不是过高了
不然真的不好冲出去
那位高手给小弟指出啊/* AMXMODX script.
*
* (c) Copyright 2004, Made by GHW_Chronic - This file is provided as is (no warranties).
*
*
* CAPTURE THE FLAG VERSION 1.0 - Tested to work on CS
*
* v1.7 changed to be compatable with all AMXX versions
*
* V1.6 With AMXX - Changed messages to help avoid confusion
*
* v1.0 - Added CTF guard feature
* - Improved scoreboard tracking
* - Fixed some run time errors
* - Various bug fixes
*
* v0.9 - Public release
*
*/
#include <amxmodx>
#include <amxmod>
#define TE_BEAMPOINTS 0
new ctfrunning, beam, gmsgTeamScore
new fr_stand[3], fr_origin[3], fr_holder, fr_return, fr_score, fr_status[33] = "基地"
new fb_stand[3], fb_origin[3], fb_holder, fb_return, fb_score, fb_status[33] = "基地"
new protected[33], guard_time
new fr_team[33] = "TERRORIST"
new fb_team[33] = "CT"
new fr_team_cn[33] = "恐怖份子"
new fb_team_cn[33] = "反恐精英"
public plugin_init()
{
register_plugin("Capture The Flag", "1.0", "GHW_Chronic|nwb13")
set_task(0.1,"drawflag",0,"",0,"b")
set_task(0.5,"checkflag",0,"",0,"b")
set_task(1.0,"drawflagstand",0,"",0,"b")
set_task(5.0,"check_cvar",0,"",0,"b")
register_event("DeathMsg","checkdeath","a")
register_event("Damage", "checkdamage", "b", "2!0")
register_event("ResetHUD", "startofround", "bce")
register_event("CurWeapon","switchweapon","be","1=1","2!29")
register_cvar("amx_ctf","1")
register_cvar("amx_ctf_guard", "8")
register_cvar("amx_ctf_version", "1.1",FCVAR_SERVER)
gmsgTeamScore = get_user_msgid("TeamScore")
}
public plugin_precache()
{
beam = precache_model("sprites/dot.spr")
}
public check_cvar()
{
if (get_cvar_num("amx_ctf"))
{
message_begin(MSG_ALL, gmsgTeamScore)
write_string(fr_team)
write_short(fr_score)
message_end()
message_begin(MSG_ALL, gmsgTeamScore)
write_string(fb_team)
write_short(fb_score)
message_end()
new team1, team2
for(new a = 1; a <= get_maxplayers(); ++a)
{
if (get_user_team(a) == 1)
{
team1 += 1
if (!(is_user_alive(a)) && ctfrunning == 1 )
{
new ids[1]
ids[0] = a
spawnplayer(ids)
}
}
else if (get_user_team(a) == 2)
{
team2 += 1
if (!(is_user_alive(a)) && ctfrunning == 1 )
{
new ids[1]
ids[0] = a
spawnplayer(ids)
}
}
}
guard_time = get_cvar_num("amx_ctf_guard")
if (guard_time < 4)
{
guard_time = 4
set_cvar_num("amx_ctf_guard", 4)
}
if (ctfrunning == 1)
{
return PLUGIN_CONTINUE
}
if (team1 > 1 && team2 > 1)
{
ctfrunning = 1
set_cvar_num("sv_restartround", 3)
set_cvar_num("mp_buytime", 7)
set_cvar_num("mp_roundtime", 7)
set_cvar_num("mp_startmoney", 1800)
set_cvar_num("amx_spawn_protect", 0)
}
else
{
set_hudmessage(0, 100, 0, -1.0, 0.85, 0, 4.0, 4.0, 1.0, 1.0, 20)
show_hudmessage(0,"夺旗模式 V1.1^n等待双方队伍中各有2名玩家")
}
}
else if (!(get_cvar_num("amx_ctf")))
{
ctfrunning = 0
}
return PLUGIN_CONTINUE
}
public switchweapon(id)
{
if (!(ctfrunning))
{
return PLUGIN_CONTINUE
}
new weapon=read_data(2)
if (protected[id] > 0)
{
client_print(id,print_chat,"夺旗模式保护提示: 你将在 %i 秒后可以使用武器.",protected[id])
engclient_cmd(id,"weapon_knife")
}
if (weapon == 6)
{
client_print(id,print_chat,"夺旗模式提示: 在夺旗模式里不允许放置炸弹.")
engclient_cmd(id,"weapon_knife")
}
return PLUGIN_CONTINUE
}
public drawflag()
{
if (!(ctfrunning))
{
return PLUGIN_CONTINUE
}
new s_origin[3], f_origin[3]
if (is_user_alive(fr_holder))
{
get_user_origin(fr_holder,fr_origin)
fr_origin[2] += 15
}
if (is_user_alive(fb_holder))
{
get_user_origin(fb_holder,fb_origin)
fb_origin[2] += 15
}
s_origin = fr_origin
f_origin = fr_origin
f_origin[2] += 20
drawbeam(s_origin,f_origin,1,3,200,200,200)
s_origin[2] = f_origin[2]
f_origin[2] += 20
drawbeam(s_origin,f_origin,1,80,200,0,0)
s_origin = fb_origin
f_origin = fb_origin
f_origin[2] += 20
drawbeam(s_origin,f_origin,1,3,200,200,200)
s_origin[2] = f_origin[2]
f_origin[2] += 20
drawbeam(s_origin,f_origin,1,80,0,0,200)
return PLUGIN_CONTINUE
}
public client_disconnect(id)
{
if (!(ctfrunning))
{
return PLUGIN_CONTINUE
}
protected[id] = 0
if (id == fr_holder)
{
set_hudmessage(0, 200, 0, -1.0, 0.4, 0, 3.0, 6.0, 0.1, 0.0, 9)
show_hudmessage(0,"%s 离开了游戏, 丢掉了 %s 的旗帜 !!!",fr_status,fr_team_cn)
fr_return = 30
fr_holder = -1
fr_origin[2] -= 10
}
if (id == fb_holder)
{
set_hudmessage(0, 200, 0, -1.0, 0.6, 0, 3.0, 6.0, 0.1, 0.0, 10)
show_hudmessage(0,"%s 离开了游戏, 丢掉了 %s 的旗帜 !!!",fb_status,fb_team_cn)
fb_return = 30
fb_holder = -1
fb_origin[2] -= 10
}
return PLUGIN_CONTINUE
}
public checkdeath()
{
if (!(ctfrunning))
{
return PLUGIN_CONTINUE
}
new killer = read_data(1)
new victim = read_data(2)
if (victim == fr_holder)
{
set_hudmessage(0, 200, 0, -1.0, 0.4, 0, 3.0, 6.0, 0.1, 0.0, 9)
show_hudmessage(0,"%s 丢掉了 %s 的旗帜 !!!",fr_status,fr_team_cn)
fr_return = 30
fr_holder = -1
fr_origin[2] -= 25
new money = get_user_money(killer)
set_user_money(killer,money+1000,1)
}
if (victim == fb_holder)
{
set_hudmessage(0, 200, 0, -1.0, 0.6, 0, 3.0, 6.0, 0.1, 0.0, 10)
show_hudmessage(0,"%s 丢掉了 %s 的旗帜 !!!",fb_status,fb_team_cn)
fb_return = 30
fb_holder = -1
fb_origin[2] -= 25
new money = get_user_money(killer)
set_user_money(killer,money+1000,1)
}
new ids[1]
ids[0] = victim
set_task(0.8,"spawnplayer",0,ids,1)
return PLUGIN_CONTINUE
}
public checkdamage(id)
{
if (!(ctfrunning))
{
return PLUGIN_CONTINUE
}
if (protected[id] > 0)
{
set_user_health(id,250)
// client_print(id,print_chat,"CTF GUARD IS PROTECTING YOU")
}
return PLUGIN_CONTINUE
}
public spawnplayer(ids[])
{
new victim = ids[0]
protected[victim] = guard_time
user_spawn(victim)
set_user_health(victim,250)
new money = get_user_money(victim)
if (money < 1800)
{
money = 1800
}
set_user_money(victim,money,0)
new pl_origin[3]
get_user_origin(victim,pl_origin)
pl_origin[2] -= 2000
set_user_origin(victim,pl_origin)
new iweapons[32], wpname[32], inum
get_user_weapons(victim,iweapons,inum)
for(new a=0;a<inum;++a)
{
get_weaponname(iweapons[a],wpname,31)
engclient_cmd(victim,"drop",wpname)
}
pl_origin[2] += 2005
give_item(victim,"weapon_knife")
set_user_origin(victim,pl_origin)
set_user_rendering(victim,kRenderFxGlowShell,200,200,100,kRenderNormal)
return PLUGIN_CONTINUE
}
public checkflag()
{
if (!(ctfrunning))
{
return PLUGIN_CONTINUE
}
for(new a = 1; a <= get_maxplayers(); ++a)
{
if (is_user_alive(a))
{
new pl_origin[3]
get_user_origin(a,pl_origin)
if (pl_origin[0] > (fb_origin[0] - 40) && pl_origin[0] < (fb_origin[0] + 40))
{
if (pl_origin[1] > (fb_origin[1] - 40) && pl_origin[1] < (fb_origin[1] + 40))
{
if (pl_origin[2] > (fb_origin[2] - 60) && pl_origin[2] < (fb_origin[2] + 80))
{
if (get_user_team(a) == 1 && fb_holder < 1)
{
if (protected[a] > 0)
{
client_print(a,print_chat,"夺旗模式: 在保护结束之前你不能取得对方的旗帜, 请稍候.")
}
else
{
fb_holder = a
get_user_name(a,fb_status,32)
set_user_rendering(a,kRenderFxGlowShell,200,0,0,kRenderNormal)
new money = get_user_money(a)
set_user_money(a,money + 1000,1)
set_hudmessage(0, 200, 0, -1.0, 0.4, 0, 3.0, 6.0, 0.1, 0.0, 9)
show_hudmessage(0,"%s 拿到了 %s 的旗帜 !!!",fb_status,fb_team_cn)
}
}
else if (get_user_team(a) == 2 && fb_holder == -1)
{
if (protected[a] > 0)
{
client_print(a,print_chat,"夺旗模式: 在保护结束之前你不能取得对方的旗帜, 请稍候.")
}
else
{
fb_return = 1
}
}
}
}
}
if (pl_origin[0] > (fr_origin[0] - 40) && pl_origin[0] < (fr_origin[0] + 40))
{
if (pl_origin[1] > (fr_origin[1] - 40) && pl_origin[1] < (fr_origin[1] + 40))
{
if (pl_origin[2] > (fr_origin[2] - 60) && pl_origin[2] < (fr_origin[2] + 80))
{
if (get_user_team(a) == 2 && fr_holder < 1)
{
if (protected[a] > 0)
{
client_print(a,print_chat,"夺旗模式: 在保护结束之前你不能取得对方的旗帜, 请稍候.")
}
else
{
fr_holder = a
get_user_name(a,fr_status,32)
set_user_rendering(a,kRenderFxGlowShell,0,0,200,kRenderNormal)
new money = get_user_money(a)
set_user_money(a,money + 1000,1)
set_hudmessage(0, 200, 0, -1.0, 0.6, 0, 3.0, 6.0, 0.1, 0.0, 10)
show_hudmessage(0,"%s 拿到了 %s 的旗帜 !!!",fr_status,fr_team_cn)
}
}
else if (get_user_team(a) == 1 && fr_holder == -1)
{
if (protected[a] > 0)
{
client_print(a,print_chat,"夺旗模式: 在保护结束之前你不能运回己方的旗帜, 请稍候.")
}
else
{
fr_return = 1
}
}
}
}
}
}
}
if (fr_holder == 0 && fb_holder != 0)
{
if (is_user_alive(fb_holder))
{
new pl_origin[3]
get_user_origin(fb_holder,pl_origin)
if (pl_origin[0] > (fr_stand[0] - 40) && pl_origin[0] < (fr_stand[0] + 40))
{
if (pl_origin[1] > (fr_stand[1] - 40) && pl_origin[1] < (fr_stand[1] + 40))
{
if (pl_origin[2] > (fr_stand[2] - 40) && pl_origin[2] < (fr_stand[2] + 40))
{
for(new a = 1; a <= get_maxplayers(); ++a)
{
if (get_user_team(a) == 1)
{
new money = get_user_money(a)
if (a == fb_holder)
{
money += 6000
}
else
{
money += 4000
}
set_user_money(a,money,1)
}
}
fr_score += 1
set_user_frags(fb_holder, get_user_frags(fb_holder) + 1)
set_hudmessage(0, 200, 0, -1.0, -1.0, 0, 3.0, 6.0, 0.1, 0.0, 10)
show_hudmessage(0,"%s 成功夺取了 %s 的旗帜 !!!^n%s: %i - %s: %i",fb_status,fb_team_cn,fr_team_cn,fr_score,fb_team_cn,fb_score)
set_user_rendering(fb_holder,kRenderFxNone,0,0,0,kRenderNormal)
fb_holder = 0
fb_origin = fb_stand
fb_status = "基地"
}
}
}
}
}
if (fb_holder == 0 && fr_holder != 0)
{
if (is_user_alive(fr_holder))
{
new pl_origin[3]
get_user_origin(fr_holder,pl_origin)
if (pl_origin[0] > (fb_stand[0] - 40) && pl_origin[0] < (fb_stand[0] + 40))
{
if (pl_origin[1] > (fb_stand[1] - 40) && pl_origin[1] < (fb_stand[1] + 40))
{
if (pl_origin[2] > (fb_stand[2] - 40) && pl_origin[2] < (fb_stand[2] + 40))
{
for(new a = 1; a <= get_maxplayers(); ++a)
{
if (get_user_team(a) == 2)
{
new money = get_user_money(a)
if (a == fr_holder)
{
money += 6000
}
else
{
money += 4000
}
set_user_money(a,money,1)
}
}
fb_score += 1
set_user_frags(fr_holder, get_user_frags(fr_holder) + 1)
set_hudmessage(0, 200, 0, -1.0, -1.0, 0, 3.0, 6.0, 0.1, 0.0, 10)
show_hudmessage(0,"%s 成功夺取了 %s 的旗帜 !!!^n%s: %i - %s: %i",fr_status,fr_team_cn,fb_team_cn,fb_score,fr_team_cn,fr_score)
set_user_rendering(fr_holder,kRenderFxNone,0,0,0,kRenderNormal)
fr_holder = 0
fr_origin = fr_stand
fr_status = "基地"
}
}
}
}
}
return PLUGIN_CONTINUE
}
public startofround()
{
if (!(ctfrunning))
{
return PLUGIN_CONTINUE
}
for(new a = 1; a <= get_maxplayers(); ++a)
{
if (protected[a] > 0)
{
protected[a] = 2
}
}
if (fr_holder == 0 && fb_holder != 0)
{
set_user_rendering(fb_holder,kRenderFxNone,0,0,0,kRenderNormal)
fb_holder = 0
fb_origin = fb_stand
fb_status = "基地"
}
if (fb_holder == 0 && fr_holder != 0)
{
set_user_rendering(fr_holder,kRenderFxNone,0,0,0,kRenderNormal)
fr_holder = 0
fr_origin = fr_stand
fr_status = "基地"
}
if (fr_stand[0] != fb_stand[0])
{
return PLUGIN_CONTINUE
}
set_task(3.0,"locateflagstand")
return PLUGIN_CONTINUE
}
public locateflagstand()
{
for(new a = 1; a <= get_maxplayers(); ++a)
{
if (get_user_team(a) == 1)
{
get_user_origin(a,fr_stand)
fr_origin = fr_stand
}
else if (get_user_team(a) == 2)
{
get_user_origin(a,fb_stand)
fb_origin = fb_stand
}
}
return PLUGIN_CONTINUE
}
public drawflagstand(id)
{
if (!(ctfrunning))
{
return PLUGIN_CONTINUE
}
if (fr_stand[1] != 0 || fb_stand[1] != 0)
{
new s_origin[3], f_origin[3]
s_origin = fr_stand
f_origin = fr_stand
s_origin[2] += 10
f_origin[2] -= 35
f_origin[1] -= 30
f_origin[0] -= 30
drawbeam(s_origin,f_origin,10,10,0,200,0)
f_origin[1] += 60
drawbeam(s_origin,f_origin,10,10,0,200,0)
f_origin[0] += 60
drawbeam(s_origin,f_origin,10,10,0,200,0)
f_origin[1] -= 60
drawbeam(s_origin,f_origin,10,10,0,200,0)
s_origin = fb_stand
f_origin = fb_stand
s_origin[2] += 10
f_origin[2] -= 35
f_origin[1] -= 30
f_origin[0] -= 30
drawbeam(s_origin,f_origin,10,10,0,200,0)
f_origin[1] += 60
drawbeam(s_origin,f_origin,10,10,0,200,0)
f_origin[0] += 60
drawbeam(s_origin,f_origin,10,10,0,200,0)
f_origin[1] -= 60
drawbeam(s_origin,f_origin,10,10,0,200,0)
}
set_hudmessage(200, 0, 0, -1.0, 0.03, 0, 0.9, 1.0, 0.1, 0.0, 7)
show_hudmessage(0,"红队旗帜: %s",fr_status)
set_hudmessage(0, 0, 200, -1.0, 0.06, 0, 0.9, 1.0, 0.1, 0.0, 8)
show_hudmessage(0,"蓝队旗帜: %s",fb_status)
if (fr_holder == -1)
{
fr_return -= 1
numtostr(fr_return, fr_status, 3)
if (fr_return == 0)
{
set_hudmessage(0, 200, 0, -1.0, 0.6, 0, 3.0, 3.0, 0.1, 0.0, 9)
show_hudmessage(0,"%s 的旗帜被运回了基地",fr_team_cn)
fr_holder = 0
fr_origin = fr_stand
fr_status = "基地"
}
}
if (fb_holder == -1)
{
fb_return -= 1
numtostr(fb_return, fb_status, 3)
if (fb_return == 0)
{
set_hudmessage(0, 200, 0, -1.0, 0.4, 0, 3.0, 3.0, 0.1, 0.0, 10)
show_hudmessage(0,"%s 的旗帜被运回了基地",fb_team_cn)
fb_holder = 0
fb_origin = fb_stand
fb_status = "基地"
}
}
for(new a = 1; a <= get_maxplayers(); ++a)
{
if (protected[a] == 1)
{
set_user_health(a,100)
set_user_rendering(a,kRenderFxNone,0,0,0,kRenderNormal)
}
if (protected[a] == (guard_time - 1))
{
set_user_rendering(a,kRenderFxGlowShell,200,200,100,kRenderNormal)
client_print(a,print_chat,"夺旗模式保护提示: 你在 %i 秒内不会被杀死.",protected[a])
}
if (protected[a] > 0)
{
protected[a] -= 1
set_hudmessage(200, 200, 200, 0.03, 0.89, 0, 0.9, 1.0, 0.1, 0.0, 13)
show_hudmessage(a,"夺旗模式保护时间: %i",protected[a])
}
}
return PLUGIN_CONTINUE
}
public drawbeam(s_origin[3],f_origin[3],blife,bwidth,bred,bgreen,bblue)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte( TE_BEAMPOINTS )
write_coord(s_origin[0])
write_coord(s_origin[1])
write_coord(s_origin[2])
write_coord(f_origin[0])
write_coord(f_origin[1])
write_coord(f_origin[2])
write_short( beam )
write_byte( 1 ) // framestart
write_byte( 1 ) // framerate
write_byte( blife ) // life in 0.1's
write_byte( bwidth ) // width
write_byte( 0 ) // noise
write_byte( bred ) // red
write_byte( bgreen ) // green
write_byte( bblue ) // blue
write_byte( 200 ) // brightness
write_byte( 0 ) // speed
message_end()
} |
|