AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with Block cmd (https://forums.alliedmods.net/showthread.php?t=101301)

gladius 08-22-2009 17:12

Problem with Block cmd
 
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

ot_207 08-22-2009 18:07

Re: Problem with Block cmd
 
query_client_cvar

gladius 08-23-2009 13:58

Re: Problem with Block cmd
 
Quote:

Originally Posted by ot_207 (Post 909463)

yes, I use this but not working.

ot_207 08-23-2009 14:05

Re: Problem with Block cmd
 
Quote:

Originally Posted by gladius (Post 910359)
yes, I use this but not working.

No-steam? x64?

gladius 08-23-2009 14:15

Re: Problem with Block cmd
 
Quote:

Originally Posted by ot_207 (Post 910371)
No-steam? x64?

no, I use my steam and server steam
the code is correct?

gladius 08-29-2009 16:08

Re: Problem with Block cmd
 
Someone can help me? pls :D

Bugsy 08-29-2009 17:26

Re: Problem with Block cmd
 
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

gladius 08-29-2009 17:30

Re: Problem with Block cmd
 
fixed :D Task_CheckFrames change to checkfps :D

PHP Code:

set_task(5.0"checkfps" id __"b"


Starsailor 08-29-2009 22:03

Re: Problem with Block cmd
 
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


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

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