Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

[KOSZ] Mysql help


  • Zamknięty Temat jest zamknięty
1 odpowiedź w tym temacie

#1 General1999

    Nowy

  • Nowy

Reputacja: 0
Nowy

  • Postów:1
  • Imię:General1999
Offline

Napisano 26.04.2015 01:43

#include < amxmodx >
#include < fun >
#include < cstrike >
#include < hamsandwich >
#include < fakemeta >
#include < dhudmessage >
#include < colorchat >
#include < sqlx >

new g_Packs[33];
new g_Exp[33];
new g_Levels[ 33 ]
new g_Classes[ 33 ]
new bool:iStart[33];
new bool:Fimdaronda;
new maxplayers;

new g_iCurrentKills[ 33 ];
new g_Kills[ 33 ], g_Deaths[ 33 ], g_HeadShots[ 33 ], g_KnifeKills[ 33 ];
new g_KnifeDeaths[ 33 ], g_GrenadeKills[ 33 ], g_GrenadeDeaths[ 33 ];
new g_DefusedBombs[ 33 ], g_WonRounds[ 33 ], g_BombExplosions[ 33 ];

new l_suicide, l_Death, l_Headshot, l_Knife, l_Grenade, l_Terrorists, l_CounterTerrorists;
new w_Kill, w_Headshot, w_Knife, w_Grenade, w_Terrorists, w_CounterTerrorists, w_4kills, w_5kills;

new horapontos, plantarpontos, explodirpontos, defusarpontos;

new Trie:g_tIgnoredAuthID; // hltv, bots and non-steam users

#define TASK_HUD                4155364
#define IsPlayer(%1)            (1 <= %1 <= 32)
#define PACKS_START             50
#define MAX_PLAYERS		32

new tag[]="!tworkandplay.pt |!n";

/******* MYSQL *******/
new Handle:g_SqlConnection;
new Handle:g_SqlTuple;
new g_Error[512];
new g_authed[33];
new g_sql_ready = false;
new bool:g_loaded[33];

new const CLASSES[ 5 ][ ] = {
	"BOT",
	"NOOB",
	"GAMER",
	"LEET",
	"TOP"
}

new const LEVELS[ 5 ] = {
	500,
	1200,
	1800,
	2500,
	100000 /* high value (not reachable) */
}

public plugin_init()
{
	register_plugin("G-Packs", "0.0.1", "General1999")

	maxplayers	= get_maxplayers();
	set_task( 0.1, "MySql_Init" )

	/*****************  Packs   ********************/
	register_logevent( "EventRoundEnd", 2, "1=Round_End" )

	RegisterHam(Ham_Spawn, "player", "Fwd_PlayerSpawn_Post", 1)

	register_event( "HLTV", "EventNewRound", "a", "1=0", "2=0" )
	register_event( "SendAudio", "TerroristsWin", "a", "2&%!MRAD_terwin" )
	register_event( "SendAudio", "CounterTerroristsWin", "a", "2&%!MRAD_ctwin" )

	l_Death		= register_cvar( "cl_lpDeath", 			"5" )
	l_suicide	= register_cvar( "cl_lpsuicide", 		"5" )
	l_Headshot	= register_cvar( "cl_lpHeadshot", 		"5" )
	l_Knife		= register_cvar( "cl_lpKnife", 			"5" )
	l_Grenade		= register_cvar( "cl_lpGrenade", 	"5" )
	l_Terrorists		= register_cvar( "cl_lpTerrorists", 	"5" )
	l_CounterTerrorists	= register_cvar( "cl_lpCTerrorists", 	"5" )

	w_Kill		= register_cvar( "cl_wpKill", 			"5" )
	w_Headshot	= register_cvar( "cl_wpHeadshot", 		"5" )
	w_Knife		= register_cvar( "cl_wpKnife", 			"5" )
	w_4kills	= register_cvar( "cl_wp4kills", 			"5" )
	w_5kills	= register_cvar( "cl_wp5kills", 			"5" )
	w_Grenade		= register_cvar( "cl_wpGrenade", 	"5" )
	w_Terrorists		= register_cvar( "cl_wpTerrorists", 	"5" )
	w_CounterTerrorists	= register_cvar( "cl_wpCTerrorists", 	"5" )

	horapontos	= register_cvar( "cl_wphora", 			"5" )
	plantarpontos	= register_cvar( "cl_wpplantar", 		"5" )
	explodirpontos	= register_cvar( "cl_wpexplodir", 		"5" )
	defusarpontos	= register_cvar( "cl_wpdefusar", 		"5" )

	g_tIgnoredAuthID = TrieCreate( )
	TrieSetCell( g_tIgnoredAuthID, "VALVE_ID_LAN", 1 )
	TrieSetCell( g_tIgnoredAuthID, "VALVE_ID_PENDING", 1 )
	TrieSetCell( g_tIgnoredAuthID, "STEAM_ID_LAN", 1 )
	TrieSetCell( g_tIgnoredAuthID, "STEAM_ID_PENDING", 1 )
	TrieSetCell( g_tIgnoredAuthID, "BOT", 1 )
	TrieSetCell( g_tIgnoredAuthID, "HLTV", 1 )
}

// KILL PLAYERS
public client_death( iKiller, iVictim, iWpnIndex, iHitPlace, iTK )
{
	if( g_authed[ iKiller ] )
	{
		if( !IsPlayer( iKiller ) || !IsPlayer( iVictim ) )
			return

		new NomeKiller[33], NomeVictim[33];
		get_user_info( iKiller, "name", NomeKiller[ iKiller ], charsmax( NomeKiller[ ] ) )
		get_user_info( iVictim, "name", NomeVictim[ iVictim ], charsmax( NomeVictim[ ] ) )

		/*if( iTK )
		{
			g_Packs[ iKiller ] -= get_pcvar_num( g_iLostPointsTK )
			ClientPrintColor( iKiller, "!g%s!n You have lost!t %i!n point%s by killing a teammate", PREFIX, get_pcvar_num( g_iLostPointsTK ), get_pcvar_num( g_iLostPointsTK ) > 1 ? "s" : ""  )

			return
		}*/

		if( iKiller == iVictim )
		{
			g_Packs[ iKiller ] -= get_pcvar_num( l_suicide )
			g_Exp[ iKiller ] -= random_num(5,20);
			ColorChat( iKiller, NORMAL, "%s Acabas-te de perder !t%i!n ponto%s por te suicidares", tag, get_pcvar_num( l_suicide ), get_pcvar_num( l_suicide ) > 1 ? "s" : ""  )
			g_Deaths[ iKiller ]++

			return
		}

		g_iCurrentKills[ iKiller ]++
		g_Kills[ iKiller ]++
		g_Packs[ iKiller ] += get_pcvar_num( w_Kill )
		g_Exp[ iKiller ] += random_num(5,16);

		ColorChat( iKiller, NORMAL, "%s Acabas-te de ganhar !t%i!n ponto%s por matares %s", tag, get_pcvar_num( w_Kill ), get_pcvar_num( w_Kill ) > 1 ? "s" : "", NomeVictim[ iVictim ] )

		if( g_authed[ iVictim ] )
		{
			g_Deaths[ iVictim ]++
			g_Packs[ iVictim ] -= get_pcvar_num( l_Death )
			g_Exp[ iKiller ] -= random_num(5,16);
			SaveOther(iVictim)
			SaveJBPacks( iVictim, g_Packs[ iVictim ], g_Exp[ iVictim ] )
			ColorChat( iVictim, NORMAL, "%s Acabas-te de perder !t%i!n ponto%s por morreres.", tag, get_pcvar_num( l_Death ), get_pcvar_num( l_Death ) > 1 ? "s" : "" )
		}

		if( iWpnIndex == CSW_HEGRENADE )
		{
			g_Packs[ iKiller ] += get_pcvar_num( w_Grenade )
			g_GrenadeKills[ iKiller]++
			g_Exp[ iKiller ] += random_num(5,38);

			ColorChat( iKiller, NORMAL, "%s Acabas-te de receber !t%i!n ponto%s por matares %s com !g[ !nHE!g ]!n", tag, get_pcvar_num( w_Grenade ), get_pcvar_num( w_Grenade ) > 1 ? "s" : "" ,NomeKiller[ iVictim ] )

			if( g_authed[ iVictim ] )
			{
				g_Packs[ iVictim ] -= get_pcvar_num( l_Grenade )
				g_Exp[ iKiller ] -= random_num(5,38);
				g_GrenadeDeaths[ iVictim ]++
				SaveOther(iVictim)
				SaveJBPacks( iVictim, g_Packs[ iVictim ], g_Exp[ iVictim ] )
				ColorChat( iVictim, NORMAL, "%s Acabas-te de perder !t%i!n ponto%s por morreres com a !g[ !nHE!g ]!n", tag, get_pcvar_num( l_Grenade ), get_pcvar_num( l_Grenade ) > 1 ? "s" : "" )
			}
			return
		}

		if( iWpnIndex == CSW_KNIFE )
		{
			g_Packs[ iKiller ] += get_pcvar_num( w_Knife )
			g_KnifeKills[ iKiller ]++
			g_Exp[ iKiller ] += random_num(5,54);

			ColorChat( iKiller, NORMAL, "%s You earned!t %i!n point%s by killing %s with knife", tag, get_pcvar_num( w_Knife ), get_pcvar_num( w_Knife ) > 1 ? "s" : "" ,NomeVictim[ iVictim ] )

			if( g_authed[ iVictim ] )
			{
				g_Packs[ iVictim ] -= get_pcvar_num( l_Knife )
				g_Exp[ iKiller ] -= random_num(5,54);
				g_KnifeDeaths[ iVictim ]++
				SaveOther(iVictim)
				SaveJBPacks( iVictim, g_Packs[ iVictim ], g_Exp[ iVictim ] )
				ColorChat( iVictim, NORMAL, "%s You have lost!t %i!n point%s for dying with knife", tag, get_pcvar_num( l_Knife ), get_pcvar_num( l_Knife ) > 1 ? "s" : "" )
			}
			return
		}

		if( iHitPlace == HIT_HEAD )
		{
			g_Packs[ iKiller ] += get_pcvar_num( w_Headshot )
			g_HeadShots[ iKiller ]++
			g_Exp[ iKiller ] += random_num(5,54);

			ColorChat( iKiller, NORMAL, "%s You earned!t %i!n point%s by killing %s with a headshot", tag, get_pcvar_num( w_Headshot ), get_pcvar_num( w_Headshot ) > 1 ? "s" : "" ,NomeVictim[ iVictim ] )

			if( g_authed[ iVictim ] )
			{
				g_Packs[ iVictim ] -= get_pcvar_num( l_Headshot )
				g_Exp[ iKiller ] -= random_num(5,54);
				SaveJBPacks( iVictim, g_Packs[ iVictim ], g_Exp[ iVictim ] )
				ColorChat( iVictim, NORMAL, "%s!n You have lost!t %i!n point%s for dying with a headshot", tag, get_pcvar_num( l_Headshot ), get_pcvar_num( l_Headshot ) > 1 ? "s" : "" )
			}
			return
		}
		SaveOther(iKiller)
		SaveJBPacks( iKiller, g_Packs[iKiller], g_Exp[ iKiller ] )
	}
}

// Fim da ronda
public EventRoundEnd( )
	set_task( 0.5, "RoundEndSavepacks" )

public RoundEndSavepacks( )
{
	new Players[ MAX_PLAYERS ]
	new iNum
	new i

	get_players( Players, iNum, "ch" )

	for( --iNum; iNum >= 0; iNum-- )
	{
		i = Players[ iNum ]

		if( g_authed[ i ] )
		{
			if( g_iCurrentKills[ i ] == 4 && get_pcvar_num( w_4kills ) )
			{
				g_Packs[ i ] += get_pcvar_num( w_4kills )
				g_Exp[ i ] += random_num(5,12);
				ColorChat( i, NORMAL, "%s Acabas-te de ganhar !t%i!n ponto%s por matares 4 players durante a roda!g!!n", tag, get_pcvar_num( w_4kills ), get_pcvar_num( w_4kills ) > 1 ? "s" : "" )
			}
			if( g_iCurrentKills[ i ] >= 5 && get_pcvar_num( w_5kills ) )
			{
				g_Packs[ i ] += get_pcvar_num( w_5kills )
				g_Exp[ i ] += random_num(5,22);
				ColorChat( i, NORMAL, "%s Acabas-te de ganhar !t%i!n ponto%s por matares 5 players durante a ronda!g!!n", tag, get_pcvar_num( w_5kills ), get_pcvar_num( w_5kills ) > 1 ? "s" : "" )
			}
			SaveJBPacks( i, g_Packs[ i ], g_Exp[ i ])
		}
	}
}

// equipa vencedor recebe packs
public TerroristsWin( )
{
	if( Fimdaronda )
	{
		return	
	}

	new Players[ MAX_PLAYERS ]
	new iNum
	new i

	get_players( Players, iNum, "ch" )

	for( --iNum; iNum >= 0; iNum-- )
	{
		i = Players[ iNum ]

		if( g_authed[ i ] )
		{
			switch( cs_get_user_team( i ) )
			{
				case( CS_TEAM_T ):
				{
					g_Packs[ i ] += get_pcvar_num( w_Terrorists )
					g_Exp[ i ] += random_num(2,32);
					g_WonRounds[ i ]++
					ColorChat( i, NORMAL, "%s A tua equipa!t (T)!n recebeu !t%i!n ponto%s por ganhar a ronda!", tag, get_pcvar_num( w_Terrorists ), get_pcvar_num( w_Terrorists ) > 1 ? "s" : "" )
				}
				case( CS_TEAM_CT ):
				{
					g_Packs[ i ] -= get_pcvar_num( l_CounterTerrorists )
					g_Exp[ i ] -= random_num(2,32);
					ColorChat( i, NORMAL, "%s A tua equipa!t (CT)!n acabou de perder !t%i!n ponto%s por terem perdido a ronda!", tag, get_pcvar_num( l_CounterTerrorists ), get_pcvar_num( l_CounterTerrorists ) > 1 ? "s" : "" )
				}
			}
		}
	}
	SaveOther(i)
	SaveJBPacks(i, g_Packs[i], g_Exp[ i ])
	Fimdaronda = true
}

public CounterTerroristsWin( )
{
	if( Fimdaronda )
	{
		return	
	}

	new Players[ MAX_PLAYERS ]
	new iNum
	new i

	get_players( Players, iNum, "ch" )

	for( --iNum; iNum >= 0; iNum-- )
	{
		i = Players[ iNum ]

		if( g_authed[ i ] )
		{
			switch( cs_get_user_team( i ) )
			{
				case( CS_TEAM_T ):
				{
					g_Packs[ i ] -= get_pcvar_num( l_Terrorists )
					g_Exp[ i ] -= random_num(2,32);
					ColorChat( i, NORMAL, "%s A tua equipa!t (T)!n acabou de perder !t%i!n ponto%s por terem perdido a ronda", tag, get_pcvar_num( l_Terrorists ), get_pcvar_num( l_Terrorists ) > 1 ? "s" : "" )
				}
				case( CS_TEAM_CT ):
				{
					g_Packs[ i ] += get_pcvar_num( w_CounterTerrorists )
					g_Exp[ i ] += random_num(2,32);
					g_WonRounds[ i ]++
					ColorChat( i, NORMAL, "%s A tua equipa!t (CT)!n recebeu !t%i!n ponto%s por ganhar a ronda", tag, get_pcvar_num( w_CounterTerrorists ), get_pcvar_num( w_CounterTerrorists ) > 1 ? "s" : "" )
				}
			}
		}
	}
	SaveOther( i )
	SaveJBPacks(i, g_Packs[i], g_Exp[ i ])
	Fimdaronda = true
}

public Playedonehour( id )
{
	if( g_authed[id] )
	{
		g_Packs[ id ] += get_pcvar_num( horapontos )
		g_Exp[ id ] += random_num(50,72);
		ColorChat( id, NORMAL, "%s Acabes-te de ganhar !t%i!n ponto%s por estares a jogar a 1 hora.", tag, get_pcvar_num( horapontos ), get_pcvar_num( horapontos ) > 1 ? "s" : "" )
		SaveJBPacks(id, g_Packs[id], g_Exp[ id ])
	}
}

public bomb_planted( planter )
{
	if( g_authed[planter] )
	{
		g_Packs[ planter ] += get_pcvar_num( plantarpontos )
		g_Exp[ planter ] += random_num(5,10);

		ColorChat( planter, NORMAL, "%s Acabas-te de ganhar !t%i!n ponto%s por plantar a bomba.", tag, get_pcvar_num( plantarpontos ), get_pcvar_num( plantarpontos ) > 1 ? "s" : "" )
		SaveOther(planter)
		SaveJBPacks(planter, g_Packs[planter], g_Exp[ planter ])
	}
}

public bomb_explode( planter, defuser )
{
	if( g_authed[ planter] )
	{
		g_Packs[ planter ] += get_pcvar_num( explodirpontos )
		g_Exp[ planter ] += random_num(10,30);
		g_BombExplosions[ planter ]++

		ColorChat( planter, NORMAL, "%s Acabas-te de ganhar !t%i!n ponto%s por conseguir fazer a bomba explodir.", tag, get_pcvar_num( explodirpontos ), get_pcvar_num( explodirpontos ) > 1 ? "s" : "" )
		SaveOther(planter)
		SaveJBPacks(planter, g_Packs[planter], g_Exp[ planter ])
	}
}

public bomb_defused( defuser )
{
	if( g_authed[defuser] )
	{
		g_Packs[ defuser ] += get_pcvar_num( defusarpontos )
		g_Exp[ defuser ] += random_num(10,30);
		g_DefusedBombs[ defuser ]++

		ColorChat( defuser, NORMAL, "!g%s!n You earned!t %i!n point%s for disarming the bomb", tag, get_pcvar_num( defusarpontos ), get_pcvar_num( defusarpontos ) > 1 ? "s" : "" )
		SaveOther(defuser)
		SaveJBPacks(defuser, g_Packs[defuser], g_Exp[ defuser ])
	}
}

public EventNewRound( )
	Fimdaronda = false

/******************************** MYSQL *********************************/
public MySql_Init()
{
	g_SqlTuple	= SQL_MakeDbTuple( "", "", "", "")

	// ok, we're ready to connect
	new ErrorCode
	g_SqlConnection	= SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))

	if(g_SqlConnection == Empty_Handle)
	{
		// stop the plugin with an error message
		set_fail_state(g_Error)
	}

	/*new Handle:Queries
	// we must now prepare some random queries
	Queries = SQL_PrepareQuery(g_SqlConnection,"CREATE TABLE IF NOT EXISTS amx_idsteam (steamid varchar(32), name varchar(64), money INT(11))")

	if(!SQL_Execute(Queries))
	{
		// if there were any problems
		SQL_QueryError(Queries,g_Error,charsmax(g_Error))
		set_fail_state(g_Error)
	}

	// close the handle
	SQL_FreeHandle(Queries)*/ 

	g_sql_ready = true
	for(new i=1; i<=maxplayers; i++)
	{
		if( g_authed[i] )
		{
			Load_MySql(i)
		}
	}
}

public Load_MySql(id)
{
	if( g_sql_ready )
	{
		if(g_SqlTuple == Empty_Handle)
		{
			set_fail_state(g_Error)
		}

		new szSteamId[32], szTemp[512]
		get_user_authid(id, szSteamId, charsmax(szSteamId))

		new Data[1]
		Data[0] = id

		//we will now select from the table `furienmoney` where the steamid match
		format(szTemp,charsmax(szTemp),"SELECT * FROM `amx_idsteam` WHERE `steamid` = '%s';", szSteamId)
		SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
	}
}

public register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
	if( FailState == TQUERY_CONNECT_FAILED )
	{
		log_amx("Load - Could not connect to SQL database.  [%d] %s", Errcode, Error)
	}
	else if(FailState == TQUERY_QUERY_FAILED)
	{
		log_amx("Load Query failed. [%d] %s", Errcode, Error)
	}

	new id
	id = Data[0]

	if( SQL_NumResults( Query ) < 1 )
	{
		//.se não existir nenhum resultado ele vai registar um novo
		new szTemp[512], szSteamId[35], szIP[32], szName[32], szQuotedName[64];
		get_user_authid(id, szSteamId, charsmax(szSteamId)) // steamid do player
		get_user_name(id, szName, 31) // nome do player
		get_user_ip(id, szIP, 31) // ip do player

		g_Packs[id] = PACKS_START;

		SQL_QuoteString(g_SqlConnection, szQuotedName, 63, szName)

		if( TrieKeyExists( g_tIgnoredAuthID, szSteamId) )
		{
			return PLUGIN_HANDLED
		}

		// now we will insert the values into our table.
		format(szTemp,charsmax(szTemp),"INSERT INTO `amx_idsteam` ( steamid, nickname, pontos, ip ) VALUES( '%s', '%s', '%i', '%s' );", szSteamId, szQuotedName, g_Packs, szIP )
		SQL_ThreadQuery(g_SqlTuple, "IgnoreHandle", szTemp)
	}
	else
	{
		// if there are results found
		g_Packs[id]	= SQL_ReadResult(Query, 0)
		g_Levels[ id ] = SQL_ReadResult( Query, 1 )

		g_Kills[ id ] = SQL_ReadResult( Query, 2 )
		g_Deaths[ id ] = SQL_ReadResult( Query, 3 )
		g_HeadShots[ id ] = SQL_ReadResult( Query, 4 )
		g_KnifeKills[ id ] = SQL_ReadResult( Query, 5 )
		g_KnifeDeaths[ id ] = SQL_ReadResult( Query, 6 )
		g_GrenadeKills[ id ] = SQL_ReadResult( Query, 7 )
		g_GrenadeDeaths[ id ] = SQL_ReadResult( Query, 8 )
		g_BombExplosions[ id ] = SQL_ReadResult( Query, 9 )
		g_DefusedBombs[ id ] = SQL_ReadResult( Query, 10 )
		g_WonRounds[ id ] = SQL_ReadResult( Query, 11 )
	}
	g_loaded[id] = true
	return PLUGIN_HANDLED
}

public Save_MySql(id)
{
	if( g_loaded[id] )
	{
		new szTemp[512], szSteamId[35], szIP[32], szName[32], szQuotedName[64];
		get_user_authid(id, szSteamId, charsmax(szSteamId))
		get_user_name(id, szName, 31)
		get_user_ip(id, szIP, 31) // ip do player
		SQL_QuoteString(g_SqlConnection, szQuotedName, 63, szName)

		// Here we will update the user hes information in the database where the steamid matches.
		format(szTemp,charsmax(szTemp),"UPDATE `amx_idsteam` SET `nickname` = '%s', `ip` = '%s' WHERE `steamid` = '%s';", szQuotedName, szIP, szSteamId)
		SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
	}
}

public IgnoreHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
	SQL_FreeHandle(Query)
	return PLUGIN_HANDLED
}

public plugin_end()
{
	TrieDestroy( g_tIgnoredAuthID )

	if( g_SqlConnection != Empty_Handle )
	{
		SQL_FreeHandle(g_SqlConnection) //free connection handle here
	}
}

public client_disconnect(id)
{
	Save_MySql(id)

	iStart[id] = false;

	id += TASK_HUD
	if(task_exists(id))
		remove_task(id)
}

public client_putinserver(id)
{
	new szSteamId[35];
	get_user_authid(id, szSteamId, charsmax(szSteamId))

	if( !TrieKeyExists( g_tIgnoredAuthID, szSteamId ) )
	{
		if( str_to_num(szSteamId))
		{
			g_authed[id] = true
			Load_MySql(id)
			set_task(1.0, "HUD_PACKS", id + TASK_HUD, _, _, "b" )
			set_task( 3600.0, "Playedonehour", id, _, _, "b" )
		}
	}
}

public Fwd_PlayerSpawn_Post(id)
{
	if(is_user_alive(id))
	{
		set_user_footsteps( id, 0 );
		set_user_rendering( id );
		cs_reset_user_model( id );
	}
}

/**************************** OTHERS ******************************/
public HUD_PACKS(id)
{
	id -= TASK_HUD

	if(is_user_connected(id))
	{
		set_dhudmessage(85, 85, 255, 0.80, 0.71, 0, 1.3, 0.0, 1.0, 1.0)
		show_dhudmessage(id, "WORKANDPLAY.PT")

		set_dhudmessage(85, 85, 255, 0.83, 0.74, 0, 1.3, 0.0, 1.0, 1.0)
		show_dhudmessage( id, "Pontos:  %i", g_Packs[ id ] )
	}
}

/*************************** SAVES ******************************/
public SaveJBPacks(id, pontos, xp)
{
	new szSteamID[41]
	get_user_authid(id, szSteamID, charsmax(szSteamID))

	new sqlquery[512];
	formatex(sqlquery, charsmax(sqlquery), "UPDATE `amx_idsteam` SET `pontos` = %i, `cl_xp` = %i WHERE `steamid` = '%s';", pontos, xp, szSteamID)

	SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",sqlquery)
}

public SaveOther(id)
{
	if( g_Packs[ id ] < 0 )
	{
		g_Packs[ id ] = 0
	}

	if( g_Levels[ id ] < 0 )
	{
		g_Levels[ id ] = 0
	}

	new g_szName[32];
	get_user_name(id, g_szName, 31)

	while( g_Exp[ id ] >= LEVELS[ g_Levels[ id ] ] )
	{
		g_Levels[ id ] += 1
		g_Classes[ id ] += 1
		
		ColorChat( 0, NORMAL, "%s !g%s!n Subiu de nivel e passou a ser %s com %i ponto%s e %i de XP. ", tag, g_szName[ id ], CLASSES[ g_Levels[ id ] ], g_Packs[ id ], g_Packs[ id ] > 1 ? "s" : "", g_Exp[ id ] )
	}

	new szSteamID[41]
	get_user_authid(id, szSteamID, charsmax(szSteamID))

	new sqlquery[512];
	formatex(sqlquery, charsmax(sqlquery), "UPDATE `amx_idsteam` SET cl_level = '%i', cl_kills = '%i', cl_deaths = '%i',\
	cl_headshots = '%i', cl_knife_kills = '%i', cl_knife_deaths = '%i', cl_grenade_kills = '%i', cl_grenade_deaths = '%i',\
	cl_bomb_explosions = '%i', cl_defused_bombs = '%i', cl_own_rounds = '%i' WHERE steamid = '%s';", g_Levels[ id ],
	g_Kills[ id ], g_Deaths[ id ], g_HeadShots[ id ], g_KnifeKills[ id ], g_KnifeDeaths[ id ], g_GrenadeKills[ id ],
	g_GrenadeDeaths[ id ], g_BombExplosions[ id ], g_DefusedBombs[ id ], g_WonRounds[ id ], szSteamID)

	SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",sqlquery)
}

Hello, I made a plugin for points and experience, but I do not know very well withoptimising the code since I started working with mysql. Please help me fix the bugs, errors and the code.
 


  • +
  • -
  • 0

#2 radim

    Godlike

  • Moderator

Reputacja: 939
Master

  • Postów:2 725
  • Steam:steam
  • Imię:Arkadiusz
  • Lokalizacja:Janów Lub.
Offline

Napisano 26.04.2015 08:01

Nazywaj tematy zgodnie z ich treścią.
Napisz ponownie temat nazywając go tak, aby każdy wiedział o co chodzi.

Jednoznacznie określ problematykę tematu, wyróżniając go spośród reszty.
Nie dodawaj zbędnych informacji, znaków, ani emotikon w nazwie tematu.

Ten temat w ciągu 24 godzin zostanie przeniesiony do kosza.
  • +
  • -
  • 0

Chcąc napisać do mnie prywatną wiadomość, wpierw zapoznaj się ze stroną "O mnie" w moim profilu użytkownika [ radim ] !





Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych