Senior Member
Join Date: Oct 2018
Location: Leeds
|
07-19-2021
, 10:24
Re: End round display damage done.
|
#5
|
Quote:
Originally Posted by Natsheh
Which bots sys are you using?
Show full code also.
|
Just normal Podbots_MM
I dont think full code is necessary since g_Gamestate is just a var I'm using to increment it when I'm switching between OVERTIME and NORMAL, and g_RoundCount is just a tracker of rounds, 2 simple vars. If you meant like full code I'm using for bots or anything like that I'm not using anything with bots, I just let them join normally from the metamod plugin
PHP Code:
new g_RoundCount new g_GameState new cvar_AnnounceDMG new g_tempsc[2]; new g_Team[2]; new g_TeamRollBack[2]; new hits[33][33], dmgs[33][33], lives[33];
public plugin_init(){ RegisterHam(Ham_Spawn, "player", "PlayerHasSpawned", 1); RegisterHam( Ham_TakeDamage, "player", "HAM_TakeDamage_Post", 1 ); cvar_AnnounceDMG = register_cvar( "amx_announcedamage", "1"); register_logevent( "logevent_round_start", 2, "1=Round_Start" ); register_logevent( "event_roundend", 2, "1=Round_End" ); }
public resetScores() { for (new i = 0; i < charsmax(hits); ++i) { arrayset(hits[i], 0, charsmax(hits[])); dmgs[i] = hits[i]; } lives = hits[0]; }
public HAM_TakeDamage_Post(victim, inflictor, attacker, float:damage, damagebits){ if( !IsPlayer( attacker ) ) // make sure it's not generic damage return HAM_IGNORED; if (g_GameState == 0) return HAM_SUPERCEDE;
hits[victim][attacker]++; dmgs[victim][attacker] += floatround(damage); return HAM_IGNORED; }
public logevent_round_start() { set_task(5.0, "resetScores", _, _, _); //g_FreezeTime = false; }
public ShowDamage(id) { new message[255], username[32]; new bool:tookHit = false; copy(message, charsmax(message), "Given: ( %d Damage / %d Hits ) Taken: ( %d Damage / %d Hits) to/from ^"%s^" (%d HP)"); for (new i = 0; i < charsmax(hits[]); ++i) { if (hits[id][i] != 0 || hits[i][id] != 0) { if (i) { if (i == id) copy(username, charsmax(username), "self"); else get_user_name(i, username, charsmax(username)); } else { copy(username, charsmax(username), "Worldspawn"); } client_print(id, print_chat, message, min(dmgs[i][id],100), hits[i][id], min(dmgs[id][i],100), hits[id][i], username, lives[i]); tookHit = true; } } if (!tookHit) client_print(id, print_chat, "You didn't take any hit in the last round."); return PLUGIN_HANDLED_MAIN; }
public PlayerHasSpawned(id){ if(is_user_alive(id) && g_GameState == 0){ strip_user_weapons(id) give_item(id, "weapon_knife") give_item(id, "weapon_deagle") give_item(id, "weapon_ak47") give_item(id, "weapon_m4a1") cs_set_user_bpammo(id, CSW_AK47, 90) cs_set_user_bpammo(id, CSW_M4A1, 90) cs_set_user_bpammo(id, CSW_DEAGLE, 35) cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM) } //This is the important part. if(get_pcvar_num(cvar_AnnounceDMG) == 1 && (g_GameState !=0 && g_RoundCount >>1) ) ShowDamage(id); // ughhhhhh???
} } public logevent_round_start() { set_task(5.0, "resetScores", _, _, _); g_FreezeTime = false; }
public event_roundend() { switch ( g_GameState ) { case 0: { return(PLUGIN_HANDLED); } case 1: { for (new i = 0; i < 33; ++i) { lives[i] = get_user_health(i); } RoundEndAnnouncer(); if ( g_RoundCount >= 15 ) { LIVE_CFG(); swapteams(); /*TO-DO also have to add save frags and money and stuff. */ }
if ( g_RoundCount >= 30 ) { if ( g_Team[0] == g_Team[1] ) { OVERTIME_CFG(); g_GameState = 2; g_RoundCount = 0; swapteams(); } if ( g_Team[0] != g_Team[1] ) { EndGame(); } } } case 2: { for (new i = 0; i < 33; ++i) { lives[i] = get_user_health(i); } RoundEndAnnouncer(); if ( g_RoundCount >= 4 ) { if ( g_Team[0] == g_Team[1] ) { g_GameState = 2; g_RoundCount = 0; swapteams(); /*TO-DO */ } if ( g_Team[0] - g_Team[1] == 3 || g_Team[1] - g_Team[0] == 3 ) { EndGame(); } } } case 3: { for (new i = 0; i < 33; ++i) { lives[i] = get_user_health(i); } WARMUP_CFG(); g_GameState = 0; } default: {} } return(PLUGIN_CONTINUE); } public LIVE_CFG(){ server_cmd("various_commands INT") //This is where I execute SERVER commands like mp_freezetime etc I feel like it's irrelevant to include ( because there's like... 60 lines only of server cvars) } public WARMUP_CFG(){ server_cmd("various_commands INT") //This is where I execute SERVER commands like mp_freezetime etc I feel like it's irrelevant to include. ( because there's like... 60 lines only of server cvars) } public swapteams() { new iPlayers[32] , iNum , Player; get_players( iPlayers , iNum , "ah "); for(new i = 0 ; i < iNum ; i++ ) { Player = iPlayers[i];
if(!is_user_connected( Player ) ) return PLUGIN_CONTINUE
switch( cs_get_user_team( Player ) ) { case CS_TEAM_CT: cs_set_user_team( Player, CS_TEAM_T );
case CS_TEAM_T: cs_set_user_team( Player, CS_TEAM_CT ); } }
g_tempsc[0] = g_Team[0] g_tempsc[1] = g_Team[1] g_Team[0] = g_tempsc[1] g_Team[1] = g_tempsc[0] if(g_RoundCount == 15){ g_Team[0] = g_TeamRollBack[0] g_Team[1] = g_TeamRollBack[1] } restart_func() return PLUGIN_HANDLED } public RoundEndAnnouncer() { new iPlayers[32], Player; get_players( iPlayers, g_iMaxPlayers, "ah" ); for ( new i = 0; i < g_iMaxPlayers; i++ ) { Player = iPlayers[i]; switch ( g_UserKills[Player] ) { case 3: { if ( get_pcvar_num(cvar_AnnounceKills) >> 2 ) return(PLUGIN_CONTINUE); new PlayerName[64]; get_user_name( Player, PlayerName, 63 ); client_print_color( 0, print_team_red, "%L", LANG_PLAYER, "TRIPLE_KILL", PlayerName, g_Tag ); } case 4: { if ( get_pcvar_num(cvar_AnnounceKills) >> 1 ) return(PLUGIN_CONTINUE); new PlayerName[64]; get_user_name( Player, PlayerName, 63 ); client_print_color( 0, print_team_red, "%L", LANG_PLAYER, "QUAD_KILL", PlayerName, g_Tag ); AnnouncerSound(); } case 5: { if ( get_pcvar_num(cvar_AnnounceKills) >> 0 ) return(PLUGIN_CONTINUE); new PlayerName[64]; get_user_name( Player, PlayerName, 63 ); client_print_color( 0, print_team_red, "%L", LANG_PLAYER, "ACE_KILL", PlayerName, g_Tag ); AnnouncerSound(); } default: {} } } return(PLUGIN_HANDLED); } public glhf() { switch(g_GameState){ case 0: for (new i = 0; i<5; i++) client_print_color(0, print_team_red, "%L", LANG_PLAYER, "STATE_LIVE", g_Tag) case 1: for (new i = 0; i<5; i++) client_print_color(0, print_team_red, "%L", LANG_PLAYER, "STATE_LIVE", g_Tag) case 2: for (new i = 0; i<5; i++) client_print_color(0, print_team_red, "%L", LANG_PLAYER, "STATE_OVERTIME", g_Tag) default:{} } } /*STUPID func */ public AnnouncerSound() { client_cmd(0, ^"spk dadeda^"") } stock EndGame() { restart_func(); WARMUP_CFG() g_RoundCount = 0 for(new i=0; i<charsmax(g_Team); i++) g_Team[i] = 0 g_GameState = 0 }
I'm aware that the logic between round counting and in general the math and coding isn't perfect, which is ok because I didn't test it yet, I haven't even gotten to test it ONCE, I'll fix probably most of the bad coding in event_roundend but honestly, This is also probably more than you wanted, but here is the full code.
PHP Code:
description stat pend file vers src load unlod [ 1] AMX Mod X RUN - amxmodx_mm.dll v1.10.0. ini Start ANY [ 2] POD-Bot mm RUN - podbot_mm.dll v3.0B15c ini Chlvl ANY [ 3] CStrike RUN - cstrike_amxx.dll v1.10.0. pl1 ANY ANY [ 4] FakeMeta RUN - fakemeta_amxx.dl v1.10.0. pl1 ANY ANY [ 5] Fun RUN - fun_amxx.dll v1.10.0. pl1 ANY ANY [ 6] Engine RUN - engine_amxx.dll v1.10.0. pl1 ANY ANY [ 7] Ham Sandwich RUN - hamsandwich_amxx v1.10.0. pl1 ANY ANY
EDIT: Also, on a side-note, is it because of my round end hook, is it called too early or too late?
EDIT2: Also on another side-note, I'm also testing it only with bots on the server, I think that's important to include.
__________________
Last edited by deprale; 07-19-2021 at 10:47.
Reason: full code. + removing odd comments
|
|