|
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
|

08-22-2009
, 17:12
Problem with Block cmd
|
#1
|
Well I made a plugin to choose FPS but I have a problem ...
The problem is that I want to block 3 cmds, which can not be changed by using the console, if only for the menu, and the values that are in the menu.
PHP Code:
fps_max fps_modem developer
PHP Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta>
#define PLUGIN "FPS Choose" #define VERSION "1.0" #define AUTHOR "GlaDiuS"
// colorchat enum Color { NORMAL = 1, // clients scr_concolor cvar color GREEN, // Green Color TEAM_COLOR, // Red, grey, blue GREY, // grey RED, // Red BLUE, // Blue }
new TeamName[][] = { "", "TERRORIST", "CT", "SPECTATOR" } // colorchat end
new g_szCommands1[][] = { "fps_max", "fps_modem", "developer" } new g_iValues1[] = { 101, 0, 0 }
new g_szCommands2[][] = { "fps_max", "fps_modem", "developer" } new g_iValues2[] = { 125, 0, 1 }
new g_szCommands3[][] = { "fps_max", "fps_modem", "developer" } new g_iValues3[] = { 131, 0, 1 }
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /setfps", "Show_FPSMenu") }
public client_putinserver(id) { if(!is_user_bot(id)) { set_task(5.0, "Show_FPSMenu", id) set_task(5.0, "checkfps", id, _, _, "b") } }
public client_disconnect(id) remove_task(id)
public checkfps(id) { if (!is_user_connected(id)) return; for (new i; i < sizeof(g_szCommands1); i++) query_client_cvar(id, g_szCommands1[i], "Blocked") for (new i; i < sizeof(g_szCommands2); i++) query_client_cvar(id, g_szCommands2[i], "Blocked") for (new i; i < sizeof(g_szCommands3); i++) query_client_cvar(id, g_szCommands3[i], "Blocked") }
public Blocked(id, const command[], const value[], const param[]) { if (!is_user_connected(id)) return; if (value[0] == 'B') { log_amx("Bad Cvar Request.") return; } for (new i; i < sizeof(g_szCommands1); i++) { if (equali(command, g_szCommands1[i])) if (str_to_num(value) != g_iValues1[i]) server_cmd("kick #%d ^"Cvar [%s] Invalida [must be: %d]^"", get_user_userid(id), g_szCommands1[i], g_iValues1[i]) } for (new i; i < sizeof(g_szCommands2); i++) { if (equali(command, g_szCommands2[i])) if (str_to_num(value) != g_iValues2[i]) server_cmd("kick #%d ^"Cvar [%s] Invalid [must be: %d]^"", get_user_userid(id), g_szCommands2[i], g_iValues2[i]) } for (new i; i < sizeof(g_szCommands3); i++) { if (equali(command, g_szCommands3[i])) if (str_to_num(value) != g_iValues3[i]) server_cmd("kick #%d ^"Cvar [%s] Invalida [must be: %d]^"", get_user_userid(id), g_szCommands3[i], g_iValues3[i]) } }
public Show_FPSMenu(id) { client_cmd(id, "say /reset") new fMenu = menu_create("\yFPS Menu", "FPSHandler") menu_additem(fMenu, "\w100 FPS", "1", 0) menu_additem(fMenu, "\w125 FPS", "2", 0) menu_additem(fMenu, "\w131 FPS", "3", 0) menu_setprop(fMenu, MPROP_EXIT, MEXIT_ALL) menu_display(id, fMenu, 0) return PLUGIN_HANDLED }
public FPSHandler(id, fMenu, item) { if (item == MENU_EXIT) { server_cmd("kick #%d ^"Your dont choose your FPS.^"", get_user_userid(id)) menu_destroy(fMenu) return PLUGIN_HANDLED } new Data[6], Name[64] new Access, Callback menu_item_getinfo(fMenu, item, Access, Data, sizeof(Data)-1, Name, sizeof(Name)-1, Callback) new Key = str_to_num(Data) switch (Key) { case 1: { if(is_user_alive(id)) { client_cmd(id, "fps_max 100") client_cmd(id, "fps_modem 0") client_cmd(id, "developer 0") ColorChat(id,GREEN, "You have 100 FPS") } } case 2: { if(is_user_alive(id)) { client_cmd(id, "fps_max 125") client_cmd(id, "fps_modem 0") client_cmd(id, "developer 1") ColorChat(id,GREEN, "You have 125 FPS") } } case 3: { if(is_user_alive(id)) { client_cmd(id, "fps_max 131") client_cmd(id, "fps_modem 0") client_cmd(id, "developer 1") ColorChat(id,GREEN, "You have 131 FPS") } } } menu_destroy(fMenu) return PLUGIN_HANDLED }
//-------------------------------------------------------------------------------------------------- //-------------------------------------Colorchat---------------------------------------------------- //--------------------------------------------------------------------------------------------------
ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...) { if( !get_playersnum() ) return;
new message[256];
switch(type) { case NORMAL: // clients scr_concolor cvar color { message[0] = 0x01; } case GREEN: // Green { message[0] = 0x04; } default: // White, Red, Blue { message[0] = 0x03; } }
vformat(message[1], 251, msg, 4);
// Make sure message is not longer than 192 character. Will crash the server. message[192] = '^0';
new team, ColorChange, index, MSG_Type;
if(id) { MSG_Type = MSG_ONE; index = id; } else { index = FindPlayer(); MSG_Type = MSG_ALL; }
team = get_user_team(index); ColorChange = ColorSelection(index, MSG_Type, type);
ShowColorMessage(index, MSG_Type, message);
if(ColorChange) { Team_Info(index, MSG_Type, TeamName[team]); } }
ShowColorMessage(id, type, message[]) { static bool:saytext_used; static get_user_msgid_saytext; if(!saytext_used) { get_user_msgid_saytext = get_user_msgid("SayText"); saytext_used = true; } message_begin(type, get_user_msgid_saytext, _, id); write_byte(id) write_string(message); message_end(); }
Team_Info(id, type, team[]) { static bool:teaminfo_used; static get_user_msgid_teaminfo; if(!teaminfo_used) { get_user_msgid_teaminfo = get_user_msgid("TeamInfo"); teaminfo_used = true; } message_begin(type, get_user_msgid_teaminfo, _, id); write_byte(id); write_string(team); message_end();
return 1; }
ColorSelection(index, type, Color:Type) { switch(Type) { case RED: { return Team_Info(index, type, TeamName[1]); } case BLUE: { return Team_Info(index, type, TeamName[2]); } case GREY: { return Team_Info(index, type, TeamName[0]); } }
return 0; }
FindPlayer() { new i = -1;
while(i <= get_maxplayers()) { if(is_user_connected(++i)) return i; }
return -1; }
PD: I HAVE STEAM
If anyone can help me, I would be very grateful: D
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).
Last edited by gladius; 08-29-2009 at 17:29.
|
|