#include "Content\\ShellScripts\\stddefs.h" #include "Content\\ShellScripts\\listboxes.script" #include "Content\\ShellScripts\\mc_listboxes.script" #include "Content\\ShellScripts\\buttons.script" #include "Content\\ShellScripts\\common_shell.script" #include "Content\\ShellScripts\\ShellFunctionHeaders.hpp" main { GUI_CREATE { font3d gFont3d = FPATH "verdana10reg.d3f" pane background = GPATH "serverstatbackground.tga" object i_cursor=s_cursor object mbutton[5] mbutton[0] = s_text3dglowbutton mbutton[0].textcolor = 0xffffffff mbutton[0].textsize = 1 mbutton[0].id = 0 mbutton[0].text = "Verbose" mbutton[0].location = 300 - (mbutton[0].twidth/2), 4, 5 mbutton[0].twidth = 60 mbutton[0].region = 0,0 to 75,20 mbutton[1] = s_text3dglowbutton mbutton[1].textcolor = 0xffffffff mbutton[1].textsize = 1 mbutton[1].id = 1 mbutton[1].location = 380 - (mbutton[1].twidth/2), 4, 5 mbutton[1].text = "Small" mbutton[1].twidth = 60 mbutton[1].region = 0,0 to 75,20 int first_half = true mbutton[2] = s_text3dglowbutton mbutton[2].textcolor = 0xffffffff mbutton[2].textsize = 1 mbutton[2].id = 1 mbutton[2].location = 480 - (mbutton[1].twidth/2), 4, 5 mbutton[2].text = "0-15" mbutton[2].twidth = 60 mbutton[2].region = 0,0 to 75,20 mbutton[3] = s_text3dglowbutton mbutton[3].textcolor = 0xffffffff mbutton[3].textsize = 1 mbutton[3].id = 1 mbutton[3].location = 560 - (mbutton[1].twidth/2), 4, 5 mbutton[3].text = "16-31" mbutton[3].twidth = 60 mbutton[3].region = 0,0 to 75,20 mbutton[4] = s_text3dglowbutton mbutton[4].textcolor = 0xffffffff mbutton[4].textsize = 1 mbutton[4].id = 1 mbutton[4].location = 720 - (mbutton[1].twidth/2), 50, 5 mbutton[4].text = "Exit" mbutton[4].twidth = 140 mbutton[4].region = 0,0 to 75,20 object o_draw_object = drawtimer focus(o_draw_object) } GUI_MAILBOX { if (sender == mbutton[0]) { o_draw_object.draw_mode = 0 } if (sender == mbutton[1]) { o_draw_object.draw_mode = 1 } if (sender == mbutton[2]) { first_half = true } if (sender == mbutton[3]) { first_half = false } if (sender == mbutton[4]) { callback($$Shell_CallbackHandler$$, ShellExitDedicatedServer) unfocus //script_end "ServerStat.script" } } } drawtimer { GUI_CREATE { int draw_mode = 0 int draw_count = 0 string game_name string mission_name callback($$GetCurrentMissionName$$,mission_name) callback($$GetCurrentGameName$$,game_name) int color_count = 16 int color_chart[color_count] color_chart[0] = 0xffe59b18 color_chart[1] = 0xfffbda38 color_chart[2] = 0xff2e1ad1 color_chart[3] = 0xffe40d11 color_chart[4] = 0xffacfdf8 color_chart[5] = 0xff299b38 color_chart[6] = 0xffe5c06a color_chart[7] = 0xffb89ad0 color_chart[8] = 0xffffafaf color_chart[9] = 0xff8000ff color_chart[10] = 0xff98e11e color_chart[11] = 0xffff80c0 color_chart[12] = 0xffacfdf8 color_chart[13] = 0xff299b38 color_chart[14] = 0xffe5c06a color_chart[15] = 0xffb89ad0 int stat_count stat_count = callback($$GetStatisticsCount$$) int server_player = -1 } GUI_DRAW { int dirty = callback($$ServerStatsDirty$$) if (dirty) { if (draw_count == 0) draw_count = 3 } //we have to draw every frame if (draw_count) { draw_count-- if (draw_mode == 0) { //---------------------------------------- // Draw the background //---------------------------------------- location = 0,0,-10 render background,location //---------------------------------------- // Calculate the drawing scale //---------------------------------------- int server_max_bps = callback($$ServerStatsScale$$) int client_max_bps = callback($$ClientStatsScale$$) //---------------------------------------- // Draw the GameName //---------------------------------------- print3d_attributes = gFont3d, 0xfffe8000, 1,0,1,0,0 print3d_position = 15,7 print3d "GameName : " print3d_attributes = gFont3d, 0xff00fe00, 1,0,1,0,0 print3d_position = 80,7 print3d game_name print3d_attributes = gFont3d, 0xfffe8000, 1,0,1,0,0 print3d_position = 175,7 print3d "Mission : " print3d_attributes = gFont3d, 0xff00fe00, 1,0,1,0,0 print3d_position = 215,7 print3d mission_name //---------------------------------------- // Draw the Time //---------------------------------------- string time callback($$GetGameTime$$,time) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 640,7 print3d time callback($$GetRealTime$$,time) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 690,7 print3d time callback($$GetRealDate$$,time) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 750,7 print3d time //---------------------------------------- // Draw the Stat Bars //---------------------------------------- int i int j int valid_player string player_name string temp_name int x int y int x2 int y2 x = 10 y = 45 x2 = 640 y2 = y+35 //---------------------------------------- // Draw the Server Bar //---------------------------------------- //make a frame //in background //setpencolor(0xffffffff) //drawrect x,y to x2,y2 x = x+1 y = y+1 x2 = x2-1 y2 = y2-1 //in background //setpencolor(0xff000000) //drawrect x,y to x2,y2 int total_server_bps = 0 int bps float percentage_of_total int temp string kbps_text //---------------------------------------- // Draw the Server Bar Stats //---------------------------------------- for (i = 0; i < stat_count; i++) { bps = callback($$GetStatisticbps$$,i,server_player) total_server_bps = total_server_bps + bps percentage_of_total = bps / server_max_bps if (bps > 0) { percentage_of_total = 630.0 * percentage_of_total x2 = x + percentage_of_total setpencolor(color_chart[i]) drawrect x,y to x2,y2 x = x2 } } //---------------------------------------- // Draw the Server Bar Numbers //---------------------------------------- bps = callback($$GetPlayersbps$$,server_player) kbps_text = conv$(bps) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 645, 45 print3d kbps_text bps = callback($$GetPlayersOutgoingPacketsPerSecond$$,server_player) kbps_text = conv$(bps) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 645, 57 print3d kbps_text bps = callback($$GetPlayersIncommingPacketsPerSecond$$,server_player) kbps_text = conv$(bps) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 645, 69 print3d kbps_text //---------------------------------------- // Draw the Client Scale and Server Scale //---------------------------------------- kbps_text = conv$(server_max_bps) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 605, 33 print3d kbps_text kbps_text = conv$(client_max_bps) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 605, 98 print3d kbps_text //---------------------------------------- // Draw the Players //---------------------------------------- int player_count = callback($$GetPlayerCount$$) int offset_index = 0 int real_player_count = 0 int draw_half = true for(i=0;i= 16) draw_half = true else draw_half = false offset_index = real_player_count - 15 } if (draw_half) { //---------------------------------------- // Draw the player boxes //---------------------------------------- x = 75 y = 110 + (offset_index * 25) x2 = 640 y2 = y + 22 //in background //setpencolor(0xffffffff) //drawrect x,y to x2,y2 x = x+1 y = y+1 x2 = x2-1 y2 = y2-1 //in background //setpencolor(0xff000000) //drawrect x,y to x2,y2 //---------------------------------------- // Draw the player name //---------------------------------------- valid_player = callback($$IsPlayerValid$$,i) if (valid_player) { callback($$GetPlayerName$$,i,temp_name) player_name = conv$(i) ":" temp_name print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 5, y+1 print3d player_name //---------------------------------------- // Draw the Player Bar Stats //---------------------------------------- for (j = 0; j < stat_count; j++) { bps = callback($$GetStatisticbps$$,j,i) percentage_of_total = bps / client_max_bps if (bps > 0) { percentage_of_total = 565.0 * percentage_of_total x2 = x + percentage_of_total setpencolor(color_chart[j]) drawrect x,y to x2,y2 x = x2 } } // draw the player numbers.... bps = callback($$GetPlayersbps$$,i) kbps_text = conv$(bps) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 645,y+2 print3d kbps_text bps = callback($$GetPlayerPing$$,i) kbps_text = conv$(bps) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 700,y+2 print3d kbps_text bps = callback($$GetPlayersIncommingPacketsPerSecond$$,i) kbps_text = conv$(bps) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 750,y+2 print3d kbps_text bps = callback($$GetPlayersOutgoingPacketsPerSecond$$,i) kbps_text = conv$(bps) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 775,y+2 print3d kbps_text real_player_count++ } } } //---------------------------------------- // Draw the Bottom Statistic Chart //---------------------------------------- int current_stat int row int column string stat_name int bps_text float percentage for (column = 0; column < 4; column++) { for (row = 0; row < 4; row++) { if (current_stat < stat_count) { callback($$GetStatisticName$$,current_stat,stat_name) setpencolor(color_chart[current_stat]) x = 10 + (column * 200) y = 520 + (row * 20) x2 = x + 15 y2 = y + 15 drawrect x,y to x2,y2 x = x + 17 y = y + 3 print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = x,y print3d stat_name //------------------------------------ // print stat kbps //------------------------------------ bps = callback($$GetStatisticbps$$,current_stat,server_player) x = x + 65 kbps_text = conv$(bps) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = x,y print3d kbps_text // figure out the percentage... if (total_server_bps != 0) { percentage = bps / total_server_bps percentage = percentage * 100 } else { percentage = 0 } x = x + 60 kbps_text = conv$(percentage) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = x,y print3d kbps_text } else { stat_name = "-------" setpencolor(0xff646464) x = 10 + (column * 200) y = 520 + (row * 20) x2 = x + 15 y2 = y + 15 drawrect x,y to x2,y2 x = x + 17 y = y + 3 print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = x,y print3d stat_name //------------------------------------ // print stat kbps //------------------------------------ bps = callback($$GetStatisticbps$$,current_stat,server_player) x = x + 65 kbps_text = "0" print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = x,y print3d kbps_text x = x + 60 kbps_text = "0" print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = x,y print3d kbps_text } current_stat++ } } callback($$ServerCleanDirtyFlag$$) } //if (draw_mode == 1) else { setpencolor(0xff000000) drawrect 0,0 to 800,600 //---------------------------------------- // Draw the GameName //---------------------------------------- print3d_attributes = gFont3d, 0xfffe8000, 1,0,1,0,0 print3d_position = 15,7 print3d "GameName : " print3d_attributes = gFont3d, 0xff00fe00, 1,0,1,0,0 print3d_position = 80,7 print3d game_name print3d_attributes = gFont3d, 0xfffe8000, 1,0,1,0,0 print3d_position = 175,7 print3d "Mission : " print3d_attributes = gFont3d, 0xff00fe00, 1,0,1,0,0 print3d_position = 215,7 print3d mission_name //---------------------------------------- // Draw the Time //---------------------------------------- string time callback($$GetGameTime$$,time) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 640,7 print3d time callback($$GetRealTime$$,time) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 690,7 print3d time callback($$GetRealDate$$,time) print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 print3d_position = 750,7 print3d time //---------------------------------------- // Draw the labels //---------------------------------------- print3d_attributes = gFont3d, 0xffffffff, 1,0,1,0,0 int name_x = 5 int pps_in_x = 100 int pps_out_x = 150 int header_in_x = 200 int header_out_x = 250 int packet_in_x = 300 int packet_out_x = 350 int total_in_x = 400 int total_out_x = 450 int total_all_x = 500 int current_y = 100 print3d_position = name_x,current_y print3d "Name" print3d_position = pps_in_x,current_y print3d "I-PPS" print3d_position = pps_out_x,current_y print3d "O-PPS" print3d_position = header_in_x,current_y print3d "I-HDR" print3d_position = header_out_x,current_y print3d "0-HDR" print3d_position = packet_in_x,current_y print3d "I-DATA" print3d_position = packet_out_x,current_y print3d "O-DATA" print3d_position = total_in_x,current_y print3d "I-TOTAL" print3d_position = total_out_x,current_y print3d "O-TOTAL" print3d_position = total_all_x,current_y print3d "A-TOTAL" int header_in_stat = 0 int header_out_stat = 1 int total_data_in_stat = stat_count+2 int total_data_out_stat = stat_count+3 current_y += 20 //---------------------------------------- // Draw the Server Numbers //---------------------------------------- string text_temp int temp print3d_position = name_x, current_y print3d "Server" int total_in = 0 int total_out = 0 int total = 0 temp = callback($$GetPlayersIncommingPacketsPerSecond$$,server_player) text_temp = conv$(temp) print3d_position = pps_in_x, current_y print3d text_temp temp = callback($$GetPlayersOutgoingPacketsPerSecond$$,server_player) text_temp = conv$(temp) print3d_position = pps_out_x, current_y print3d text_temp temp = callback($$GetStatisticbps$$,header_in_stat,server_player) text_temp = conv$(temp) print3d_position = header_in_x, current_y print3d text_temp total_in += temp temp = callback($$GetStatisticbps$$,header_out_stat,server_player) text_temp = conv$(temp) print3d_position = header_out_x, current_y print3d text_temp total_out += temp temp = callback($$GetStatisticbps$$,total_data_in_stat,server_player) text_temp = conv$(temp) print3d_position = packet_in_x, current_y print3d text_temp total_in += temp temp = callback($$GetStatisticbps$$,total_data_out_stat,server_player) text_temp = conv$(temp) print3d_position = packet_out_x, current_y print3d text_temp total_out += temp total = total_in + total_out text_temp = conv$(total_in) print3d_position = total_in_x, current_y print3d text_temp text_temp = conv$(total_out) print3d_position = total_out_x, current_y print3d text_temp text_temp = conv$(total) print3d_position = total_all_x, current_y print3d text_temp current_y += 20 //---------------------------------------- // Draw the Player Numbers //---------------------------------------- int i int player_count = callback($$GetPlayerCount$$) int real_player_count = 0 string player_name int valid_player int offset_index = 0 int draw_half = true for(i=0;i= 16) draw_half = true else draw_half = false offset_index = real_player_count - 15 } if (draw_half) { valid_player = callback($$IsPlayerValid$$,i) if (valid_player) { callback($$GetPlayerName$$,i,text_temp) player_name = conv$(i) ":" text_temp print3d_position = name_x, current_y print3d player_name if (valid_player) { total_in = 0 total_out = 0 total = 0 temp = callback($$GetPlayersIncommingPacketsPerSecond$$,i) text_temp = conv$(temp) print3d_position = pps_in_x, current_y print3d text_temp temp = callback($$GetPlayersOutgoingPacketsPerSecond$$,i) text_temp = conv$(temp) print3d_position = pps_out_x, current_y print3d text_temp temp = callback($$GetStatisticbps$$,header_in_stat,i) text_temp = conv$(temp) print3d_position = header_in_x, current_y print3d text_temp total_in += temp temp = callback($$GetStatisticbps$$,header_out_stat,i) text_temp = conv$(temp) print3d_position = header_out_x, current_y print3d text_temp total_out += temp temp = callback($$GetStatisticbps$$,total_data_in_stat,i) text_temp = conv$(temp) print3d_position = packet_in_x, current_y print3d text_temp total_in += temp temp = callback($$GetStatisticbps$$,total_data_out_stat,i) text_temp = conv$(temp) print3d_position = packet_out_x, current_y print3d text_temp total_out += temp total = total_in + total_out text_temp = conv$(total_in) print3d_position = total_in_x, current_y print3d text_temp text_temp = conv$(total_out) print3d_position = total_out_x, current_y print3d text_temp text_temp = conv$(total) print3d_position = total_all_x, current_y print3d text_temp } current_y += 20 } } real_player_count++ } } // else if (draw_mode == 0) } // if (draw_count) }//GUI DRAW }//object s_cursor { GUI_CREATE { pane p_pointer = GPATH "mouse_pointer.tga" alphamode(p_pointer) = am_alpha_alphainvalpha origin(p_pointer) = 0, 0 location.z = 255 } GUI_DRAW { render p_pointer, mouse.x, mouse.y } }