Problema Mysql

Modificari necesare ale pluginurilor

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
User avatar
Doctor whO? <3
Membru, skill +2
Membru, skill +2
Posts: 794
Joined: 21 Jun 2013, 11:40
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Reputatie: Fost Membru Club eXtreamCS (doua luni)
Has thanked: 90 times
Been thanked: 12 times
Contact:

29 Jul 2019, 10:22

Salut, am un plugin mysql dar refuza sa se connecteze la baza de date ...

Code: Select all

#include AmxModX
#include SqlX

native sdm_get_user_skills_health( pId );
native sdm_get_user_skills_armor( pId );
native sdm_get_user_skills_vampire( pId );

native sdm_set_user_skills_health( pId, iNum );
native sdm_set_user_skills_armor( pId, iNum );
native sdm_set_user_skills_vampire( pId, iNum );

native sdm_set_user_money( pId, iMoney );
native sdm_get_user_money( pId );

native sdm_set_user_exp( pId, iNum );
native sdm_get_user_true_exp( pId );

enum _: eData_SaveMethod
{
SaveMethod_SteamId = 0,
SaveMethod_Ip,
SaveMethod_Name
};

#define DB_SAVE	2
#define FP_BOOL FP_CELL

#if ( DB_SAVE > 2 ) || ( DB_SAVE < 1 )
#error "macros 'DB_SAVE' not valid."
#endif

new Handle: g_hSqlTuple;
new g_szPluginSaveMethod[ 16 ];

new g_szTableName[ 16 ];
new g_iSaveMethod, g_iForwardSQLoad;
new const g_szSaveMethod[ 3 ][] = { "SteamId", "Ip", "Name" };

public plugin_natives()
register_native( "sdm_save_user_info", "SaveUserInfo", 1 );

public plugin_init()
{
	// ???? ??? ?? setmaster!
	register_plugin( "[SurfDm] MySQL Save" );
	
	// forward sdm_sql_load_player_info( pId, iHealthLvl, iArmorLvl, iVampireLvl, iExp, iMoney, bool: bIsNewPlayer );
	g_iForwardSQLoad = CreateMultiForward( "sdm_sql_load_player_info", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_BOOL );
	
	set_task( 0.2, "LoadDataBase" );
}

public LoadDataBase()
{
	g_iSaveMethod = get_cvar_num( "sdm_sql_method" );
	log_amx( "MySQL Save Method: ^"%s^"", g_szSaveMethod[ g_iSaveMethod ] );
	
	DB_GetKeyName( g_szPluginSaveMethod, 15 ); 
	switch( DB_SAVE )
	{
		case 1: SQL_SetAffinity( "sqlite" );
			case 2: SQL_SetAffinity( "mysql" );
		}
	
	new szHost[ 64 ], szUser[ 16 ], szPassword[ 32 ], szDataBaseName[ 16 ];
	get_cvar_string( "sdm_sql_host", szHost, charsmax( szHost ) );
	get_cvar_string( "sdm_sql_user", szUser, charsmax( szUser ) );
	get_cvar_string( "sdm_sql_password", szPassword, charsmax( szPassword ) );
	get_cvar_string( "sdm_sql_db_name", szDataBaseName, charsmax( szDataBaseName ) );
	get_cvar_string( "sdm_sql_table", g_szTableName, charsmax( g_szTableName ) );
	
	new szCharPassword[ 32 ];
	for( new iPos; iPos <= strlen( szPassword ); iPos++ )
		szCharPassword[ iPos ] = '*';
	
	log_amx( "Host: ^"%s^"", szHost );
	log_amx( "User: ^"%s^"", szUser );
	log_amx( "Passwrod: %s", szCharPassword );
	log_amx( "DataBase Name: ^"%s^"", szDataBaseName );
	log_amx( "Table: ^"%s^"", g_szTableName );
	
	new iErrorId, szError[ 512 ], Handle: hSqlConnection = SQL_Connect( ( g_hSqlTuple = SQL_MakeDbTuple( szHost, szUser, szPassword, szDataBaseName ) ), iErrorId, szError, charsmax( szError ) );
	
	if( hSqlConnection == Empty_Handle )
		set_fail_state( szError );
	
	new szBuffer[ 512 ];
	format( szBuffer, charsmax( szBuffer ), 
	"CREATE TABLE IF NOT EXISTS `%s` \
	(%s varchar(64), `health` INT(4),`armor` INT(4),`vamp` INT(4),`exp` INT(8),`money` INT(8));", g_szTableName, g_szPluginSaveMethod );
	
	new Handle: iQueries = SQL_PrepareQuery( hSqlConnection, szBuffer ); 
	if( !SQL_Execute( iQueries ) )
	{
		SQL_QueryError( iQueries, szError,charsmax( szError ) );
		set_fail_state( szError ); 
	}
	
	SQL_FreeHandle( iQueries );
	SQL_FreeHandle( hSqlConnection );
}

