Raised This Month: $ Target: $400
 0% 

Need help :) calculanting maps + sql


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Metanabol
Member
Join Date: Feb 2009
Old 11-05-2009 , 03:38   Need help :) calculanting maps + sql
Reply With Quote #1

Hello, i'm thinkink about making plugin, who calculates maps.
e.g. if map is de_dust2_2x2 plugin write name de_dust2_2x2 to sql table like that:
Code:
de_dust2_2x2 10
de_assault 21
de_dust2 61
i want to make top 5 favourite maps in server and show this in my website based on php-fusion...


So, from that i must start making plugin... because never worked with sql..


sry for bad english.
Metanabol is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-05-2009 , 11:17   Re: Need help :) calculanting maps + sql
Reply With Quote #2

Code:
#include < amxmodx > #include < sqlx > new const TABLE_NAME[ ] = ""; new const KEY_MAPNAME[ ] = ""; new const KEY_MAPCOUNT[ ] = ""; new Handle:g_hSqlTuple; new g_szQuery[ 128 ]; new g_szMap[ 64 ]; public plugin_init( ) {     g_hSqlTuple = SQL_MakeStdTuple( );         formatex( g_szQuery, 127, "CREATE TABLE IF NOT EXISTS `%s` ( `%s` VARCHAR(64) NOT NULL, `%s` INT(10) NOT NULL );",         TABLE_NAME, KEY_MAPNAME, KEY_MAPCOUNT );         SQL_ThreadQuery( g_hSqlTuple, "QueryCreateTable", szQuery ); } public QueryCreateTable( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) {     if( iFailState == TQUERY_CONNECT_FAILED     || iFailState == TQUERY_QUERY_FAILED ) {         log_amx( "Query failed on create table." );     } else {         get_mapname( g_szMap, 63 );         strtolower( g_szMap, 63 );                 formatex( g_szQuery, 127, "SELECT `%s` FROM `%s` WHERE `%s` = '%s';",             KEY_MAPCOUNT, TABLE_NAME, KEY_MAPNAME, g_szMap );                 SQL_ThreadQuery( g_hSqlTuple, "QuerySelectMapCount", szQuery );     } } public QuerySelectMapCount( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) {     if( iFailState == TQUERY_CONNECT_FAILED     || iFailState == TQUERY_QUERY_FAILED ) {         log_amx( "Query failed on select map count." );     } else {         if( SQL_NumResults( hQuery ) ) {             new iCount = SQL_ReadResult( hQuery, 0 ) + 1;                         formatex( g_szQuery, 127, "UPDATE `%s` SET `%s` = `%s` + 1 WHERE `%s` = '%s';",                 TABLE_NAME, KEY_MAPCOUNT, KEY_MAPCOUNT, KEY_MAPNAME, g_szMap );         } else {             formatex( g_szQuery, 127, "INSERT INTO `%s` ( `%s`, `%s` ) VALUES ( '%s', 1 );",                 TABLE_NAME, KEY_MAPNAME, KEY_MAPCOUNT, g_szMap );         }                 SQL_ThreadQuery( g_hSqlTuple, "QuerySetMapCount", g_szQuery );     } } public QuerySelectMapCount( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) {     if( iFailState == TQUERY_CONNECT_FAILED     || iFailState == TQUERY_QUERY_FAILED ) {         log_amx( "Query failed on set map count." );     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 17:35.


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