Raised This Month: $ Target: $400
 0% 

[sql] menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
avril-lavigne
Banned
Join Date: Apr 2009
Old 09-13-2012 , 00:00   [sql] menu
Reply With Quote #1

Is it possible to show Custom item in menu using mysql ?
I want to change TEXT in menu using website. Lets say I have 6 points in menu and form with 6 lines on website. I need to change text in each menu item


1. [HELLO]
2. Drop weapon
3. open xxx menu
4 [BYE]


after change on website
1. LOL ?
2. WTF
3. disconnect
4. get admin

Amxbans has that feature because amxbans reasons read web/sql data
I would pay for the code and sql rows
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 09-13-2012 at 00:34.
avril-lavigne is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 09-13-2012 , 10:33   Re: [sql] menu
Reply With Quote #2

Really , i dont understand what is your idea.

You want to do a Menu with data from MySQL Columns ?

Ex simple

Spoiler


But , i really dont understand , you say using mysql , but at the time says you want to read data from website...
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
Old 09-13-2012, 10:34
lucas_7_94
This message has been deleted by lucas_7_94. Reason: nevermind.
avril-lavigne
Banned
Join Date: Apr 2009
Old 09-13-2012 , 10:49   Re: [sql] menu
Reply With Quote #3

I want to have ability to rename menu items thru my website, using mysql to store data or set new names.
html form will send new data to mysql
Hlds server will read it and change the menu

Spoiler
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 09-13-2012 at 10:52.
avril-lavigne is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 09-13-2012 , 11:12   Re: [sql] menu
Reply With Quote #4

And what should be done in the menu handler ? And i think this should be moved to Request.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
mabaclu
Senior Member
Join Date: Jun 2010
Location: Portugal
Old 09-13-2012 , 11:26   Re: [sql] menu
Reply With Quote #5

Quote:
Originally Posted by lucas_7_94 View Post
And what should be done in the menu handler ? And i think this should be moved to Request.
Please answer this question. If the answer is 'nothing', I can do it for 6$.
__________________
mabaclu is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 09-13-2012 , 11:58   Re: [sql] menu
Reply With Quote #6

Ok here is the code its not complete I didnt have time to complete


PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>

#define INSERT_MAX_LENGTH 50000
     
new g_szLogFile64 ];
new 
g_Table32 ]
new 
szPrefix32 ]

new 
p_Hostp_Userp_Passp_Dbp_Tablep_Prefix
new ip_servakaip_servaka2ip_servaka3ip_servaka4ip_servaka5 ,  ip_servaka6

new cvar_showhudmsg
public plugin_init() 
{
    
register_plugin("putinserver menu""0.1""Avril-Lavigne");
    
register_clcmd("amx_menu""function_menu"ADMIN_ALL,"");
    
register_clcmd("say /menu""function_menu");    
    
register_clcmd("menu""function_menu");
    
cvar_showhudmsg register_cvar("show_hudmsg""1");    
        
ip_servaka register_cvar("server_ip""123.123.123.123:27015")
        
ip_servaka2 register_cvar("server_ip2""123.123.123.123:27015")
        
ip_servaka3 register_cvar("server_ip3""123.123.123.123:27015")
        
ip_servaka4 register_cvar("server_ip4""123.123.123.123:27015")
        
ip_servaka5 register_cvar("server_ip5""123.123.123.123:27015")
        
ip_servaka6 register_cvar("server_ip6""123.123.123.123:27015")
        


            
    
p_Host        register_cvar"lac_host""",  FCVAR_PROTECTED );
    
p_User        register_cvar"lac_user""",  FCVAR_PROTECTED );
    
p_Pass        register_cvar"lac_pass""",  FCVAR_PROTECTED );
    
p_Db        register_cvar"lac_db""",    FCVAR_PROTECTED );
    
p_Table        register_cvar"lac_table"""FCVAR_PROTECTED );
    
    
p_Prefix    register_cvar"lac_prefix""[LAC]" )
    
    
get_datadirg_szLogFilecharsmaxg_szLogFile ) );
    
addg_szLogFilecharsmaxg_szLogFile ), "/connect.log" );
    
    
set_task0.1"plugin_mysql_init" );
    
}

public 
plugin_mysql_init()
{
    new 
szHost32 ], szUser32 ], szPass32 ], szDb32 ];
    
    
get_pcvar_stringp_HostszHost,   charsmaxszHost )    );
    
get_pcvar_stringp_UserszUser,   charsmaxszUser )    );
    
get_pcvar_stringp_PassszPass,   charsmaxszPass )    );
    
get_pcvar_stringp_Db,   szDb,     charsmaxszDb )      );
    
get_pcvar_stringp_Tableg_Tablecharsmaxg_Table )   );
    
    
get_pcvar_stringp_PrefixszPrefixcharsmaxszPrefix ) )
    
    new 
Handle:SqlxTuple SQL_MakeDbTupleszHostszUserszPassszDb );
    
    if( 
SqlxTuple )
    {
        new 
Error128 ]
        new 
ErrorCodeHandle:SqlxConnection SQL_ConnectSqlxTupleErrorCodeErrorcharsmaxError ) );
        if( 
SqlxConnection )
        {
            
server_print"%s Conected to database"szPrefix );
            
            new 
Handle:Queries SQL_PrepareQuerySqlxConnection,
                
"CREATE TABLE IF NOT EXISTS `%s` (\
                `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\
                `hostname` VARCHAR( 100 ) NOT NULL,\
                `adminname` VARCHAR( 100 ) NOT NULL,\
                `steamid` VARCHAR( 100 ) NOT NULL,\
                `connecttime` TIME NOT NULL default '00:00:00',\
                `connectdate` DATE NOT NULL default '0000-00-00')"
,
                
g_Table );
            
            new 
Error128 ];
            if( !
SQL_ExecuteQueries ) )
            {
                
SQL_QueryErrorQueriesErrorcharsmaxError ) );
                
set_fail_stateError );
            }
            
            
SQL_FreeHandleQueries );
            
            new 
fopeng_szLogFile"rt" );
            
            if( 
)
            {
                new 
szQueryINSERT_MAX_LENGTH ];
                new 
iDefaultLeniLen iDefaultLen formatexszQuerycharsmaxszQuery ), "INSERT INTO %s (hostname,adminname,connecttime,connectdate,steamid) VALUES "g_Table );
                new 
szTemp240 ], iTempLen;
                
                new 
szData200 ];
                new 
szSteamID35 ];
                
                while( !
feof) )
                {
                    
fgetsfszDatacharsmaxszData ) );
                    
                    if( 
parseszDataszHostcharsmaxszHost ), szUsercharsmaxszUser ), szPasscharsmaxszPass ), szDbcharsmaxszDb ), szSteamIDcharsmaxszSteamID ) ) != )
                    {
                        continue;
                    }
                    
                    
// szHost = hostname
                    // szUser = player name
                    // szPass = time
                    // szDb = date
                    
                    
iTempLen formatexszTempcharsmaxszTemp ), "('%s','%s','%s','%s','%s'),"szHostszUserszPassszDbszSteamID );
                    
                    if( ( 
iLen iTempLen ) > INSERT_MAX_LENGTH )
                    {
                        
szQueryiLen ] = ';';
                        
                        
Queries SQL_PrepareQuerySqlxConnection"%s"szQuery );
                        
                        if( !
SQL_ExecuteQueries ) )
                        {
                            
SQL_QueryErrorQueriesErrorcharsmaxError ) );
                            
log_amx"Error inserting logs: %s"Error );
                        }
                        
                        
SQL_FreeHandleQueries );
                        
                        
iLen iDefaultLen;
                    }
                    
                    
iLen += copyszQueryiLen ], charsmaxszQuery ) - iLenszTemp );
                }
                
                
fclose);
                
                if( 
iLen iDefaultLen )
                {
                    
szQueryiLen ] = ';';
                    
                    
Queries SQL_PrepareQuerySqlxConnection"%s"szQuery );
                    
                    if( !
SQL_ExecuteQueries ) )
                    {
                        
SQL_QueryErrorQueriesErrorcharsmaxError ) );
                        
log_amx"Error inserting logs: %s"Error );
                    }
                    
                    
SQL_FreeHandleQueries );
                }
            }
            
            
SQL_FreeHandleSqlxConnection );
        }
        else
        {
            
server_print"%s : Database connection failed (error %d): %s"szPrefixErrorCodeError )
        }
    }
    
    if( 
file_existsg_szLogFile ) )
    {
        
delete_fileg_szLogFile );
    }
}

FixForSQLszString[ ], iLen )
{
    
replace_allszStringiLen"`""" );
    
replace_allszStringiLen"'""''" );
}


public 
client_putinserver(id)
{
    if(
get_pcvar_num(cvar_showhudmsg))
        
set_task(1.0"task_hudmsg"id__"b")
}

public 
task_hudmsg(id)
{
    
set_hudmessage(025500.750.006.012.0)
    
show_hudmessage(id"Idi nahuj")
}

public 
function_menu(id
{
    new 
menu menu_create("\wР’С‹ С…отите РїРѕСЃРµС‚ить СЃР»РµРґСѓС‰РёРµ СЃРµСЂРІРµСЂР°?""menu_handler")
    
    
    
menu_additem(menu"\d[Pro] Classic","1")
    
menu_additem(menu"\d[Pro] CSDM","2")
    
menu_additem(menu"\w[Pro] War3FT","3")
    
menu_additem(menu"\y[Pro] Respawn","4")
        
menu_additem(menu"\y[Pro] Jump 2","5")
    
menu_additem(menu"\wКупить Р°РґРјРёРЅРєСѓ","6")
    
menu_setprop(menuMPROP_EXITNAME"Р*’ыхР*С•Р*Т‘")
    
menu_setprop(menuMPROP_EXIT,MEXIT_ALL)
         
    
menu_display(id,menu,0)
    return 
PLUGIN_HANDLED
        register_clcmd
("menu","go_menu");
}

public 
client_authorized(id)
{
    
client_cmd(id"bind ^"F3^" ^"menu^"")
}
     
public 
menu_handler(idmenuitem
{
    if(
item == MENU_EXIT
    {
        
menu_destroy(menu)
            return 
PLUGIN_HANDLED
    
}

        new 
Server[32],Server2[32] ,Server3[32] ,Server4[32] ,Server5[32],Server6[32
        
get_pcvar_string(ip_servakaServercharsmax(Server))   
        
get_pcvar_string(ip_servaka2Server2charsmax(Server2))  
        
get_pcvar_string(ip_servaka3Server3charsmax(Server3))  
        
get_pcvar_string(ip_servaka4Server4charsmax(Server4))  
        
get_pcvar_string(ip_servaka5Server5charsmax(Server5))  
        
get_pcvar_string(ip_servaka6Server6charsmax(Server6))  

         
    new 
data[6], iName[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
         
    new 
key str_to_num(data)
         
    switch(
key
    {
        case 
1: {  
                              
client_cmd(id"connect %s",Server)
                              
client_cmd(id"Connect %s",Server)
                              
LogAdminToSql(id)
                           }          
            case 
2:  {  
                              
client_cmd(id"connect %s",Server2)
                              
client_cmd(id"Connect %s",Server2)
                               
LogAdminToSql(id)
                             }        
            case 
3:  {  
                              
client_cmd(id"connect %s",Server3)
                              
client_cmd(id"Connect %s",Server3)
                              
LogAdminToSql(id)
                           }            
            case 
4   {  
                              
client_cmd(id"connect %s",Server4)
                              
client_cmd(id"Connect %s",Server4)
                               
LogAdminToSql(id)
                           }             
            case 
5:  {  
                              
client_cmd(id"connect %s",Server5)
                              
client_cmd(id"Connect %s",Server5)
                               
LogAdminToSql(id)
                           }                    
            case 
6:  {  
                              
client_cmd(id"connect %s",Server6)
                              
client_cmd(id"Connect %s",Server6)
                               
LogAdminToSql(id)
                           }        
           
           
    }
    return 
PLUGIN_HANDLED
}



public 
LogAdminToSqlid )
{
    if( 
is_user_connectedid ) && is_user_adminid ) )
    {
        static 
szHostName64 ], szAdminName32 ], TimeStr32 ], DateStr82 ], szSteamID35 ]
        
        
get_user_nameidszAdminNamecharsmaxszAdminName ) );
        
get_user_name0szHostNamecharsmaxszHostName ) );
        
get_user_authididszSteamIDcharsmaxszSteamID ) )
        
        
get_time"%H:%M:%S"TimeStrcharsmaxTimeStr ) );
        
get_time"%Y.%m.%d"DateStrcharsmaxDateStr ) );
        
        
FixForSQLszAdminNamecharsmaxszAdminName ) );
        
FixForSQLszHostNamecharsmaxszHostName ) );
        
FixForSQLTimeStrcharsmaxTimeStr ) );
        
FixForSQLDateStrcharsmaxDateStr ) );
        
FixForSQLszSteamIDcharsmaxszSteamID ) );
        
        new 
fopeng_szLogFile"a+" );
        
fprintff"^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^"^n"szHostNameszAdminNameTimeStrDateStrszSteamID );
        
fclose);
    }

what I need -
change this
Spoiler


yeah I took sql logging from admin sql plugin ...*(
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 09-13-2012 at 12:01.
avril-lavigne is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 09-13-2012 , 12:15   Re: [sql] menu
Reply With Quote #7

Do you want a column to edit that 'Pro Classic' ( Can be another name ) and another column that have ips from that servers ?

According with the last posted ,you want a little custom server redirect.

Spoiler


The database is your custom name , table should be called 'tablehere' , columns names should be "MenuData" and "Handler" , both should be Varchar 64 ( The names should be without quotes )

See if this is that you want.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.

Last edited by lucas_7_94; 09-14-2012 at 09:00. Reason: Fixed a little thing when playes closes the menu.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
mabaclu
Senior Member
Join Date: Jun 2010
Location: Portugal
Old 09-13-2012 , 15:29   Re: [sql] menu
Reply With Quote #8

For what you need use lucas' code.
__________________
mabaclu is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 09-13-2012 , 19:47   Re: [sql] menu
Reply With Quote #9

yes lucas, thats exactly what I want. change 'pro classic' to another name and change IP related to that menu item thru website.

can you do that for me. Ill pay of course
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 09-13-2012 at 19:48.
avril-lavigne is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 09-13-2012 , 20:32   Re: [sql] menu
Reply With Quote #10

I already posted the code , install it , create the database with data already posted and done , post your server name and your ips and plugin will do all.

GL and , repost if you have any problem.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.

Last edited by lucas_7_94; 09-13-2012 at 20:33.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
Reply


Thread Tools
Display Modes

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 08:13.


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