public client_putinserver( pId )
{
	new iData[ 1 ]; iData[ 0 ] = pId; 
	new szKey[ 35 ]; DB_GetKey( pId, szKey, charsmax( szKey ) );
	new szTemp[ 512 ]; format( szTemp, charsmax( szTemp ), "SELECT * FROM `%s` WHERE (`%s`.`%s` = '%s')", g_szTableName, g_szTableName, g_szPluginSaveMethod, szKey );
	SQL_ThreadQuery( g_hSqlTuple, "register_client", szTemp, iData, 1 );
}

public client_disconnect( pId )
	SaveUserInfo( pId );

public SaveUserInfo( pId )
{
	new szKey[ 35 ]; DB_GetKey( pId, szKey, charsmax( szKey ) );
	
	#define SaveInfo(%1,%2) format(szTemp,charsmax(szTemp),"UPDATE `%s` SET `%s` = '%i' WHERE `%s`.`%s` = '%s';",g_szTableName,%2,%1,g_szTableName,g_szPluginSaveMethod,szKey);SQL_ThreadQuery(g_hSqlTuple,"IgnoreHandle",szTemp)
	
	new szTemp[ 512 ];
	
	SaveInfo( sdm_get_user_skills_health( pId ), "health" );
	SaveInfo( sdm_get_user_skills_armor( pId ), "armor" );
	SaveInfo( sdm_get_user_skills_vampire( pId ), "vamp" );
	
	SaveInfo( sdm_get_user_true_exp( pId ), "exp" );
	SaveInfo( sdm_get_user_money( pId ), "money" );
	
	#undef SaveInfo
}

public register_client( iFailState, Handle: hQuery, szErrorBuffer[], iErrorCode, iData[], iDataSize )
{
	switch( iFailState )
	{
		case TQUERY_CONNECT_FAILED: log_amx( "[SurfDm|DataBase] Not connected. Info: [%d] ^"%s^"", iErrorCode, szErrorBuffer );
			case TQUERY_QUERY_FAILED:	log_amx( "[SurfDm|DataBase] Load Query failed. [%d] ^"%s^"", iErrorCode, szErrorBuffer );
		}
	
	new pId = iData[ 0 ];
	if( SQL_NumResults( hQuery ) < 1 ) 
	{
		new szKey[ 35 ]; DB_GetKey( pId, szKey, charsmax( szKey ) );
		
		new szTemp[ 512 ];
		format( szTemp, charsmax( szTemp ), "INSERT INTO `%s` \
		( `%s`, `health`, `armor`, `vamp`, `exp`, `money` ) VALUES ( '%s', '0', '0', '0', '0', '100' );", g_szTableName, g_szPluginSaveMethod, szKey );
		
		SQL_ThreadQuery( g_hSqlTuple, "IgnoreHandle", szTemp );
		
		static iForwardReturn; ExecuteForward( g_iForwardSQLoad, iForwardReturn, pId, 0, 0, 0, 0, 100, true );
	} 
	else 
	{
		#define LOAD_SQL_INFO(%1) iReturn[ ( %1 - 1 ) ] = SQL_ReadResult( hQuery, %1 )
		new iReturn[ 5 ];
		
		LOAD_SQL_INFO( 1 );
		LOAD_SQL_INFO( 2 );
		LOAD_SQL_INFO( 3 );
		LOAD_SQL_INFO( 4 );
		LOAD_SQL_INFO( 5 );
		
		sdm_set_user_skills_health( pId, iReturn[ 0 ] );
		sdm_set_user_skills_armor( pId, iReturn[ 1 ] );
		sdm_set_user_skills_vampire( pId, iReturn[ 2 ] );
		
		sdm_set_user_exp( pId, iReturn[ 3 ] );
		sdm_set_user_money( pId, iReturn[ 4 ] );
		
		static iForwardReturn; ExecuteForward( g_iForwardSQLoad, iForwardReturn, pId, iReturn[ 0 ], iReturn[ 1 ], iReturn[ 2 ], iReturn[ 3 ], iReturn[ 4 ], false );
		#undef LOAD_SQL_INFO
	}
	
	return PLUGIN_HANDLED;
}

public IgnoreHandle( iFailState, Handle: hQuery, szErrorBuffer[], iErrorCode, iData[], iDataSize ) {
SQL_FreeHandle( hQuery ); return PLUGIN_HANDLED; }

public plugin_end() {
	if ( g_hSqlTuple )
	SQL_FreeHandle( g_hSqlTuple ); }

