Raised This Month: $ Target: $400
 0% 

[HELP] Fast, please. How to get player id?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DaxProxy
Senior Member
Join Date: Sep 2007
Old 04-05-2009 , 08:41   [HELP] Fast, please. How to get player id?
Reply With Quote #1

PHP Code:
public QueryVip(iFailStateHandle:hQueryszError[], iErrnumcData[], iSizeFloat:fQueueTime)
{
    if( 
iFailState != TQUERY_SUCCESS )
    {
        return 
log_amx("[Kz-Arg] SQL: SQL Error #%d - %s"iErrnumszError)
    }
    
    if( 
SQL_MoreResults(hQuery) )
    {
        new 
resultado[2][192]
        new 
punktid
        SQL_ReadResult
(hQuery0resultado[0], 191)
        
SQL_ReadResult(hQuery1resultado[1], 191)
        
punktid str_to_num(resultado[0]) 
    if (
punktid >= 50)
    {
        
client_print(0print_chat"Punktide arv: %s!"resultado[0]) 
        
client_print(0print_chat"Sa ostsid 50 punkti eest endale VIPi!"resultado[0]) 
     }
    else
    {
        
client_print(0print_chat"Sul ei ole piisavalt punkte (%s)!"resultado[0]) 
     }
    }
    return 
PLUGIN_CONTINUE    

QueryVip(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime, id)

If i put ID in there, i get ID=0 Which is not right. Now, resultado[1] is user's name...so is there any way i can get user id from user's name?
DaxProxy is offline
Old 04-05-2009, 08:44
One
This message has been deleted by One. Reason: loel???
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-05-2009 , 08:52   Re: [HELP] Fast, please. How to get player id?
Reply With Quote #3

cmd_target()
__________________
fysiks is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 04-05-2009 , 08:58   Re: [HELP] Fast, please. How to get player id?
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
lol? idk why i deleted my post :-))) the same
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 04-05-2009 , 09:41   Re: [HELP] Fast, please. How to get player id?
Reply With Quote #5

get_user_authid
__________________
alan_el_more is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-05-2009 , 09:45   Re: [HELP] Fast, please. How to get player id?
Reply With Quote #6

Written by |PJ| Shorty
PHP Code:
stock select_user_db(id
{
    new 
data[1]
    
data[0]=id
    formatex
(g_Cache,1023,SEARCH_STEAMID,g_authid[id]);
    
SQL_ThreadQuery(dbc,"SelectHandle",g_Cache,data,sizeof data);
    
server_print"Search for player in db");
}

public 
SelectHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
        return 
set_fail_state("Could not connect to SQL database.");
    else if(
FailState == TQUERY_QUERY_FAILED)
        return 
set_fail_state("SQL Query failed.");
    if(
Errcode)
        return 
log_amx("SQL Error on query: %s",Error);
    
    new 
id=Data[0]
    if(!
SQL_MoreResults(Query)) {
        
//steamid doesn´t exists in db, insert it with status=0 and current timestamp
        
insert_user_db(id,0,get_systime())
        
        return 
PLUGIN_CONTINUE
    
}
    
g_DBstatus[id]=SQL_ReadResult(Query,0)
    
g_DBtimestamp[id]=SQL_ReadResult(Query,1)
    
    
// player is in db, do what you want with the info now
    // values from db stored in "g_DBstatus" and "g_DBtimestamp" vars
    /*
    ...
    //after your code, update the db entry
    update_user_db(id,status,timestamp)
    */
    
    
return PLUGIN_CONTINUE;

__________________

Last edited by Bugsy; 04-05-2009 at 10:48.
Bugsy is offline
DaxProxy
Senior Member
Join Date: Sep 2007
Old 04-05-2009 , 13:51   Re: [HELP] Fast, please. How to get player id?
Reply With Quote #7

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

new Handle:g_SqlTuple
new Handle:SqlConnection
new g_Error[512]

public 
plugin_init() 

    
register_plugin("SMS""SQL""ReymonARG")
    
register_clcmd("say /punkte""func_get_punkte")
    
register_clcmd("say /ostavip""func_get_vip")
    
    
set_task(0.2"plugin_sql")
}

public 
plugin_sql()
{
    new 
host[64], user[64], pass[64], db[64]
    
    
get_cvar_string("amx_sql_host"host63)
    
get_cvar_string("amx_sql_user"user63)
    
get_cvar_string("amx_sql_pass"pass63)
    
get_cvar_string("amx_sql_db"db63)
    
    
g_SqlTuple SQL_MakeDbTuple("Fr546e""frie456a""sa567a""friee45632a")
    
    new 
ErrorCode
    SqlConnection 
SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
    
    if(!
SqlConnection
    {
        
server_print("[Kz-Arg] SQL: Could not connect to SQL database.!")
        
log_amx("[Kz-Arg] SQL: Could not connect to SQL database.")
        return 
pause("a")
    }
    
    
set_task(300.0"func_get_punkte"54564__"b")
    
set_task(300.0"func_get_vip"54564__"b")
    
    return 
PLUGIN_CONTINUE
}

public 
func_get_punkte(id)
{
    new 
createinto[1001]
    new 
name[32]
    
get_user_info(id"name"name,31)
     
formatex(createinto1000"SELECT `punktid`, `name` FROM `ur_users` WHERE `name`='%s'",name)
    
SQL_ThreadQuery(g_SqlTuple"QueryHandler"createinto)
}



public 
QueryHandler(iFailStateHandle:hQueryszError[], iErrnumcData[], iSizeFloat:fQueueTime)
{
    if( 
iFailState != TQUERY_SUCCESS )
    {
        return 
log_amx("[Kz-Arg] SQL: SQL Error #%d - %s"iErrnumszError)
    }
    
    if( 
SQL_MoreResults(hQuery) )
    {
        new 
resultado[2][192]
        
SQL_ReadResult(hQuery0resultado[0], 191)
        
SQL_ReadResult(hQuery1resultado[1], 191)
        
        
client_print(0print_chat"Sul on %s punkti!"resultado[0]) 
    }
    
    return 
PLUGIN_CONTINUE    


public 
func_get_vip(id)
{
    new 
createinto[1001]
    new 
name[32]
    
get_user_info(id"name"name,31)
     
formatex(createinto1000"SELECT `punktid`, `name` FROM `ur_users` WHERE `name`='%s'",name)
    
SQL_ThreadQuery(g_SqlTuple"QueryVip"createinto)
}

public 
QueryVip(iFailStateHandle:hQueryszError[], iErrnumcData[], iSizeFloat:fQueueTime)
{
        new 
resultado[2][192]
        new 
punktid
    
if( iFailState != TQUERY_SUCCESS )
    {
        return 
log_amx("[Kz-Arg] SQL: SQL Error #%d - %s"iErrnumszError)
    }
    
    if( 
SQL_MoreResults(hQuery) )
    {
        
read_argv(1arg31)
        
SQL_ReadResult(hQuery0resultado[0], 191)
        
SQL_ReadResult(hQuery1resultado[1], 191)
        
punktid str_to_num(resultado[0]) 
    if (
punktid >= 50)
    {
        
client_print(0print_chat"Idip: %i"id)
        
client_print(0print_chat"ArgS: %s"id)
        
client_print(0print_chat"ArgD: %d"id)
        
client_print(0print_chat"Punktide arv: %s!"resultado[0]) 
        
client_print(0print_chat"Sa ostsid 50 punkti eest endale VIPi!"resultado[0]) 


        
cs_set_user_vip(1)
HereI need to define USERID in cs_set_user_vip...but HOWHow can i get current user's id?

     }
    else
    {
        client_print(0, print_chat, "Sul ei ole piisavalt punkte (%s)!", resultado[0]) 
     }
    }
    return PLUGIN_CONTINUE    


Last edited by DaxProxy; 04-05-2009 at 14:10.
DaxProxy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-05-2009 , 14:01   Re: [HELP] Fast, please. How to get player id?
Reply With Quote #8

Before addressing that, you need to look at your 2 functions that are called with set_task: func_get_punkte and func_get_vip

Neither of these functions are passed a players ID so there is no way to pass a player id to the SQL handler.

You are also using the same task id for both tasks. Make them different, 54564 and 54565 would work.
__________________
Bugsy is offline
DaxProxy
Senior Member
Join Date: Sep 2007
Old 04-05-2009 , 14:08   Re: [HELP] Fast, please. How to get player id?
Reply With Quote #9

Wait, so there is no way to pass player's ID to SQL handler?

I am new at Pawn...ive programmed VB, PHP, Delphi...but this Pawn...it's killin me.
DaxProxy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-05-2009 , 14:28   Re: [HELP] Fast, please. How to get player id?
Reply With Quote #10

I'm not 100% sure of the logic behind your plugin but to get which player is VIP you can use the below. You will need to include cstrike module.

PHP Code:
g_MaxPlayers get_maxplayers();

public 
GetVIP()
{
    for ( new 
<= g_MaxPlayers i++ )
    {
        if ( 
cs_get_user_vip(i) )
        {
            return 
i;
        }
    }
    
    return 
0;

__________________
Bugsy 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 02:15.


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