| daffy4jr |
05-17-2007 08:58 |
vote system
hello,
I am trying to get vote system to work on my MOD which is MS:C (Mastersword Continued)
I have posted in support and realized it is not the best place to post for scripting.
http://forums.alliedmods.net/showthread.php?t=55101
I am trying to get rid of adminvote.amxx now since it doesn't work well with my MOD.
A friend of mine gave me this script for the MSC and trying to make it work with the MOD. I have been getting a lot of errors when I try to compile it.
Could you guys help me please?
the code is below.
Code:
/*
===========================================================
Adminvote for MSC by Thothie, aka "Eff this, I'll do it myself"
FUNCTIONS/FEATURES:
- Starts a vote for an adjacent map when all players touch transition
- Allows individual players to start votes for adjacent maps when they touch a transition (optional-pending)
- Allows voting for some or all MSC maps at various levels of restritiveness based on current location
- Allows voting for a list of custom maps
- Allows admins to force a vote for any map
- Allows voting to kick/ban AFK/annoying players
- Allows voting to activate/deactivate PVP mode
- Compensates for MSC key-code weirdness
- Intercepts forced change map events from MSC, allowing mappers to bypass potential crashes
- Allows MSC NPC's or events to start votes for maps via scripts or map events
- Automatically turns PVP on before going to any map prefixed with PVP_
- Integrates with Stevelafl's crash recovery system, writing to the crash.cfg before map change
- Log options for chat and for developers
COMMANDS
- votemap: In chat or console, opens vote menu (lists maps)
- votemap [map]: In chat or console, votes for specific map, if allowed (returns feedback)
- votekick [player]: In chat or console, starts a vote to kick a player (req > 2 players)
- voteban [player]: In chat or console, starts a vote to ban a player for 1 hour (req > 2 players)
- amx_votemap: In console only, treats as though transition was touched (requires ADMIN_KICK)
CVARS[defaults]
- custommaps["ww1 lowlands ms_show foutpost unrest pvp_archery pvp_arena"] - List of available custom maps, maps must be seperated by spaces
- custommaps["file"] - Use custommaps.txt for map list instead (not yet implemented)
- amx_votemap_ratio[0.50] % of voting players that need to vote yes for new map.
- amx_votekick_ratio[0.40] % of voting players that need to vote yes to kick a player.
- amx_voteban_ratio[0.80] % of voting players that need to vote yes to ban a player.
- amx_allow_kickvotes [1] allow clients to vote kick players
- amx_allow_banvotes [1] allow clients to vote ban players
- amx_allow_pvpvotes [1] allow clients to vote to enable/disable pvp
- amx_vote_time[60] seconds between votes
- ms_vote_delay[90] seconds before allowing non-trans vote after map change (prevents map hopping)
- ms_repeatvote[0] when set to 1, allows voting for the same map repeatedly
- ms_vote_on_touch [1] Gives player option to start a vote whenever he touches a transition (not yet implemented)
- ms_votemap_type [0]
0 = Standard - Adjacent, root towns, and custom maps votable only
1 = Restricted - Only root towns and custom maps are votable
2 = Ultra - All maps votable except boss and gauntlet maps
* Note: You can never vote for the map you are currently on, save through admin vote
- ms_alwaysshow_adj [0] when set to 1, always report adjacent maps, regardless of vote type
- ms_town_warp [1] when set to 0, disallows voting for root towns (does not override ms_votemap_type 2)
- ms_mazelock [1] when set to 1, disallows voting for maps adjacent to maze maps (including mscave->gatecity/goblintown)
- ms_hiddenlock [1] when set to 1, disallows voting for maps that are considered to be hidden (including Challs)
LOG OPTIONS: (do not combine with other logging plugins)
- ms_chat_log [0] when set to 1, this logs all chat in a file based on the month name (file is continuously appended)
- ms_debug_log [0] when set to 1 writes ALL server messages to dev_log.log (lags, but good for debuggary) - map must restart to take effect (dev_log.log is cleared with each map start)
===========================================================
*/
#include <amxmodx>
#include <amxmisc>
// #include <VexdUM>
#include <string>
#include <file.inc>
//version control
#define c_version "MAR2007b"
//constants
#define c_touch_delay 5 //seconds to supress checking for transition generated votes after spawn (as players often spawn in transitions)
#define c_message_delay 3 //seconds between reporting entity touched when dev log > 2
#define c_votemap_type_standard 0 //constants for vote types
#define c_votemap_type_restrict 1
#define c_votemap_type_ultra 2
#define c_votetype_map 1 //vote types (stored to g_votetype, passed to task_start_vote)
#define c_votetype_kick 2
#define c_votetype_ban 3
#define c_key_yes 1 //keys
#define c_key_no 2
#define c_key_null 3
#define c_root_towns "edana deralia helena" //maps votable as root town maps
//adjacent maps
#define c_adj_calruin2 "sfor"
#define c_adj_challs "sfor"
#define c_adj_daragoth "helena deralia mines"
#define c_adj_deralia "daragoth"
#define c_adj_edana "thornlands edanasewers"
#define c_adj_edanasewers "edana"
#define c_adj_gatecity "mscave"
#define c_adj_goblintown "mscave"
#define c_adj_helena "thornlands daragoth keledrosprelude2"
#define c_adj_heras "thornlands"
#define c_adj_keledrosprelude2 "helena [bossmap]"
#define c_adj_keledrosruins "keledrosprelude2"
#define c_adj_mines "daragoth"
#define c_adj_mscave "gatecity goblintown thornlands"
#define c_adj_sfor "thornlands challs"
#define c_adj_thornlands "heras helena sfor mscave edana"
#define c_nadjacents 15 //number of maps with adjacent listings
//gauntlet maps (voting into one of these, save at trans, causes gauntlet anti-cheat to activate, so do not allow)
#define c_gauntlet_maps "keledrosruins ww2b ww3d highlands_msc lostcastle_msc skycastle orcplace2_beta"
//maze maps (these maps do not allow adjacent voting when set to ms_mazelock set to 1) (these are not parsed)
#define c_maze_maps "mscave"
#define c_maze_maps_connected "goblintown gatecity"
//hidden maps (these maps cannot be voted for when ms_hiddenlock set to 1) (these are not parsed)
#define c_hidden_maps "challs"
//globals
new empty[32] //used to reset map strings
new bool:debug_mode = true //debug mode flag, set to false before release
new cvar_ms_debug_log //stored globally to help optimization
new g_text[256] //text for func_message to display (may not need)
new g_cmap_list[256][32] //holds parsed custom map names
new g_ncustom = 0 //holds number of custom maps
new g_towns_list[32][32] //holds parsed town map names
new g_ntowns = 0 //holds number of towns
new g_adjacent_list[32][32] //holds parsed map adjacent lists (ie. which maps are adjacent)
new g_adjacent_maps[32][32] //holds parsed map adjacent maps (ie. which maps have adjacent listings)
new g_gauntlet_list[32][32] //holds parsed gauntlet map names
new g_player_vote[32] //holds player votes
new g_votetype //holds votemap type (0|1|2) ("votemap"|"votekicK"|"voteban")
new g_maxplayers //holds max players
new g_nvotes //holds number of playes that voted
new g_error[256] //error to return
new g_maptovote[32] //passes map string to vote for
new g_offending_player[32] //passes player string to voteban/kick
new g_voter_id //passes voter index (0 = server)
new g_last_touched[32] //holds name of map the last touched transition goes to (for single touch voting)
new g_lastMessage //holds time of last message sent
//time markers
new foat:t_lastvote //holds time of last vote
new foat:t_lastspawn //holds time of last player spawn
//===== Initialize
public plugin_init()
{
register_plugin("MSC Adminvote",c_version,"by Thothie")
//get max players
new players[32]
get_players(players, g_maxplayers, "c")
//register cvars
register_cvar("custommaps","ww1 lowlands ms_show foutpost nightmare_thornlands unrest pvp_archery pvp_arena");
register_cvar("amx_votekick_ratio","0.40") //% of voting players voting yes needed to kick a player
register_cvar("amx_voteban_ratio","0.80") //% of voting players voting yes needed to ban a player
register_cvar("amx_votemap_ratio","0.50") //% of voting players voting yes needed to vote in a new map
register_cvar("amx_allow_kickvotes","1") //allow kick votes
register_cvar("amx_allow_banvotes","1") //allow ban votes
register_cvar("amx_allow_pvpvotes","1") //allow votes to change ms_pklevel
register_cvar("amx_vote_time","60") //time between votes
register_cvar("ms_vote_delay","90") //time before you can vote after arriving on new map
register_cvar("ms_repeatvote","0") //allow voting for same map you are on (reset map)
register_cvar("ms_vote_on_touch","1") //allow positive respond to single_touch_XXX server messages
register_cvar("ms_votetype","0") //vote restriction level
register_cvar("ms_alwaysshow_adj","0") //always list adjacent maps
register_cvar("ms_town_warp","1") //always allow warping to towns
register_cvar("ms_mazelock","1") //do not allow map votes in mazes
register_cvar("ms_hiddenlock","1") //do not allow votes for hidden maps
register_cvar("ms_chat_log","0") //log chat (msc_chatlog_MONTH-YEAR.txt)
register_cvar("ms_debug_log","0") //log all server messages (dev_log.txt)
//register commands (each of these parses params and passes to task_start_vote)
register_concmd("amx_votemap","cmd_vote_map" ,ADMIN_KICK,"<map name>")
register_concmd("votemap","cmd_vote_map",0,"<map name>")
register_concmd("votekick","cmd_vote_kick",0,"<partial name or #userid>")
register_concmd("voteban","cmd_vote_ban",0,"<partial name or #userid>")
//register menus
register_menucmd(register_menuid("Change map to "),(1<<0)|(1<<1),"func_tally_votes")
register_menucmd(register_menuid("Kick "),(1<<0)|(1<<1),"func_tally_votes")
register_menucmd(register_menuid("Ban "),(1<<0)|(1<<1),"func_tally_votes")
//initialize adjacent map strings
copy(g_adjacent_list[1],32,c_adj_calruin2)
copy(g_adjacent_list[2],32,c_adj_challs)
copy(g_adjacent_list[3],32,c_adj_daragoth)
copy(g_adjacent_list[4],32,c_adj_deralia)
copy(g_adjacent_list[5],32,c_adj_edana)
copy(g_adjacent_list[6],32,c_adj_edanasewers)
copy(g_adjacent_list[7],32,c_adj_gatecity)
copy(g_adjacent_list[8],32,c_adj_goblintown)
copy(g_adjacent_list[9],32,c_adj_helena)
copy(g_adjacent_list[10],32,c_adj_heras)
copy(g_adjacent_list[11],32,c_adj_mines)
copy(g_adjacent_list[12],32,c_adj_mscave)
copy(g_adjacent_list[13],32,c_adj_sfor)
copy(g_adjacent_list[14],32,c_adj_thornlands)
copy(g_adjacent_maps[1],32,"calruin2")
copy(g_adjacent_maps[2],32,"challs")
copy(g_adjacent_maps[3],32,"daragoth")
copy(g_adjacent_maps[4],32,"deralia")
copy(g_adjacent_maps[5],32,"edana")
copy(g_adjacent_maps[6],32,"edanasewers")
copy(g_adjacent_maps[7],32,"gatecity")
copy(g_adjacent_maps[8],32,"goblintown")
copy(g_adjacent_maps[9],32,"helena")
copy(g_adjacent_maps[10],32,"heras")
copy(g_adjacent_maps[11],32,"mines")
copy(g_adjacent_maps[12],32,"mscave")
copy(g_adjacent_maps[13],32,"sfor")
copy(g_adjacent_maps[14],32,"c_adj_thornlands ")
//this reads in every say_text command from the client
//since cmd's cannot have spaces, we need to parse every one :\
register_clcmd("say_text","event_say_text");
//remove any previous vote from screen on load
set_task(5.0,"task_clear_crap");
//get debug level
cvar_ms_debug_log = get_cvar_num("ms_debug_log");
}
//===== Quick display to both console and chat
public func_message(text[])
{
client_print(0,print_chat,"%s",text)
client_print(0,print_console,"%s",text)
}
//===== Vote key pressed, catalog vote
public event_tally_vote( id, key )
{
//(1<<0)|(1<<1)|(1<<2) ext|yes|no
new l_username
get_user_name(id,l_username,31)
if ( key == c_key_yes )
{
++g_nvotes
g_player_vote[id] = 1
client_print(0,print_chat,"%s votes aye!",l_username)
}
if ( key == c_key_no )
{
++g_nvotes
g_player_vote[id] = 2
client_print(0,print_chat,"%s votes neigh!",l_username)
}
if ( key == c_key_null || key == 0 )
{
g_player_vote[id] = 0
client_print(0,print_chat,"%s obstains.",l_username)
}
//these are for testing
if ( debug_mode )
{
if ( key == 4 ) client_print(0,print_chat,"%s pressed 4",l_username)
if ( key == 5 ) client_print(0,print_chat,"%s pressed 5",l_username)
if ( key == 6 ) client_print(0,print_chat,"%s pressed 6",l_username)
if ( key == 7 ) client_print(0,print_chat,"%s pressed 7",l_username)
if ( key == 8 ) client_print(0,print_chat,"%s pressed 8",l_username)
if ( key == 9 ) client_print(0,print_chat,"%s pressed 9",l_username)
if ( key == 10 ) client_print(0,print_chat,"%s pressed 0",l_username)
}
}
//===== Count votes when vote time is up
public task_count_votes()
{
new l_nyesvotes = 0
new l_nnovotes = 0
new float:l_ratio = 0
new bool:l_passed = 0
//count yes votes, calculate ratio vs. total votes
for ( new i=1; i<g_maxplayers; ++i)
{
if ( g_player_vote[i] == 1 ) ++l_nyesvotes
if ( g_player_vote[i] == 2 ) ++l_nnovotes
}
l_ratio = l_nyesvotes / g_nvotes
//get required artio
new l_req_ratio = 0
if ( g_votetype == c_votetype_map ) l_req_ratio = get_cvar_float("amx_votemap_ratio")
if ( g_votetype == c_votetype_kick ) l_req_ratio = get_cvar_float("amx_votekick_ratio")
if ( g_votetype == c_votetype_ban ) l_req_ratio = get_cvar_float("amx_voteban_ratio")
//flag fail/pass
if ( l_ratio > l_req_ratio ) l_passed = true
if ( l_ratio < l_req_ratio ) l_passed = false
if ( l_nyesvotes == 0 ) l_passed = false
if ( g_nvotes == 0 ) l_passed = false
new l_out_ratio = floatround(l_ratio * 100)
new l_out_req_ratio = floatround(l_req_ratio * 100)
if ( l_passed ) client_print(0,print_chat,"The ayes have it! %i ayes vs. %i neighs ( %f % of votes were aye vs. the required %f % )",l_nyesvotes,l_nnovotes,l_out_ratio,l_out_req_ratio)
if ( !l_passed ) client_print(0,print_chat,"The vote has fails. %i ayes vs. %i neighs ( %f % of votes were aye vs. the required %f % )",l_nyesvotes,l_nnovotes,l_out_ratio,l_out_req_ratio)
if ( l_passed )
{
if ( g_votetype == c_votetype_map ) event_votemap_pass()
if ( g_votetype == c_votetype_map ) event_votekick_pass()
if ( g_votetype == c_votetype_map ) event_voteban_pass()
}
}
//===== Return true if map is valid for vote
bool:func_ismap_legit( map[] )
{
new l_this_map[32];
get_mapname(l_this_map, 32);
new bool:l_is_gauntlet = ( containi(c_gauntlet_maps,map) > -1 );
new bool:l_is_hidden = ( containi(c_hidden_maps,map) > -1 );
new bool:l_is_adjacent = func_ismap_adjacent(l_this_map,map);
new bool:l_is_town = func_ismap_town(map);
new bool:l_is_custom = func_ismap_custom(map);
new cvar_ms_hiddenlock = get_cvar_num("ms_hiddenlock");
new cvar_ms_mazelock = get_cvar_num("ms_mazelock");
new cvar_ms_town_warp = get_cvar_num("ms_town_warp");
new cvar_ms_votemap_type = get_cvar_num("ms_votemap_type");
if ( debug_mode ) client_print(0,print_console,"gaunt: %s hidden: %s adj %s town %s custom %c thismap ",l_is_gauntlet,l_is_hidden,l_is_adjacent,l_is_town,l_is_custom,l_this_map);
if ( l_is_custom ) return true;
if ( l_is_gauntlet > -1 )
{
g_error = "%s is a gauntlet or boss map. You'll have to walk.";
return false;
}
if ( cvar_ms_hiddenlock == 1 )
{
if ( l_is_hidden > -1 )
{
g_error = "%s is a hidden area. You must find the entrance.";
return false;
}
}
if ( cvar_ms_mazelock == 1 )
{
if ( containi(c_maze_maps,l_this_map) > -1 )
{
g_error = "You are on a maze map. %s is around here... Somewhere. You must find the entrance.";
return false;
}
if ( containi(c_maze_maps_connected,map) > -1 )
{
g_error = "%s is connected to a maze map. You must explore the maze to find it.";
return false;
}
}
//all possible negative conditions for ultra vote passed, return true if ultra
if ( cvar_ms_votemap_type == c_votemap_type_ultra ) return true;
if ( cvar_ms_votemap_type == c_votemap_type_restricted )
{
if ( l_is_town )
{
if ( cvar_ms_town_warp == 1 ) return true;
if ( cvar_ms_town_warp == 0 )
{
g_error = "Town warping is not allowed on this server, you'll have to walk.";
return true;
}
}
g_error = "You cannot vote for %s on this server. You'll have to walk there.";
return false;
}
//there are no more possible positive conditions for restricted voting, so return neg, if in that mode
if ( cvar_ms_votemap_type == c_votemap_type_restricted ) return false;
//last possiblity is server is in standard vote mode and map is adjacent
if ( l_is_adjacent ) return true;
//all positive possiblities exhausted
g_error = "Unknown error - the best error report ever.";
return false;
}
//===== Return true if map is adjacent
bool:func_ismap_adjacent ( check_map[], is_adjacent_to[] )
{
for ( new i=1; i < c_nadjacents; ++i )
{
if ( equali(g_adjacent_maps[i],check_map) )
{
if ( containi(g_adjacent_list[i],is_adjacent_to) ) return true;
}
}
}
//===== Place town maps into array
public task_parse_towns()
{
//this isn't really needed, since this array is not dynamic, but helped to debug custom maps array builder
new bool:l_store_flag = false;
new r = 0;
g_ntowns = 1;
for ( new i = 1; i < strlen(c_root_towns); i++ )
{
if ( c_root_towns[i] == 32 ) l_store_flag = true; //if hit space, move to next element in array
if ( !l_store_flag )
{
copy(g_towns_list[g_ntowns][r],1,c_root_towns[i]);
++r;
}
if ( l_store_flag )
{
++g_ntowns;
g_towns_list[g_ntowns] = empty;
r = 0;
}
}
++g_ntowns; //+1 as last map will not have space after it
if ( debug_mode )
{
new townlist[1280];
for ( new i = 1; i < g_ntowns, i++ )
{
copy(townlist,32,g_towns_list[i]);
copy(townlist,1," ");
}
client_print(0,print_console,"towns: %s",townlist);
}
}
//===== Return true if this is a town map
bool:func_ismap_town( map[] )
{
task_parse_towns(); //puts towns into array
//see if check map is in town array
for ( new i = 1; i <= g_ntowns; i++ )
{
if ( equali(g_towns_list[i],map) ) return true;
}
return false;
}
//===== Place custom maps into array
public task_parse_custom()
{
new l_maplist[1280];
get_cvar_string ("custommaps",l_maplist,1279);
new bool:l_store_flag = false;
new r = 0;
if ( equali(l_maplist,"file") )
{
//use file method instead (pending)
return;
}
g_ncustom = 1;
for ( new i = 1; i < strlen(l_maplist); i++ )
{
if ( l_maplist[i] == 32 ) l_store_flag = true; //if encounter space, store this entry, move to next element in array
if ( !l_store_flag )
{
copy(g_cmap_list[g_ncustom][r],1,l_maplist[i]);
++r;
}
if ( l_store_flag )
{
if ( debug_mode ) client_print(0,print_console,"added_custom_map: /%s/",g_cmap_list[g_ncustom]);
++g_ncustom;
g_cmap_list[g_ncustom] = empty;
r=0;
}
}
++g_ncustom //+1 as last map will not have space after it
}
//===== Return true of map is in custom map array
bool:func_ismap_custom( map[] )
{
task_parse_custom(); //puts custom maps into array
for ( new i = 1; i <= g_ncustom; i++ )
{
if ( equali(g_cmap_list[i],map) ) return true;
}
return false;
}
//===== Event called with every message from the server
public alertmessage(atype, message[])
{
//this section will generate several duplicate definition warnings
//seems best to optimize this section by only defining the vars when an actual handled message takes place
if ( strlen(message) < 1 ) return PLUGIN_HANDLED;
new bool:l_handled = false;
//script or map event attempting to force map change
if ( containi(message,"force_map_") > -1 )
{
new l_scan_start = containi(message,"force_map_") + 10; //start reading string where "force_map_" ends
new bool:l_end_mapname = false;
new l_changemap[32];
for ( new i = l_scan_start; i < strlen(message) && !l_end_mapname; i++ )
{
//build changemap string - add letters until encounter non alpha num or end of string
if ( !isalnum(message[i]) && message[i] != 95 ) l_end_mapname = true; //95 = "_"
if ( !l_end_mapname ) l_changemap[i - l_scan_start] = message[i];
}
task_change_map(l_changemap);
l_handled = true;
}
//script or map event asking to vote for map change (usually called by transition with all players touching)
if ( containi(message,"touch_trans_") > -1 && !l_handled )
{
new l_scan_start = containi(message,"touch_trans_") + strlen("touch_trans_"); //start reading string where "touch_trans_" ends
new bool:l_end_mapname = false;
g_maptovote = empty;
for ( new i = l_scan_start; i < strlen(message) && !l_end_mapname; i++ )
{
//build changemap string - add letters until encounter non alpha num or end of string
if ( !isalnum(message[i]) && message[i] != 95 ) l_end_mapname = true; //95 = "_"
if ( !l_end_mapname ) g_maptovote[i - l_scan_start] = message[i];
}
g_votetype = c_votetype_map;
g_voter_id = 0;
task_start_vote();
l_handled = true;
}
//called when individual player touched a transition
if ( containi(message,"single_touch_") > -1 && !l_handled )
{
new l_scan_start = containi(message,"single_touch_") + strlen("single_touch_"); //start reading string where "touch_trans_" ends
new bool:l_end_mapname = false;
g_last_touched = empty;
for ( new i = l_scan_start; i < strlen(message) && !l_end_mapname; i++ )
{
//build changemap string - add letters until encounter non alpha num or end of string
if ( !isalnum(message[i]) && message[i] != 95 ) l_end_mapname = true; //95 = _
if ( !l_end_mapname ) g_last_touched[i - l_scan_start] = message[i];
}
l_handled = true;
}
if ( cvar_ms_debug_log > 0 )
{
new l_logout[512];
format(l_logout,511,"%s", message)
if ( file_exists("dev_log.log") == 0 ) write_file("dev_log.log","logstart");
write_file("dev_log.log",l_logout,-1);
}
}
//===== Event called every time a client executes the saytext command
public event_say_text(id,level,cid)
{
new cvar_ms_chat_log = get_cvar_num("ms_chat_log");
new bool:l_handled = false; //prevents weridness if someone said, for instance, "votemap votekick"
//read in command
new l_saytext[256];
read_args(l_saytext,255);
if ( containi(l_saytext,"votemap") > -1 )
{
//grab map string player is attempting to vote for, if any
new l_scanstart = containi(l_saytext,"votemap") + 8;
new r = 0;
g_maptovote = empty;
copy(g_maptovote,4,"none"); //if task_start_vote gets "none" it should just display the available maps
if ( l_scanstart < strlen(l_saytext) )
{
//if string is longer than "votemap ", assume there is a map, read in to end
for ( new i = l_scanstart; i < strlen(l_saytext); i++ )
{
g_maptovote[r] = l_saytext[i];
++r;
}
}
g_votetype = c_votetype_map;
g_voter_id = id;
task_start_vote();
l_handled = true;
}
if ( containi(l_saytext,"votekick") > -1 && !l_handled )
{
new l_scanstart = containi(l_saytext,"votekick") + 9;
new r = 0;
g_offending_player = empty;
copy(g_offending_player,4,"none");
if ( l_scanstart < strlen(l_saytext) )
{
for ( new i = l_scanstart; i < strlen(l_saytext); i++ )
{
g_offending_player[r] = l_saytext[i];
++r;
}
}
g_votetype = c_votetype_kick;
g_voter_id = id;
task_start_vote();
l_handled = true;
}
if ( containi(l_saytext,"voteban") > -1 && !l_handled )
{
new l_scanstart = containi(l_saytext,"voteban") + 8;
new r = 0;
g_offending_player = empty;
copy(g_offending_player,4,"none");
if ( l_scanstart < strlen(l_saytext) )
{
for ( new i = l_scanstart; i < strlen(l_saytext); i++ )
{
g_offending_player[r] = l_saytext[i];
++r;
}
}
g_votetype = c_votetype_ban;
g_voter_id = id;
task_start_vote();
l_handled = true;
}
if ( cvar_ms_chat_log > 0 )
{
//get user info
new name[33];
new authid[33];
get_user_name(id, name, 32);
get_user_authid(id, authid, 32);
//time stamp
new l_time_stamp[15];
get_time("%m/%d-%H:%M", l_time_stamp, 15);
//map stamp
new l_currentmap[32]
get_mapname (l_currentmap, 31)
//format message to log
new l_outlog[512];
format(l_outlog,511,"[%s]%s - '%s'<%s> says: '%s'", l_currentmap, l_time_stamp, name, authid, l_saytext);
//log message
task_write_chatlog(l_outlog)
}
return PLUGIN_CONTINUE;
}
//===== Remove vote from screen after map change (called from init)
public task_clear_crap()
{
new menu_msg[256];
new players[32];
new numplayers;
new keys = (1<<0)|(1<<1);
get_players(players,numplayers,"c");
for(numplayers--;numplayers>=0;numplayers--)
{
format(menu_msg,255," ", players[numplayers])
show_menu(players[numplayers],keys,menu_msg,0.1,"nadda ")
}
}
//===== Write out chat log
public task_write_chatlog( chatlog[] )
{
//assemble log file name ( msc_chatlog_MMMYYYY.log )
new l_file_stamp[22];
get_time("%m%Y", l_file_stamp, 22);
new l_logfile[37];
copy(l_logfile,12, "msc_chatlog_");
copy(l_logfile,22, l_file_stamp);
copy(l_logfile,4, ".log");
if ( file_exists(l_logfile) == 0 ) write_file("msc_chatlog.log","MSC Chat Log");
write_file(l_logfile,chatlog,-1);
}
//======================================================================================= [BEGIN] CLIENT LOGGING EVENTS [BEGIN]
//===== Event fired whenever client connects
public client_connect(id)
{
new cvar_ms_chat_log = get_cvar_num("ms_chat_log");
if ( cvar_ms_chat_log > 0 )
{
//user info
new name[33]
new authid[33]
get_user_name(id, name, 32)
get_user_authid(id, authid, 32)
//time stamp
new l_time_stamp[15];
get_time("%m/%d-%H:%M", l_time_stamp, 15);
//map stamp
new l_currentmap[32];
get_mapname (l_currentmap, 31);
//format message to log
new l_outlog[512];
format(l_outlog,511,"[%s]%s - '%s'<%s> ATTEMPTS_TO_CONNECT", l_currentmap, l_time_stamp, name, authid);
//log message
task_write_chatlog(l_outlog)
}
}
//===== Event fired whenever client authorized
public client_authorized(id)
{
new cvar_ms_chat_log = get_cvar_num("ms_chat_log");
if ( cvar_ms_chat_log > 0 )
{
//user info
new name[33]
new authid[33]
get_user_name(id, name, 32)
get_user_authid(id, authid, 32)
//time stamp
new l_time_stamp[15];
get_time("%m/%d-%H:%M", l_time_stamp, 15);
//map stamp
new l_currentmap[32];
get_mapname (l_currentmap, 31);
//format message to log
new l_outlog[512];
format(l_outlog,511,"[%s]%s - '%s'<%s> CONNECTED", l_currentmap, l_time_stamp, name, authid);
//log message
task_write_chatlog(l_outlog)
}
}
//===== Event fired whenever client exits
public client_disconnect(id)
{
new cvar_ms_chat_log = get_cvar_num("ms_chat_log");
if ( cvar_ms_chat_log > 0 )
{
//user info
new name[33]
new authid[33]
get_user_name(id, name, 32)
get_user_authid(id, authid, 32)
//time stamp
new l_time_stamp[15];
get_time("%m/%d-%H:%M", l_time_stamp, 15);
//map stamp
new l_currentmap[32];
get_mapname (l_currentmap, 31);
//format message to log
new l_outlog[512];
format(l_outlog,511,"[%s]%s - '%s'<%s> LEAVES_SERVER", l_currentmap, l_time_stamp, name, authid);
//log message
task_write_chatlog(l_outlog)
}
}
//======================================================================================= [END] CLIENT LOGGING EVENTS [END]
//===== Respond to vote request from player
public task_start_vote()
{
new Float:l_vdifference = get_gametime() - g_lastvotetime[0];
new Float:cvar_amx_vote_time = get_cvar_float("amx_vote_time");
if ( l_vdifference < cvar_amx_vote_time )
{
client_print(g_voter_id,print_chat,"Too soon to begin another vote.");
return;
}
if ( g_votetype == c_votetype_map )
{
if ( equali(g_maptovote,"none") )
{
task_list_maps();
return;
}
new bool:map_legit = func_ismap_legit(g_maptovote);
if ( map_legit )
{
g_lastvotetime[0] = get_gametime(); //store vote time
task_votemap( map_legit );
return;
}
if ( !map_legit )
{
client_print(g_voter_id,print_chat,"%s",g_error,g_maptovote);
return;
}
}
}
//====== Start a vote for a map
public task_votemap( map[] )
{
}
|