DB_GetKey( pId, szKey[], iLen )
{
switch( g_iSaveMethod )
{
	case SaveMethod_SteamId:
	{
		get_user_name( pId, szKey, iLen );
		replace_all( szKey, iLen, "'", "''" );
	}
	case SaveMethod_Ip: get_user_ip( pId, szKey, iLen, 1 );
		case SaveMethod_Name: get_user_authid( pId, szKey, iLen );
		}
}

DB_GetKeyName( g_szPluginSaveMethod[], iLen )
{
switch( g_iSaveMethod )
{
	case SaveMethod_SteamId:	copy( g_szPluginSaveMethod, iLen, "player_name" );
		case SaveMethod_Ip:			copy( g_szPluginSaveMethod, iLen, "player_ip" );
			case SaveMethod_Name:		copy( g_szPluginSaveMethod, iLen, "player_steamid" );
		}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1252\\ deff0\\ deflang1033{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
*/
Am facut totul cum trebuie insa refuza sa se connecteze..

L 07/29/2019 - 11:20:13: [surfdm_save.amxx] MySQL Save Method: "Name"
L 07/29/2019 - 11:20:13: [surfdm_save.amxx] Host: "188.212.101.22"
L 07/29/2019 - 11:20:13: [surfdm_save.amxx] User: "mysqldbc"
L 07/29/2019 - 11:20:13: [surfdm_save.amxx] Passwrod: ****************
L 07/29/2019 - 11:20:13: [surfdm_save.amxx] DataBase Name: "mysqldbc_surf"
L 07/29/2019 - 11:20:13: [surfdm_save.amxx] Table: "admins"
L 07/29/2019 - 11:20:14: [AMXX] Plugin ("surfdm_save.amxx") is setting itself as failed.
L 07/29/2019 - 11:20:14: [AMXX] Plugin says: Can't connect to MySQL server on '188.212.101.22' (111)
L 07/29/2019 - 11:20:14: [AMXX] Run time error 1 (plugin "surfdm_save.amxx") - forced exit


L 07/29/2019 - 11:08:49: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20190729.log")
L 07/29/2019 - 11:08:49: [AMXX] Plugin ("surfdm_save.amxx") is setting itself as failed.
L 07/29/2019 - 11:08:49: [AMXX] Plugin says: Can't connect to MySQL server on '188.212.101.22' (111)
L 07/29/2019 - 11:08:49: [AMXX] Run time error 1 (plugin "surfdm_save.amxx") - forced exit
eXtreamSHOP
User avatar
DevilBoy.eXe
Moderator ajutator
Moderator ajutator
Posts: 1374
Joined: 05 Jun 2016, 22:04
Detinator Steam: Da
Detinator server CS: GO.WARED.RO
SteamID: DevilBoy_eXe
Reputatie: Moderator ajutator
Fond eXtream: -1
Location: beyond the time
Has thanked: 6 times
Been thanked: 16 times
Contact:

29 Jul 2019, 11:03

Ce fel de baza de date ai?
Daca ai creat-o din cpanel-ul de la vreun website probabil nu permite conexiuni externe
My Steam Profile (from SteamDB)

  • Worth: 1283€ (333€ with sales)
  • Games owned: 228
  • Games played: 126 (55%)
  • Hours on record: 2,371.7h
User avatar
Doctor whO? <3
Membru, skill +2
Membru, skill +2
Posts: 794
Joined: 21 Jun 2013, 11:40
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Reputatie: Fost Membru Club eXtreamCS (doua luni)
Has thanked: 90 times
Been thanked: 12 times
Contact:

29 Jul 2019, 15:52

DevilBoy.eXe wrote:
29 Jul 2019, 11:03
Ce fel de baza de date ai?
Daca ai creat-o din cpanel-ul de la vreun website probabil nu permite conexiuni externe
Exact asa am facut. Voi trimite un tiket la cei de la host sa vad ce rezolva. + Daca un moderator vede acest topic sa il mute la modificări pluginuri.
Filiq_
Membru, skill +2
Membru, skill +2
Posts: 619
Joined: 02 Nov 2014, 18:21
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Reputatie: Fost Scripter eXtreamCS
Fond eXtream: 0
Location: Constanta
Has thanked: 28 times
Been thanked: 13 times

29 Aug 2019, 04:39

daca primiti acest timp de eroare la mysql:

Code: Select all

07/29/2019 - 11:20:14: [AMXX] Plugin says: Can't connect to MySQL server on '188.212.101.22' (111)
o puteti primi din 2 motive, primul motiv este pentru ca webhostul de pe care ati facut baza de date nu permite conexiuni externe(cum a spus si devilboy) si al 2 lea motiv nu ati dat remote la acel ip, intrati in cpanel si mergeti la mysql remote(ceva in genul) si adaugati acel ip din eroare acolo.
Post Reply

Return to “Modificari pluginuri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests