Raised This Month: $ Target: $400
 0% 

Problem with Block cmd


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 08-22-2009 , 17:12   Problem with Block cmd
Reply With Quote #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[] = { 1010}

new 
g_szCommands2[][] = { "fps_max""fps_modem""developer" }
new 
g_iValues2[] = { 1250}

new 
g_szCommands3[][] = { "fps_max""fps_modem""developer" }
new 
g_iValues3[] = { 1310}

public 
plugin_init() {
register_plugin(PLUGINVERSIONAUTHOR)

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 
isizeof(g_szCommands1); i++)
        
query_client_cvar(idg_szCommands1[i], "Blocked")
        
    for (new 
isizeof(g_szCommands2); i++)
        
query_client_cvar(idg_szCommands2[i], "Blocked")
        
    for (new 
isizeof(g_szCommands3); i++)
        
query_client_cvar(idg_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 
isizeof(g_szCommands1); i++)
    {
        if (
equali(commandg_szCommands1[i]))
            if (
str_to_num(value) != g_iValues1[i])
            
server_cmd("kick #%d ^"Cvar [%sInvalida [must be: %d]^""get_user_userid(id), g_szCommands1[i], g_iValues1[i])
    }
    
    for (new 
isizeof(g_szCommands2); i++)
    {
        if (
equali(commandg_szCommands2[i]))
            if (
str_to_num(value) != g_iValues2[i])
            
server_cmd("kick #%d ^"Cvar [%sInvalid [must be: %d]^""get_user_userid(id), g_szCommands2[i], g_iValues2[i])
    }
    
    for (new 
isizeof(g_szCommands3); i++)
    {
        if (
equali(commandg_szCommands3[i]))
            if (
str_to_num(value) != g_iValues3[i])
            
server_cmd("kick #%d ^"Cvar [%sInvalida [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(fMenuMPROP_EXITMEXIT_ALL)
    
menu_display(idfMenu0)
    
    return 
PLUGIN_HANDLED
}

public 
FPSHandler(idfMenuitem)
{
    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 
AccessCallback
    menu_item_getinfo
(fMenuitemAccessDatasizeof(Data)-1Namesizeof(Name)-1Callback)
    
    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(idColor: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], 251msg4);

// Make sure message is not longer than 192 character. Will crash the server.
message[192] = '^0';

new 
teamColorChangeindexMSG_Type;

if(
id)
{
MSG_Type MSG_ONE;
index id;
} else {
index FindPlayer();
MSG_Type MSG_ALL;
}

team get_user_team(index);
ColorChange ColorSelection(indexMSG_Typetype);

ShowColorMessage(indexMSG_Typemessage);

if(
ColorChange)
{
Team_Info(indexMSG_TypeTeamName[team]);
}
}

ShowColorMessage(idtypemessage[])
{
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(typeget_user_msgid_saytext_id);
write_byte(id)        
write_string(message);
message_end();    
}

Team_Info(idtypeteam[])
{
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(typeget_user_msgid_teaminfo_id);
write_byte(id);
write_string(team);
message_end();

return 
1;
}

ColorSelection(indextypeColor:Type)
{
switch(
Type)
{
case 
RED:
{
return 
Team_Info(indextypeTeamName[1]);
}
case 
BLUE:
{
return 
Team_Info(indextypeTeamName[2]);
}
case 
GREY:
{
return 
Team_Info(indextypeTeamName[0]);
}
}

return 
0;
}

FindPlayer()
{
new 
= -1;

while(
<= 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.
gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-22-2009 , 18:07   Re: Problem with Block cmd
Reply With Quote #2

query_client_cvar
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 08-23-2009 , 13:58   Re: Problem with Block cmd
Reply With Quote #3

Quote:
Originally Posted by ot_207 View Post
yes, I use this but not working.
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).

gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-23-2009 , 14:05   Re: Problem with Block cmd
Reply With Quote #4

Quote:
Originally Posted by gladius View Post
yes, I use this but not working.
No-steam? x64?
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 08-23-2009 , 14:15   Re: Problem with Block cmd
Reply With Quote #5

Quote:
Originally Posted by ot_207 View Post
No-steam? x64?
no, I use my steam and server steam
the code is correct?
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).

gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 08-29-2009 , 16:08   Re: Problem with Block cmd
Reply With Quote #6

Someone can help me? pls
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).

gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-29-2009 , 17:26   Re: Problem with Block cmd
Reply With Quote #7

Code:
public client_putinserver(id) {     if(!is_user_bot(id))     {         set_task(5.0, "Show_FPSMenu", id )         set_task(5.0, "Task_CheckFrames" , id , _, _, "b")     } }
Task_CheckFrames function doesnt exist. Was checkfps the intended function to be called?

Edit: Nice code correction edit after my post :-P
__________________

Last edited by Bugsy; 08-29-2009 at 17:31.
Bugsy is offline
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 08-29-2009 , 17:30   Re: Problem with Block cmd
Reply With Quote #8

fixed Task_CheckFrames change to checkfps

PHP Code:
set_task(5.0"checkfps" id __"b"
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).

gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
Starsailor
horrible hahah
Join Date: Aug 2008
Location: Buenos Aires
Old 08-29-2009 , 22:03   Re: Problem with Block cmd
Reply With Quote #9

PHP Code:
for (new isizeof(g_szCommands1); i++)
    
query_client_cvar(idg_szCommands1[i], "Blocked")

for (new 
isizeof(g_szCommands2); i++)
    
query_client_cvar(idg_szCommands2[i], "Blocked")

for (new 
isizeof(g_szCommands3); i++)
    
query_client_cvar(idg_szCommands3[i], "Blocked"
that loops are same thing :S
__________________
Find my plugins here..

Ex - Spanish Moderator.
Starsailor is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:02.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode