diff --git a/plugins/ts/stats.sma b/plugins/ts/stats.sma index 419dabe3..56439e41 100755 --- a/plugins/ts/stats.sma +++ b/plugins/ts/stats.sma @@ -167,18 +167,18 @@ public cmdStatsMe(id){ public displayStats(id,dest) { new name[32], stats[8], body[8] get_user_wstats(id,0,stats,body) - new pos = format(g_Buffer,2047,"Kills: %d^nDeaths: %d^nTKs: %d^nDamage: %d^nHits: %d^nShots: %d^n^n", + new pos = format(g_Buffer,charsmax(g_Buffer),"Kills: %d^nDeaths: %d^nTKs: %d^nDamage: %d^nHits: %d^nShots: %d^n^n", stats[0],stats[1],stats[3],stats[6],stats[5],stats[4]) for(new a = 1; a < TSMAX_WEAPONS; ++a) { if (get_user_wstats(id,a,stats,body)){ if ( xmod_is_melee_wpn(a) ) stats[4] = -1; - xmod_get_wpnname(a,name,31) - pos += format(g_Buffer[pos],2047-pos,"%s shots: %d hits: %d damage: %d kills: %d deaths: %d^n", + xmod_get_wpnname(a,name,charsmax(name)) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s shots: %d hits: %d damage: %d kills: %d deaths: %d^n", name,stats[4],stats[5],stats[6],stats[0],stats[1]) } } - get_user_name(id,name,31) + get_user_name(id,name,charsmax(name)) show_motd(dest,g_Buffer,name) return PLUGIN_CONTINUE } @@ -193,15 +193,15 @@ public cmdRank(id){ } displayRank(id,dest) { - new name[32], stats[8], body[8] + new name[MAX_NAME_LENGTH], stats[8], body[8] new rank_pos = get_user_stats(id,stats,body) - new pos = format(g_Buffer,2047,"Kills: %d^nDeaths: %d^nTKs: %d^nDamage: %d^nHits: %d^nShots: %d^n^n", + new pos = format(g_Buffer,charsmax(g_Buffer),"Kills: %d^nDeaths: %d^nTKs: %d^nDamage: %d^nHits: %d^nShots: %d^n^n", stats[0],stats[1],stats[3],stats[6],stats[5],stats[4]) - pos += format(g_Buffer[pos],2047-pos,"Hits:^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n^n", + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"Hits:^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n^n", g_bodyParts[1],body[1],g_bodyParts[2],body[2],g_bodyParts[3],body[3], g_bodyParts[4],body[4], g_bodyParts[5],body[5],g_bodyParts[6],body[6],g_bodyParts[7],body[7]) - format(g_Buffer[pos],2047-pos,"%s rank is %d of %d",(id==dest)?"Your":"His", rank_pos,get_statsnum()) - get_user_name(id,name,31) + format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s rank is %d of %d",(id==dest)?"Your":"His", rank_pos,get_statsnum()) + get_user_name(id,name,charsmax(name)) show_motd(dest,g_Buffer,name) } @@ -218,14 +218,14 @@ public cmdTop15(id) { /* get top 15 */ getTop15(){ new stats[8], body[8], name[MAX_NAME_LENGTH] - new pos = copy(g_Buffer,2047,"# nick kills/deaths TKs hits/shots/headshots^n") + new pos = copy(g_Buffer,charsmax(g_Buffer),"# nick kills/deaths TKs hits/shots/headshots^n") new imax = get_statsnum() if (imax > 15) imax = 15 for(new a = 0; a < imax; ++a){ - get_stats(a,stats,body,name,31) - replace_all(name, 31, "<", "[") - replace_all(name, 31, ">", "]") - pos += format(g_Buffer[pos],2047-pos,"%2d. %-28.27s %d/%d %d %d/%d/%d^n",a+1,name,stats[0],stats[1],stats[3],stats[5],stats[4],stats[2]) + get_stats(a,stats,body,name,charsmax(name)) + replace_all(name, charsmax(name), "<", "[") + replace_all(name, charsmax(name), ">", "]") + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%2d. %-28.27s %d/%d %d %d/%d/%d^n",a+1,name,stats[0],stats[1],stats[3],stats[5],stats[4],stats[2]) } } @@ -261,16 +261,16 @@ public cmdStats(id){ /* build list of attackers */ getAttackers(id) { new name[MAX_NAME_LENGTH],wpn[32], stats[8],body[8],found=0 - new pos = copy(g_Buffer,2047,"Attackers:^n") + new pos = copy(g_Buffer,charsmax(g_Buffer),"Attackers:^n") for(new a = 1; a <= MaxClients; ++a){ - if(get_user_astats(id,a,stats,body,wpn,31)){ + if(get_user_astats(id,a,stats,body,wpn,charsmax(wpn))){ found = 1 if (stats[0]) - format(wpn,31," -- %s",wpn) + format(wpn,charsmax(wpn)," -- %s",wpn) else wpn[0] = 0 - get_user_name(a,name,31) - pos += format(g_Buffer[pos],2047-pos,"%s -- %d dmg / %d hit(s)%s^n",name,stats[6],stats[5],wpn) + get_user_name(a,name,charsmax(name)) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s -- %d dmg / %d hit(s)%s^n",name,stats[6],stats[5],wpn) } } return found @@ -279,16 +279,16 @@ getAttackers(id) { /* build list of victims */ getVictims(id) { new name[MAX_NAME_LENGTH],wpn[32], stats[8],body[8],found=0 - new pos = copy(g_Buffer,2047,"Victims:^n") + new pos = copy(g_Buffer,charsmax(g_Buffer),"Victims:^n") for(new a = 1; a <= MaxClients; ++a){ - if(get_user_vstats(id,a,stats,body,wpn,31)){ + if(get_user_vstats(id,a,stats,body,wpn,charsmax(wpn))){ found = 1 if (stats[1]) - format(wpn,31," -- %s",wpn) + format(wpn,charsmax(wpn)," -- %s",wpn) else wpn[0] = 0 - get_user_name(a,name,31) - pos += format(g_Buffer[pos],2047-pos,"%s -- %d dmg / %d hit(s)%s^n",name,stats[6],stats[5],wpn) + get_user_name(a,name,charsmax(name)) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s -- %d dmg / %d hit(s)%s^n",name,stats[6],stats[5],wpn) } } return found @@ -299,22 +299,22 @@ getHits(id,killer) { new stats[8], body[8], pos = 0 g_Buffer[0] = 0 get_user_astats(id,killer,stats,body) - for(new a = 1; a < 8; ++a) + for(new a = 1; a < sizeof(body); ++a) if(body[a]) - pos += format(g_Buffer[pos],2047-pos,"%s: %d^n",g_bodyParts[a],body[a]) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s: %d^n",g_bodyParts[a],body[a]) } /* build list of hits for say hp */ getMyHits(id,killed) { new name[MAX_NAME_LENGTH], stats[8], body[8], found = 0 - get_user_name(killed,name,31) - new pos = format(g_Buffer,2047,"You hit %s in:",name) + get_user_name(killed,name,charsmax(name)) + new pos = format(g_Buffer,charsmax(g_Buffer),"You hit %s in:",name) get_user_vstats(id,killed,stats,body) - for(new a = 1; a < 8; ++a){ + for(new a = 1; a < sizeof(body); ++a){ if(body[a]){ found = 1 - pos += format(g_Buffer[pos],2047-pos," %s: %d ",g_bodyParts[a],body[a]) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos," %s: %d ",g_bodyParts[a],body[a]) } } return found @@ -324,7 +324,7 @@ public client_damage(attacker,victim,damage,wpnindex,hitplace,TA) { if ( TA ){ if ( TAInfo && is_user_alive(victim) ){ new attacker_name[MAX_NAME_LENGTH] - get_user_name(attacker,attacker_name,31) + get_user_name(attacker,attacker_name,charsmax(attacker_name)) client_print(0,print_chat,"%s attacked a teammate",attacker_name) } return PLUGIN_CONTINUE @@ -341,7 +341,7 @@ public client_damage(attacker,victim,damage,wpnindex,hitplace,TA) { public client_death(killer,victim,wpnindex,hitplace,TK){ new killer_name[MAX_NAME_LENGTH] - get_user_name(killer,killer_name,31) + get_user_name(killer,killer_name,charsmax(killer_name)) if ( TK ){ if ( TAInfo ){ @@ -355,7 +355,7 @@ public client_death(killer,victim,wpnindex,hitplace,TK){ new headshot = ( hitplace == HIT_HEAD ) ? 1:0 new victim_name[MAX_NAME_LENGTH] - get_user_name(victim,victim_name,31) + get_user_name(victim,victim_name,charsmax(victim_name)) if ( killer == victim ){ if ( grenade && GrenadeSuicide ){ @@ -390,11 +390,11 @@ public client_death(killer,victim,wpnindex,hitplace,TK){ else if ( headshot && (HeadShotKill || HeadShotKillSound) && !xmod_is_melee_wpn(wpnindex) ){ if ( HeadShotKill ){ new weapon[32], message[256] - xmod_get_wpnname(wpnindex,weapon,31) - copy( message, sizeof(message)-1, g_HeadShots[ random_num(0,6) ] ) - replace( message, sizeof(message)-1, "$vn", victim_name ) - replace( message, sizeof(message)-1 , "$wn", weapon ) - replace( message, sizeof(message)-1, "$kn", killer_name ) + xmod_get_wpnname(wpnindex,weapon,charsmax(weapon)) + copy( message, charsmax(message), g_HeadShots[ random_num(0,6) ] ) + replace( message, charsmax(message), "$vn", victim_name ) + replace( message, charsmax(message), "$wn", weapon ) + replace( message, charsmax(message), "$kn", killer_name ) set_hudmessage(100, 100, 255, -1.0, 0.29, 0, 6.0, 6.0, 0.5, 0.15, -1) for (new i=1;i<=MaxClients;i++){ if ( g_Killers[i][0] && g_DeathStats[i] > get_gametime() ) @@ -420,26 +420,26 @@ public client_death(killer,victim,wpnindex,hitplace,TK){ if ( FragInfo ){ new kmsg[128] - new pos = format(kmsg,63,"LastKill: %d frag(s)^n",ts_getuserlastfrag(killer)) + new pos = format(kmsg,charsmax(kmsg),"LastKill: %d frag(s)^n",ts_getuserlastfrag(killer)) if ( killFlags ){ - pos += format(kmsg[pos],128-pos,"[") + pos += format(kmsg[pos],charsmax(kmsg)-pos,"[") if ( killFlags & TSKF_STUNTKILL ) - pos += format(kmsg[pos],128-pos," stunt ") + pos += format(kmsg[pos],charsmax(kmsg)-pos," stunt ") if ( killFlags & TSKF_SLIDINGKILL ) - pos += format(kmsg[pos],128-pos," sliding ") + pos += format(kmsg[pos],charsmax(kmsg)-pos," sliding ") if ( killFlags & TSKF_DOUBLEKILL ) - pos += format(kmsg[pos],128-pos," double ") + pos += format(kmsg[pos],charsmax(kmsg)-pos," double ") if ( killFlags & TSKF_ISSPEC ) - pos += format(kmsg[pos],128-pos," spec ") + pos += format(kmsg[pos],charsmax(kmsg)-pos," spec ") if ( killFlags & TSKF_KILLEDSPEC ) - pos += format(kmsg[pos],128-pos," kspec ") + pos += format(kmsg[pos],charsmax(kmsg)-pos," kspec ") - pos += format(kmsg[pos],128-pos,"]") + pos += format(kmsg[pos],charsmax(kmsg)-pos,"]") } set_hudmessage(255,255,255,0.02,0.85,2, 1.5, 3.0, 0.02, 5.0, -1) show_hudmessage(killer, "%s", kmsg) @@ -450,9 +450,9 @@ public client_death(killer,victim,wpnindex,hitplace,TK){ DisplayKillInfo(victim){ if ( ShowKiller ){ - new name[MAX_NAME_LENGTH], stats[8], body[8], wpn[33], mstats[8], mbody[8] - get_user_name(g_Killers[victim][0],name,31) - get_user_astats(victim,g_Killers[victim][0],stats,body,wpn,31) + new name[MAX_NAME_LENGTH], stats[8], body[8], wpn[32], mstats[8], mbody[8] + get_user_name(g_Killers[victim][0],name,charsmax(name)) + get_user_astats(victim,g_Killers[victim][0],stats,body,wpn,charsmax(wpn)) get_user_vstats(victim,g_Killers[victim][0],mstats,mbody) set_hudmessage(220,80,0,0.05,0.15,0, 6.0, 12.0, 1.0, 2.0, -1) getHits(victim,g_Killers[victim][0]) @@ -476,8 +476,8 @@ DisplayAVList(victim){ DisplayKillerHp(victim,con){ if ( KillerHp ){ new name[MAX_NAME_LENGTH], kmsg[128] - get_user_name(g_Killers[victim][0],name,31) - format(kmsg,127,"%s still has %dhp",name,g_Killers[victim][1]) + get_user_name(g_Killers[victim][0],name,charsmax(name)) + format(kmsg,charsmax(kmsg),"%s still has %dhp",name,g_Killers[victim][1]) if ( con ) client_print(victim,print_console, "%s", kmsg) set_hudmessage(255,255,255,0.02,0.9,2, 1.5, 3.0, 0.02, 5.0, -1) show_hudmessage(victim, "%s", kmsg) @@ -503,9 +503,9 @@ public cmdKiller(id) { return PLUGIN_HANDLED } if (g_Killers[id][0]) { - new name[MAX_NAME_LENGTH], stats[8], body[8], wpn[33], mstats[8], mbody[8] - get_user_name(g_Killers[id][0],name,31) - get_user_astats(id,g_Killers[id][0],stats,body,wpn,31) + new name[MAX_NAME_LENGTH], stats[8], body[8], wpn[32], mstats[8], mbody[8] + get_user_name(g_Killers[id][0],name,charsmax(name)) + get_user_astats(id,g_Killers[id][0],stats,body,wpn,charsmax(wpn)) get_user_vstats(id,g_Killers[id][0],mstats,mbody) client_print(id,print_chat,"%s killed you with %s from distance of %.2f meters", name,wpn,float(g_Killers[id][2]) * 0.0254 ) client_print(id,print_chat,"He did %d damage to you with %d hit(s) and still had %dhp", @@ -547,20 +547,20 @@ showStatsMenu(id,pos){ new menu_body[512], inum, k = 0, start = pos * MAX_MENUPOS get_players(g_userPlayers[id],inum) if (start >= inum) start = pos = g_userPosition[id] = 0 - new len = format(menu_body,511,"Server Stats %d/%d^n^n",pos + 1,((inum/MAX_MENUPOS)+((inum%MAX_MENUPOS)?1:0))) + new len = format(menu_body,charsmax(menu_body),"Server Stats %d/%d^n^n",pos + 1,((inum/MAX_MENUPOS)+((inum%MAX_MENUPOS)?1:0))) new name[MAX_NAME_LENGTH], end = start + MAX_MENUPOS, keys = (1<<9)|(1<<7) if (end > inum) end = inum for(new a = start; a < end; ++a){ - get_user_name(g_userPlayers[id][a],name,31) + get_user_name(g_userPlayers[id][a],name,charsmax(name)) keys |= (1<