Raised This Month: $ Target: $400
 0% 

Solved Print stuff from database


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
4ever16
Veteran Member
Join Date: Apr 2015
Old 06-04-2018 , 10:58   Print stuff from database
Reply With Quote #1

I have a database which is called player_player. In that database i have following.

Username | Steam id | Kills | Deaths | Headshots | Points

I have a plugin which prints out my points like this: [SERVERNAME] Your points 1000
I would like it to print out more stuff like kills & deaths but dont have a clue how to.


PHP Code:
public showPlayerRank(id)
{
    static 
query[512];
    
formatex(querycharsmax(query), "SELECT COUNT(*) FROM player_player WHERE points > '%d'"pPoints[id]);
    
log_amx(query)
    static 
data[2];
    
data[0] = id;
    
    
SQL_ThreadQuery(g_hTuple"QueryLoadRank"querydatasizeof(data));
    return 
PLUGIN_HANDLED;
}

public 
QueryLoadRank(failstateHandle:hQueryerror[], errnumdata[], sizeFloat:queuetime)
{
    if( 
failstate == TQUERY_CONNECT_FAILED
    
|| failstate == TQUERY_QUERY_FAILED )
    {
        
set_fail_state(error);
    }
    else
    {
        new 
id data];
        
        if(
SQL_NumResults(hQuery))
        {
            new 
colRank SQL_ReadResult(hQuery0) + 1;
            
client_printcolor(id"/y[/ctr%s/y] Your points /ctr%d"PREFIXcolRank);
        }
    }

Extra stuff in the script.
PHP Code:
    pKills[id] = 0;
    
pDeaths[id] = 0;
    
pHeadshots[id] = 0;
    
pPoints[id] = 0
////////////////////////////////////////////////////////////////////////////////////////////////////////

I have tryed following. But it prints out wrong number, that numbers doesnt exist in database so what am i doing wrong and how to fix it?

PHP Code:
    formatex(querycharsmax(query), "SELECT COUNT(*) FROM player_player WHERE points > '%d'"pKills[id]); 

Last edited by 4ever16; 06-04-2018 at 14:41.
4ever16 is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 06-04-2018 , 13:11   Re: Print stuff from database
Reply With Quote #2

Quote:
Originally Posted by 4ever16 View Post
Extra stuff in the script.
PHP Code:
    pKills[id] = 0;
    
pDeaths[id] = 0;
    
pHeadshots[id] = 0;
    
pPoints[id] = 0
why are you messing with the sql query formatting when you have global arrays that store the information you need to print?

also that plugin doesn't print your points from the database, instead it prints the amount of entries in the table that have more points than you

Last edited by jimaway; 06-04-2018 at 13:11.
jimaway is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 06-04-2018 , 13:31   Re: Print stuff from database
Reply With Quote #3

Dont really understand what you are saying but...

For example.

If i edit the code to this: There is a table called kills.
PHP Code:
    formatex(querycharsmax(query), "SELECT COUNT(*) FROM mix_players WHERE kills = '%d'"pKills[id]); 
In the console it gets the number correctly. The number is 7 thats my kill count.
But when it prints out it to the server it says 2.

Whats the error?

Last edited by 4ever16; 06-04-2018 at 13:49.
4ever16 is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 06-04-2018 , 13:51   Re: Print stuff from database
Reply With Quote #4

Ok now i understand how it works.

Player 1: 0 kills
Me: 7 kills.
Player 3: 14 kills.

It prints out 2 because it counts the place im in.

So instead of this i would just like to print out my actual kills. Any help?
4ever16 is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 06-04-2018 , 14:41   Re: Print stuff from database
Reply With Quote #5

Never mind solved it.
4ever16 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 04:42.


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