Sistem Puncte mysql

Cereri de pluginuri noi, skinuri in CS, etc.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
robbencsgo
Membru, skill 0
Membru, skill 0
Posts: 11
Joined: 31 Aug 2019, 18:14
Detinator Steam: Da
CS Status: .
Detinator server CS: csgo.crashed.ro
SteamID: robbengiu
Fond eXtream: 0
Has thanked: 1 time

05 Nov 2019, 22:25

salut am si eu un sistem de puncte si as vrea sa se salveze punctele intr-o baza de date nu intr-un fisier in configs.

Code: Select all

#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fun >


new const PLUGIN [ ] = "Points";
new const VERSION [ ] = "1.3";
new const AUTHOR [ ] = "Alex #";

new Points [ 33 ];
new SaveDataFile [ 128 ];

const Float:HUD_SPECT_X = -1.0
const Float:HUD_SPECT_Y = 0.8

public plugin_init ( )
{
	register_plugin ( PLUGIN, VERSION, AUTHOR );
	
	register_event ( "DeathMsg", "eDeath", "a" );
	
	new DataDir [ 64 ];
	get_configsdir ( DataDir, charsmax ( DataDir ) );
	format ( SaveDataFile, 127, "%s/Points.dat", DataDir );
	
	set_task ( 0.1, "TASK_MSG", _, _, _, "b" );
}

public plugin_natives ( )
{
	register_native ( "csdm_get_user_points", "get_user_points", 1 );
	register_native ( "csdm_set_user_points", "set_user_points", 1 );
}

public get_user_points ( id )
{
	return Points [ id ];
}

public set_user_points ( id, PointsNum )
{
	Points [ id ] = PointsNum;
}

public eDeath ( )
{
	new Killer = read_data ( 1 );
	new Victim = read_data ( 2 );
	new HeadShoot = read_data ( 3 );
	
	if ( Killer == Victim )                           return PLUGIN_HANDLED;
	
	Points [ Killer ] += 1;
	if ( HeadShoot ) {
		Points [ Killer ] += 2;
	}
	
	return PLUGIN_CONTINUE;
}

public client_connect ( id )
{
	LoadPoints ( id );
}

public client_disconnect ( id )
{
	SavePoints ( id );
}

public LoadPoints ( id )
{
	new Name [ 32 ];
	get_user_name ( id, Name, 31 );
	
	new Line [ 128 ], IsPlayer = false, Arg1 [ 32 ], Arg2 [ 32 ];
	new File = fopen ( SaveDataFile, "rt" )
	while ( !feof ( File ) ) {
		fgets ( File, Line, 127 );
		trim ( Line );
		
		parse ( Line, Arg1, 31, Arg2, 31 );
		
		if ( equali ( Arg1, Name ) ) {
			Points [ id ] = str_to_num ( Arg2 );
			IsPlayer = true;
			break;
		}
	}
	
	fclose ( File );
	
	if ( !IsPlayer )
		Points [ id ] = 0;
}


public SavePoints ( id )
{
	new Name [ 32 ];
	get_user_name ( id, Name, 31 );
	
	new Save [ 1024 ];
	format ( Save, sizeof ( Save ) -1, "^"%s^" %d", Name, Points [ id ] );
	
	new Line [ 128 ], Linie, IsPlayer = false, Arg1 [ 32 ]
	
	new File = fopen ( SaveDataFile, "rt" );
	while ( !feof ( File ) ) {
		fgets ( File, Line, 127 );
		
		parse ( Line, Arg1, 31 );
		
		if ( equali ( Arg1, Name ) ) {
			write_file ( SaveDataFile, Save, Linie );
			IsPlayer = true;
			break;
		}
		
		Linie++
	}
	
	fclose ( File );
	
	if ( !IsPlayer )
		write_file ( SaveDataFile, Save, -1 );
}

public TASK_MSG ( )
{
	static id;
	for ( id = 1; id <= get_maxplayers ( ); id++ )
	{
		if ( is_user_alive ( id ) && is_user_connected ( id ) ) {
			switch ( cs_get_user_team ( id ) )
			{
				case CS_TEAM_T : {
					set_hudmessage ( id, 127, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1 );
					show_hudmessage ( id, "Terorist, HP: %d - AP: %d - Points: %d", get_user_health ( id ), get_user_armor ( id ), Points [ id ] );
				}
				
				case CS_TEAM_CT : {
					set_hudmessage ( id, 127, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1 )
					show_hudmessage ( id, "Counter, HP: %d - AP: %d - Points: %d", get_user_health ( id ), get_user_armor ( id ), Points [ id ] );
				}
				
				case CS_TEAM_SPECTATOR : {
					return PLUGIN_CONTINUE;
				}
			}
		}
		
	}
	return PLUGIN_CONTINUE;
}
IG-BOOST.org - Instagram Followers Best, Cheap, Reliable
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2509
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 36 times
Been thanked: 379 times
Contact:

05 Nov 2019, 23:41

să se salveze pe nick?
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
robbencsgo
Membru, skill 0
Membru, skill 0
Posts: 11
Joined: 31 Aug 2019, 18:14
Detinator Steam: Da
CS Status: .
Detinator server CS: csgo.crashed.ro
SteamID: robbengiu
Fond eXtream: 0
Has thanked: 1 time

06 Nov 2019, 17:32

Nu, as dori pe steamid daca poti sa faci te rog frumos. Eu il facusem pentru steamid dar nu mai aveam sursa si am postat sursa default gen cum am gasit-o de la mama ei pe nick. Multumesc!
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2509
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 36 times
Been thanked: 379 times
Contact:

06 Nov 2019, 17:51

Code: Select all

#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fun >
#include <sqlx> 

new const	PLUGIN [ ] = "Points",
		VERSION [ ] = "1.3",
		AUTHOR [ ] = "Alex #";
new Points [ 33 ];

new const	TABEL[]="Points",
		Host[]="",
		User[]="",
		Pass[]="",
		Db[]=""
new Handle:g_SqlTuple,g_Error[512],szSteamId[33][35]

const Float:HUD_SPECT_X = -1.0
const Float:HUD_SPECT_Y = 0.8

public plugin_init ( )
{
	register_plugin ( PLUGIN, VERSION, AUTHOR );
	
	register_event ( "DeathMsg", "eDeath", "a" );
	
	set_task ( 0.1, "TASK_MSG", _, _, _, "b" );
}
public MySql_Init()
{
    g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db)

    new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
    if(SqlConnection == Empty_Handle)	set_fail_state(g_Error)

    new Handle:Queries
    Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS %s (steamid varchar(35),points INT(11))",TABEL)

    if(!SQL_Execute(Queries))
    {
        SQL_QueryError(Queries,g_Error,charsmax(g_Error))
        set_fail_state(g_Error)
    }

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

public plugin_natives ( )
{
	register_native ( "csdm_get_user_points", "get_user_points", 1 );
	register_native ( "csdm_set_user_points", "set_user_points", 1 );
}
public get_user_points ( id )	return Points [ id ];
public set_user_points ( id, PointsNum )	Points [ id ] = PointsNum;

public eDeath ( )
{
	new Killer = read_data ( 1 );
	new Victim = read_data ( 2 );
	new HeadShoot = read_data ( 3 );
	
	if ( Killer == Victim )                           return PLUGIN_HANDLED;
	
	Points [ Killer ] += 1;
	if ( HeadShoot )	Points [ Killer ] += 2;
	
	return PLUGIN_CONTINUE;
}

public client_connect ( id )	if(!(is_user_bot(id)||is_user_hltv(id)))	Load_MySql(id)
public client_disconnect ( id )	if(!(is_user_bot(id)||is_user_hltv(id)))	Save_MySql(id)
public Load_MySql(id)
{
    new szTemp[512]
    get_user_authid(id, szSteamId[id], charsmax(szSteamId[]))

    new Data[1]
    Data[0] = id

    format(szTemp,charsmax(szTemp),"SELECT * FROM `%s` WHERE (`%s`.`steamid` = '%s');",TABEL,TABEL, szSteamId[id])
    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) 
    {
        if (equal(szSteamId[id],"ID_PENDING"))	return PLUGIN_HANDLED
            
        new szTemp[512]
        format(szTemp,charsmax(szTemp),"INSERT INTO `%s` ( `steamid` , `points`) VALUES ( '%s' , '0' );",TABEL,szSteamId[id])
        SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
    } 
    else 	Points[id] = SQL_ReadResult(Query, 1)

    return PLUGIN_HANDLED
}
public Save_MySql(id)
{
    new szTemp[512]

    format(szTemp,charsmax(szTemp),"UPDATE `%s` SET `points` = '%i' WHERE `%s`.`steamid` = '%s';",TABEL,Points[id],TABEL, szSteamId[id])
    SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
}

public TASK_MSG ( )
{
	static id;
	for ( id = 1; id <= get_maxplayers ( ); id++ )
	{
		if ( is_user_alive ( id ) && is_user_connected ( id ) ) {
			switch ( cs_get_user_team ( id ) )
			{
				case CS_TEAM_T : {
					set_hudmessage ( id, 127, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1 );
					show_hudmessage ( id, "Terorist, HP: %d - AP: %d - Points: %d", get_user_health ( id ), get_user_armor ( id ), Points [ id ] );
				}
				case CS_TEAM_CT : {
					set_hudmessage ( id, 127, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1 )
					show_hudmessage ( id, "Counter, HP: %d - AP: %d - Points: %d", get_user_health ( id ), get_user_armor ( id ), Points [ id ] );
				}
				case CS_TEAM_SPECTATOR :	return PLUGIN_CONTINUE;
			}
		}
		
	}
	return PLUGIN_CONTINUE;
}
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
robbencsgo
Membru, skill 0
Membru, skill 0
Posts: 11
Joined: 31 Aug 2019, 18:14
Detinator Steam: Da
CS Status: .
Detinator server CS: csgo.crashed.ro
SteamID: robbengiu
Fond eXtream: 0
Has thanked: 1 time

06 Nov 2019, 18:26

Code: Select all

[DPROTO]: Client 1 - Set AuthIdType 1 [Native]; pClient = 0xf33a8dfc
L 11/06/2019 - 18:23:13: [MySQL] Invalid info tuple handle: 0
L 11/06/2019 - 18:23:13: [AMXX] Displaying debug trace (plugin "sistempuncte.amxx")
L 11/06/2019 - 18:23:13: [AMXX] Run time error 10: native error (native "SQL_ThreadQuery")
L 11/06/2019 - 18:23:13: [AMXX] [0] sistempuncte.sma::Load_MySql (line 87)
L 11/06/2019 - 18:23:13: [AMXX] [1] sistempuncte.sma::client_connect (line 76)
imi da asta in consola
si asta cand iese de pe sv

Code: Select all

L 11/06/2019 - 18:30:22: [MySQL] Invalid info tuple handle: 0
L 11/06/2019 - 18:30:22: [AMXX] Displaying debug trace (plugin "sistempuncte.amxx")
L 11/06/2019 - 18:30:22: [AMXX] Run time error 10: native error (native "SQL_ThreadQuery")
L 11/06/2019 - 18:30:22: [AMXX] [0] sistempuncte.sma::Save_MySql (line 113)
L 11/06/2019 - 18:30:22: [AMXX] [1] sistempuncte.sma::client_disconnect (line 77)
Last edited by robbencsgo on 06 Nov 2019, 18:36, edited 1 time in total.
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2509
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 36 times
Been thanked: 379 times
Contact:

06 Nov 2019, 18:32

Code: Select all

#include < amxmodx >
#include <sqlx> 

new const	PLUGIN [ ] = "Points",
		VERSION [ ] = "1.3",
		AUTHOR [ ] = "Alex #";
new Points [ 33 ];

new const	TABEL[]="Points",
		Host[]="",
		User[]="",
		Pass[]="",
		Db[]=""
new Handle:g_SqlTuple,g_Error[512],szSteamId[33][35]

const Float:HUD_SPECT_X = -1.0
const Float:HUD_SPECT_Y = 0.8

public plugin_init ( )
{
	register_plugin ( PLUGIN, VERSION, AUTHOR );
	
	register_event ( "DeathMsg", "eDeath", "a" );
	
	set_task ( 0.1, "TASK_MSG", _, _, _, "b" );
	
	MySql_Init()
}
public MySql_Init()
{
    g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db)

    new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
    if(SqlConnection == Empty_Handle)	set_fail_state(g_Error)

    new Handle:Queries
    Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS %s (steamid varchar(35), points INT(11))",TABEL)

    if(!SQL_Execute(Queries))
    {
        SQL_QueryError(Queries,g_Error,charsmax(g_Error))
        set_fail_state(g_Error)
    }

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

public plugin_natives ( )
{
	register_native ( "csdm_get_user_points", "get_user_points", 1 );
	register_native ( "csdm_set_user_points", "set_user_points", 1 );
}
public get_user_points ( id )	return Points [ id ];
public set_user_points ( id, PointsNum )	Points [ id ] = PointsNum;

public eDeath ( )
{
	new Killer = read_data ( 1 );
	new Victim = read_data ( 2 );
	new HeadShoot = read_data ( 3 );
	
	if ( Killer == Victim )                           return PLUGIN_HANDLED;
	
	Points [ Killer ] += 1;
	if ( HeadShoot )	Points [ Killer ] += 2;
	
	return PLUGIN_CONTINUE;
}

public client_authorized ( id )	if(!(is_user_bot(id)||is_user_hltv(id)))	Load_MySql(id)
public client_disconnect ( id )	if(!(is_user_bot(id)||is_user_hltv(id)))	Save_MySql(id)
public Load_MySql(id)
{
    new szTemp[512]
    get_user_authid(id, szSteamId[id], charsmax(szSteamId[]))

    new Data[1]
    Data[0] = id
    format(szTemp,charsmax(szTemp),"SELECT * FROM `%s` WHERE (`%s`.`steamid` = '%s');",TABEL,TABEL, szSteamId[id])
    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) 
    {
        if (equal(szSteamId[id],"ID_PENDING"))	return PLUGIN_HANDLED
            
        new szTemp[512]
        format(szTemp,charsmax(szTemp),"INSERT INTO `%s` ( `steamid` , `points`) VALUES ( '%s' , '0' );",TABEL,szSteamId[id])
        SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
    } 
    else 	Points[id] = SQL_ReadResult(Query, 1)

    return PLUGIN_HANDLED
}
public Save_MySql(id)
{
    new szTemp[512]
    format(szTemp,charsmax(szTemp),"UPDATE `%s` SET `points` = '%i' WHERE `%s`.`steamid` = '%s';",TABEL,Points[id],TABEL, szSteamId[id])
    SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
}

public TASK_MSG ( )
{
	static id;
	for ( id = 1; id <= get_maxplayers ( ); id++ )
	{
		if ( is_user_alive ( id ) && is_user_connected ( id ) ) {
			switch ( get_user_team ( id ) )
			{
				case 1 : {
					set_hudmessage ( id, 127, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1 );
					show_hudmessage ( id, "Terorist, HP: %d - AP: %d - Points: %d", get_user_health ( id ), get_user_armor ( id ), Points [ id ] );
				}
				case 2 : {
					set_hudmessage ( id, 127, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1 )
					show_hudmessage ( id, "Counter, HP: %d - AP: %d - Points: %d", get_user_health ( id ), get_user_armor ( id ), Points [ id ] );
				}
				case 3 :	return PLUGIN_CONTINUE;
			}
		}
		
	}
	return PLUGIN_CONTINUE;
}
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
robbencsgo
Membru, skill 0
Membru, skill 0
Posts: 11
Joined: 31 Aug 2019, 18:14
Detinator Steam: Da
CS Status: .
Detinator server CS: csgo.crashed.ro
SteamID: robbengiu
Fond eXtream: 0
Has thanked: 1 time

06 Nov 2019, 18:43

Multumeste foarte mult, merge acuma dar am o intrebare, pot sa imi faci gen sa imi apara in MySQL

STAEMID NUME PUNCTE

Gen sa apara si numele in tabela dar sa se ia doar dupa steamid, multumesc frumos din nou pentru ca ti-ai ocupat timpul si merge :D
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2509
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 36 times
Been thanked: 379 times
Contact:

06 Nov 2019, 18:46

ori adaugi tu nick ori dai delete

Code: Select all

#include < amxmodx >
#include <sqlx> 

#pragma ctrlchar '\'

new const	PLUGIN [ ] = "Points",
		VERSION [ ] = "1.3",
		AUTHOR [ ] = "Alex #";
new Points [ 33 ];

new const	TABEL[]="Points",
		Host[]="",
		User[]="",
		Pass[]="",
		Db[]=""
new Handle:g_SqlTuple,g_Error[512],szSteamId[33][35],szNick[33][32]

const Float:HUD_SPECT_X = -1.0
const Float:HUD_SPECT_Y = 0.8

public plugin_init ( )
{
	register_plugin ( PLUGIN, VERSION, AUTHOR );
	
	register_event ( "DeathMsg", "eDeath", "a" );
	
	set_task ( 0.1, "TASK_MSG", _, _, _, "b" );
	
	MySql_Init()
}
public MySql_Init()
{
    g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db)

    new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
    if(SqlConnection == Empty_Handle)	set_fail_state(g_Error)

    new Handle:Queries
    Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS %s (steamid varchar(35), nick varchar(33), points INT(11))",TABEL)

    if(!SQL_Execute(Queries))
    {
        SQL_QueryError(Queries,g_Error,charsmax(g_Error))
        set_fail_state(g_Error)
    }

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

public plugin_natives ( )
{
	register_native ( "csdm_get_user_points", "get_user_points", 1 );
	register_native ( "csdm_set_user_points", "set_user_points", 1 );
}
public get_user_points ( id )	return Points [ id ];
public set_user_points ( id, PointsNum )	Points [ id ] = PointsNum;

public eDeath ( )
{
	new Killer = read_data ( 1 );
	new Victim = read_data ( 2 );
	new HeadShoot = read_data ( 3 );
	
	if ( Killer == Victim )                           return PLUGIN_HANDLED;
	
	Points [ Killer ] += 1;
	if ( HeadShoot )	Points [ Killer ] += 2;
	
	return PLUGIN_CONTINUE;
}

public client_authorized ( id )	if(!(is_user_bot(id)||is_user_hltv(id)))	Load_MySql(id)
public client_disconnect ( id )	if(!(is_user_bot(id)||is_user_hltv(id)))	Save_MySql(id)
public Load_MySql(id)
{
    new szTemp[512]
    get_user_authid(id, szSteamId[id], charsmax(szSteamId[]))
    get_user_name(id, szNick[id], charsmax(szNick[]))

    new Data[1]
    Data[0] = id
    format(szTemp,charsmax(szTemp),"SELECT * FROM `%s` WHERE (`%s`.`steamid` = '%s');",TABEL,TABEL, szSteamId[id])
    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) 
    {
        if (equal(szSteamId[id],"ID_PENDING"))	return PLUGIN_HANDLED
            
        new szTemp[512]
        CleanString(szNick[id],charsmax(szNick))
        format(szTemp,charsmax(szTemp),"INSERT INTO `%s` ( `steamid` , `nick` , `points`) VALUES ( '%s' , %s,  '0' );",TABEL,szSteamId[id],szNick[id])
        SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
    } 
    else 	Points[id] = SQL_ReadResult(Query, 1)

    return PLUGIN_HANDLED
}
public Save_MySql(id)
{
    new szTemp[512]
    format(szTemp,charsmax(szTemp),"UPDATE `%s` SET `points` = `points` + '%i' WHERE `%s`.`steamid` = '%s';",TABEL,Points[id],TABEL, szSteamId[id])
    SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
}

public TASK_MSG ( )
{
	static id;
	for ( id = 1; id <= get_maxplayers ( ); id++ )
	{
		if ( is_user_alive ( id ) && is_user_connected ( id ) ) {
			switch ( get_user_team ( id ) )
			{
				case 1 : {
					set_hudmessage ( id, 127, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1 );
					show_hudmessage ( id, "Terorist, HP: %d - AP: %d - Points: %d", get_user_health ( id ), get_user_armor ( id ), Points [ id ] );
				}
				case 2 : {
					set_hudmessage ( id, 127, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1 )
					show_hudmessage ( id, "Counter, HP: %d - AP: %d - Points: %d", get_user_health ( id ), get_user_armor ( id ), Points [ id ] );
				}
				case 3 :	return PLUGIN_CONTINUE;
			}
		}
		
	}
	return PLUGIN_CONTINUE;
}

stock CleanString(szName[], iSize)
{
	replace_all(szName, iSize, "\"", "");
	replace_all(szName, iSize, "'", "");
	replace_all(szName, iSize, "`", "\\`");
	replace_all(szName, iSize, "\\", "\\\\");
}
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
Post Reply

Return to “Cereri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests