Code Still has Bugs .. Uploaded back before i fixed them On special request by Hornet
I dont think now this is required in New plugin submissions. So fix the bugs and use it
PHP Code:
#include <amxmodx>
#include <fun>
#include <engine>
new g_playerT,g_playerCT;
new g_maxplayers
public plugin_init()
{
register_event("HLTV", "event_NewRound", "a", "1=0", "2=0");
register_event( "DeathMsg", "EventDeathMsg", "a", "1>0" );
g_maxplayers = get_maxplayers()
}
public event_NewRound() {
//client_print(g_playerCT, print_chat, "Delaying 2 seconds");
set_task(2.0,"spawnplayers")
}
public EventDeathMsg() {
new killer = read_data(1);
new victim = read_data(2);
if ( g_playerT && victim == g_playerT && is_user_connected(killer) ) {
new killer_name[32], victim_name[32];
get_user_name(killer, killer_name, charsmax(killer_name));
get_user_name(victim, victim_name, charsmax(victim_name));
colored_print(0, "^x04 %s saved the Asses of Ts by killing %s and was given 50HP Bonus :D", killer_name,victim_name);
show_hudmessage(killer ,"Bonus +50 HP[Deathmsg]");
set_user_health(killer, get_user_health(killer) + 50);
}
if ( g_playerCT && victim == g_playerCT && is_user_connected(killer) ) {
new killer_name[32], victim_name[32];
get_user_name(killer, killer_name, charsmax(killer_name));
get_user_name(victim, victim_name, charsmax(victim_name));
colored_print(0, "^x04 %s saved the Asses of Ts by killing %s and was given 50HP Bonus :D", killer_name,victim_name);
show_hudmessage(killer ,"Bonus +50 HP[Deathmsg]");
set_user_health(killer, get_user_health(killer) + 50);
}
}
public client_disconnect(id) {
if ( id == g_playerT )
g_playerT = 0;
if ( id == g_playerCT )
g_playerCT = 0;
}
public spawnplayers()
{
if ( g_playerT ) {
//colored_print(g_playerT, "Saale Bach kaise gya xD !!")
//client_print(g_playerT, print_chat, "Phew.. You have survived the round !!");
}
if ( g_playerCT ) {
//colored_print(g_playerCT, "Saale Bach kaise gya xD !!")
//client_print(g_playerCT, print_chat, "Phew ..You have survived the round !!");
}
g_playerT = 0;
g_playerCT = 0;
new playersT[32], playersnumT;
new playersCT[32], playersnumCT;
get_players(playersT, playersnumT, "a", "TERRORIST");
get_players(playersCT, playersnumCT, "a", "CT");
g_playerT = playersT[random(playersnumT)];
g_playerCT = playersCT[random(playersnumCT)];
new nameT[32],nameCT[32];
get_user_name(g_playerT, nameT, charsmax(nameT));
get_user_name(g_playerCT, nameCT, charsmax(nameCT));
//client_print(g_playerCT, print_chat, "Players chosen");
new Tspot[33][3]
new CTspot[33][3]
//Get Spawn
get_user_origin(g_playerT,Tspot[g_playerT])
get_user_origin(g_playerCT,CTspot[g_playerCT])
//client_print(0, print_chat, "Spawns GET!");
//Set Spawn
set_user_origin(g_playerT,CTspot[g_playerCT])
set_user_origin(g_playerCT,Tspot[g_playerT])
//client_print(0, print_chat, "Spawns SET!");
set_user_health(g_playerT, get_user_health(g_playerT) + 100);
set_user_health(g_playerCT, get_user_health(g_playerCT) + 100);
//Done Spawning
colored_print(0, "^x04Spawns of %s & %s are exchanged :D Kill Or Get Killed!", nameT, nameCT);
}
/*
public event_HamKilled(victim, killer)
{
set_hudmessage(127, 170, 255, 0.27, 0.14, 0, 5.0, 5.0, 0.0, 0.0, -1);
if ( g_playerT && victim == g_playerT && is_user_connected(killer) ) {
new killer_name[32], victim_name[32];
get_user_name(killer, killer_name, charsmax(killer_name));
get_user_name(victim, victim_name, charsmax(victim_name));
colored_print(0, "^x04 %s saved the Asses of CTs by killing %s and was given 50HP Bonus :D[HAM]", killer_name,victim_name);
show_hudmessage(killer ,"Bonus +50 HP[HAM]");
set_user_health(killer, get_user_health(killer) + 50);
}
if ( g_playerCT && victim == g_playerCT && is_user_connected(killer) ) {
new killer_name[32], victim_name[32];
get_user_name(killer, killer_name, charsmax(killer_name));
get_user_name(victim, victim_name, charsmax(victim_name));
colored_print(0, "^x04 %s saved the Asses of Ts by killing %s and was given 50HP Bonus :D[HAM]", killer_name,victim_name);
show_hudmessage(killer ,"Bonus +50 HP[HAM]");
set_user_health(killer, get_user_health(killer) + 50);
}
}
*/
// Colored print by MeRcyLeZZ
colored_print(target, const message[], any:...)
{
static buffer[512], i, argscount, g_msgSayText
argscount = numargs()
g_msgSayText = get_user_msgid("SayText")
// Send to everyone
if (!target)
{
static player
for (player = 1; player <= g_maxplayers; player++)
{
// Not connected
if (!is_user_connected(player))
continue;
// Remember changed arguments
static changed[5], changedcount // [5] = max LANG_PLAYER occurencies
changedcount = 0
// Replace LANG_PLAYER with player id
for (i = 2; i < argscount; i++)
{
if (getarg(i) == LANG_PLAYER)
{
setarg(i, 0, player)
changed[changedcount] = i
changedcount++
}
}
// Format message for player
vformat(buffer, charsmax(buffer), message, 3)
// Send it
message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player)
write_byte(player)
write_string(buffer)
message_end()
// Replace back player id's with LANG_PLAYER
for (i = 0; i < changedcount; i++)
setarg(changed[i], 0, LANG_PLAYER)
}
}
// Send to specific target
else
{
// Format message for player
vformat(buffer, charsmax(buffer), message, 3)
// Send it
message_begin(MSG_ONE, g_msgSayText, _, target)
write_byte(target)
write_string(buffer)
message_end()
}
}