Raised This Month: $ Target: $400
 0% 

global values, player's indexes


Post New Thread Reply   
 
Thread Tools Display Modes
worldspawn
Senior Member
Join Date: Aug 2009
Location: Russia, Yekaterinburg
Old 11-30-2009 , 15:31   Re: global values, player's indexes
Reply With Quote #11

if you ever worked with sql
PHP Code:
#include <amxmodx>  
#include <amxmisc>
#include <sqlx>

new Handle:g_h_SqlHandle:g_h_Sql_Connectbool:g_b_Connected_SQL false
new g_szResult[33][32]

public 
plugin_init() 

    
register_plugin("get_some_damn_results_and_display_them""6.6""worldspawn")

    
register_clcmd("say result""get_result")


public 
plugin_cfg()
{
    new 
s_Error[128], i_Error

    g_h_Sql 
SQL_MakeDbTuple("--host--""--dbuser--""--dbpass--""--dbname--")  

    
g_h_Sql_Connect SQL_Connect(g_h_Sqli_Errors_Errorcharsmax(s_Error))

    if (
g_h_Sql_Connect == Empty_Handle)
    {
        
server_print("Can't connect to MySQL, error: %s"s_Error)
        
log_amx("Can't connect to MySQL, error: %s"s_Error)

        return 
PLUGIN_HANDLED
    
}else
        
g_b_Connected_SQL true

    
return PLUGIN_CONTINUE
}

public 
get_result(id)
{
    if (
g_b_Connected_SQL
    {
        new 
Handle:queryauthid[33], s_Error[128]

        
get_user_authid(idauthidcharsmax(authid))

        
query SQL_PrepareQuery(g_h_Sql_Connect"SELECT column FROM table WHERE (authid='%s')"authid)

        if (!
SQL_Execute(query))
        {
            
SQL_QueryError(querys_Errorcharsmax(s_Error))
            
log_amx("Can't execute MySQL query, error: %s"s_Error)
        }else{
            new 
i_Column

            i_Column 
SQL_FieldNameToNum(query"column")

            while (
SQL_MoreResults(query))
            {
                
SQL_ReadResult(queryi_Columng_szResult[id], charsmax(g_szResult[]))

                if (
equal(g_szResult[id], ""))
                {
                }else{
                    
remove_task(id);
                    
set_task(2.0"showHud"id__"b")
                }

                
SQL_NextRow(query)
            }
            
SQL_FreeHandle(query)
        }
    }
}

public 
showHud(id)
{
    
set_hudmessage(210105300.010.760_1.90.10.1, -1)
    
show_hudmessage(id"Your result: %s "g_szResult[id])
}

public 
plugin_end()
{
    
SQL_FreeHandle(g_h_Sql_Connect)
    
SQL_FreeHandle(g_h_Sql)

it works for me only now, not for other players

so when player types "result" his some stats will load and i want them to be shown only to him
and that's like for all players

Last edited by worldspawn; 11-30-2009 at 15:52.
worldspawn is offline
Send a message via ICQ to worldspawn Send a message via Skype™ to worldspawn
Old 12-01-2009, 04:53
Napalmy
This message has been deleted by YamiKaitou. Reason: random post
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 19:52.


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