Код
/***************************************************
This plugin is to test if players' have set 32-bit.
Multiple pictures are show to each player and he or she needs to
choose proper one (in menu). If player does not choose properly
after X tries he or she is disconnected. Pictures are show after
the player dies, not to disturb the gameplay.
Number of tries can be configured by cvar:
32bit_tries 2 (default)
Plugin is using "data/lang/32bit_test.txt" language file.
***************************************************/
#include <amxmodx>
#include <amxmisc>
#define TASKID 18923
new motd[2000];
new szczegoly_testu[33][3];
new tested[33];
new prob[33];
new pcvar_tested32bit[33];
new pcvar_tries;
public plugin_init()
{
register_plugin("32-bit test","1.2","Czesio");
register_dictionary("32bit_test.txt");
register_event("DeathMsg", "death_msg", "a");
pcvar_tries = register_cvar("32bit_tries", "2");
new tmp[16]
for(new i=1; i<33; i++){
formatex(tmp,15,"tested32bit_%d",i);
pcvar_tested32bit[i] = register_cvar(tmp,"0");
tested[i] = get_pcvar_num(pcvar_tested32bit[i]);
}
register_menucmd(register_menuid("menu_a"), 511, "menu_a_handler");
register_menucmd(register_menuid("menu_b"), 511, "menu_b_handler");
register_menucmd(register_menuid("menu_c"), 511, "menu_c_handler");
motd = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd'><html><head><style type='text/css'>body{background:black;font-family:Arial;color:#fff;text-align:center;margin:0;padding:0}table{margin:0 auto}th,td{font-weight:bold;padding-top:4px}b,u{display:inline-block;width:16px;height:48px;maring:0}td b{background:#808080}td u{background:#7f7f7f}th b{background:#878787}th u{background:#787878}</style></head>";
strcat(motd,"<body><table cellpadding='0' cellspacing='5'><tr><td>A1<br><b></b><u></u><b></b></td><td>A2<br><b></b><u></u><b></b></td><td>A3<br><b></b><u></u><b></b></td><td>A4<br><b></b><u></u><b></b></td><td>A5<br><b></b><u></u><b></b></td><td>A6<br><b></b><u></u><b></b></td><td>A7<br><b></b><u></u><b></b></td><td>A8<br><b></b><u></u><b></b></td></tr>",1999);
strcat(motd,"<tr><td>B1<br><b></b><u></u><b></b></td><td>B2<br><b></b><u></u><b></b></td><td>B3<br><b></b><u></u><b></b></td><td>B4<br><b></b><u></u><b></b></td><td>B5<br><b></b><u></u><b></b></td><td>B6<br><b></b><u></u><b></b></td><td>B7<br><b></b><u></u><b></b></td><td>B8<br><b></b><u></u><b></b></td></tr>",1999);
strcat(motd,"<tr><td>C1<br><b></b><u></u><b></b></td><td>C2<br><b></b><u></u><b></b></td><td>C3<br><b></b><u></u><b></b></td><td>C4<br><b></b><u></u><b></b></td><td>C5<br><b></b><u></u><b></b></td><td>C6<br><b></b><u></u><b></b></td><td>C7<br><b></b><u></u><b></b></td><td>C8<br><b></b><u></u><b></b></td></tr></table></body></html>",1999);
return PLUGIN_CONTINUE;
}
public client_connect(id){
prob[id] = 0;
}
public death_msg(){
new victim = read_data(2);
set_task(2.0,"testuj_gracza", victim + TASKID);
return PLUGIN_HANDLED;
}
public testuj_gracza(id){
id -= TASKID;
if(is_user_connected(id) && !is_user_bot(id) && !is_user_hltv(id) && tested[id] != get_user_userid(id)){
prob[id]++;
if(prob[id] > get_pcvar_num(pcvar_tries)){
nieudana_proba(id);
}
else{
szczegoly_testu[id][0] = random(8) + 1;
szczegoly_testu[id][1] = random(8) + 1;
szczegoly_testu[id][2] = random(8) + 1;
pokaz_menu_a(id);
pokaz_motd(id);
}
}
}
public nieudana_proba(id){
if(prob[id] >= get_pcvar_num(pcvar_tries)){
server_cmd("kick #%d 16-bit video", get_user_userid(id));
}
else{
if(get_pcvar_num(pcvar_tries) - prob[id] == 1)
client_print(id,print_chat,"%L",LANG_PLAYER,"TEST_BAD_1_TRY_LEFT",get_pcvar_num(pcvar_tries) - prob[id]);
else
client_print(id,print_chat,"%L",LANG_PLAYER,"TEST_BAD",get_pcvar_num(pcvar_tries) - prob[id]);
}
}
public menu_a_handler(id,key){
key++;
if(key == 9){
pokaz_menu_a(id);
pokaz_motd(id);
}
else if(key == szczegoly_testu[id][0])
pokaz_menu_b(id);
else
nieudana_proba(id);
}
public menu_b_handler(id,key){
key++;
if(key == 9){
pokaz_menu_b(id);
pokaz_motd(id);
}
else if(key == szczegoly_testu[id][1])
pokaz_menu_c(id);
else
nieudana_proba(id);
}
public menu_c_handler(id,key){
key++;
if(key == 9){
pokaz_menu_c(id);
pokaz_motd(id);
}
else if(key == szczegoly_testu[id][2]){
tested[id] = get_user_userid(id);
set_pcvar_num(pcvar_tested32bit[id], tested[id]);
client_print(id,print_chat,"%L",LANG_PLAYER,"TEST_OK");
}
else
nieudana_proba(id);
}
public pokaz_menu_a(id){
new menu_body[1000]
formatex(menu_body, 999, "\w%L^n^n\w1. A1^n\w2. A2^n\w3.\w A3^n\w4.\w A4^n\w5.\w A5^n\w6.\w A6^n\w7.\w A7^n\w8.\w A8^n\w9. %L", id, "INFO", id, "SHOW_AGAIN");
show_menu(id, 511, menu_body, -1, "menu_a");
}
public pokaz_menu_b(id){
new menu_body[1000]
formatex(menu_body, 999, "\w%L^n^n\w1. B1^n\w2. B2^n\w3.\w B3^n\w4.\w B4^n\w5.\w B5^n\w6.\w B6^n\w7.\w B7^n\w8.\w B8^n\w9. %L", id, "INFO", id, "SHOW_AGAIN");
show_menu(id, 511, menu_body, -1, "menu_b");
}
public pokaz_menu_c(id){
new menu_body[1000]
formatex(menu_body, 999, "\w%L^n^n\w1. C1^n\w2. C2^n\w3.\w C3^n\w4.\w C4^n\w5.\w C5^n\w6.\w C6^n\w7.\w C7^n\w8.\w C8^n\w9. %L", id, "INFO", id, "SHOW_AGAIN");
show_menu(id, 511, menu_body, -1, "menu_c");
}
public pokaz_motd(id){
new temp_motd[2000];
new find_a[50];
new find_b[50];
new find_c[50];
new replace_a[50];
new replace_b[50];
new replace_c[50];
copy(temp_motd,1999,motd);
formatex(find_a,49,"<td>A%d<br><b></b><u></u><b></b></td>",szczegoly_testu[id][0]);
formatex(find_b,49,"<td>B%d<br><b></b><u></u><b></b></td>",szczegoly_testu[id][1]);
formatex(find_c,49,"<td>C%d<br><b></b><u></u><b></b></td>",szczegoly_testu[id][2]);
formatex(replace_a,49,"<th>A%d<br><b></b><u></u><b></b></th>",szczegoly_testu[id][0]);
formatex(replace_b,49,"<th>B%d<br><b></b><u></u><b></b></th>",szczegoly_testu[id][1]);
formatex(replace_c,49,"<th>C%d<br><b></b><u></u><b></b></th>",szczegoly_testu[id][2]);
replace(temp_motd,1999,find_a,replace_a);
replace(temp_motd,1999,find_b,replace_b);
replace(temp_motd,1999,find_c,replace_c);
show_motd(id,temp_motd,"!!! Choose the one that differs");
}