Jump to content

MySQL Cache Tutorial ( Cel mai rapid )


[.]..RoW..[.]

Recommended Posts

Salut sunt RoW si astazi va prezint sistemul de salvare MySQL.

Deci hai sa incepem xD.

Avantaje:

1. Viteza

2. Capacitatea mare de date pe care o poate stoca.

3. In gamemode nu ocupa chiar atat de mult.

Dezavantaje:

1. Greu de folosit ( Pentru incepatori )

2. Greselile nu le semnaleaza pawno( Greselile de CLAUZE )

Sintaxe MySQL( r33 )

1. mysql_connect - Face conexiunea cu database

Handle = mysql_connect( MySQL_Host , MySQL_User , MySQL_Database , MySQL_Password );

La mysql_connect folositi o variabila globala !

Se folose?te doar la OnGameModeInit ( Doar acolo facem conexiunea ).

2. mysql_close - Inchide conexiunea cu database

mysql_close( Handle );

mysql_close inchide conexiunea cu database ( De aceea folosim o variabila globala ).

Se folose?te doar la OnGameModeExit ( Doar acolo inchidem conexiunea ).

3. mysql_tquery - Trimite un query( comanda ) catre database

mysql_tquery( ID-ul conExiuni , stringul  , numele thread-ului , parametri , definitie parametri );

Ex: mysql_tquery( Handle , "SELECT * FROM `accounts` WHERE `UserName` = '[.]..RoW..[.]' LIMIT 1;" , "LoadAccount" , "d" , playerid );

Se folose?te in orice callback.

4. cache_get_field_content_int - Extrage din database un integer

cache_get_field_content_int( Rândul , Stringul , ID-ul de conExiune );

Ex: PlayerInfo[ playerid ][ pLevel ] = cache_get_field_content_int( 0 , "PlayerLevel" , Handle );

Se folose?te in interiorul stock-urilor/callback-urilor!

5. cache_get_field_content_float - Extrage din database un float

cache_get_field_content_float( Rândul , Stringul , ID-ul de conExiune );

Ex: PlayerInfo[ playerid ][ pHealth ] = cache_get_field_content_float( 0 , "PlayerHealth" , Handle );

Se folose?te in interiorul stock-urilor/callback-urilor!

6. cache_get_field_content - Extrage din database un string

cache_get_field_content( Rândul , Stringul , variabila de stocare , ID-ul de conExiune , Numarul de caractere );

cache_get_field_content( 0 , "PlayerMoto" , PlayerInfo[ playerid ][ pMoto ] , Handle , 24 );

Se folose?te in interiorul stock-urilor/callback-urilor!

7. mysql_real_escape_string(tExt,escape);

mysql_real_escape_string( TExtul neprotejat , TExtul protejat );

Ex:

		new 
			BadString[ 128 ] 	,
			GoodString[ 128 ]   ;
		format( BadString , 128 , "DELETE FORM `accounts` WHERE `UserName` = '%d' LIMIT 1;" , pName );
		mysql_real_escape_string( BadString , GoodString , Handle );
		mysql_tquery( Handle , GoodString , "LoadAccount" , "d" , playerid );
	
Se folose?te in interiorul stock-urilor/callback-urilor! Cele mai cunoscute clauze: INSERT INTO - Insereaz? în database.
	new
		pName[ 24 ] ,
		test[ 256 ] ;

	GetPlayerName( playerid , pName , 24 );

	format( test , 256 , "INSERT INTO `accounts` ( UserName , LEvel ) VALUES ( '%s' '%d')" , pName );
	mysql_tquery( Handle , test , "" , "" );

SELECT - Selecteaz? din database.
	new
		pName[ 24 ] ,
		test[ 256 ] ;

	GetPlayerName( playerid , pName , 24 );

	format( test , 256 , "SELECT * FROM `accounts` WHERE `UserName` = '%s' LIMIT 1;" , pName );
	mysql_tquery( Handle , test , "" , "" );

UPDATE - Updateaz? coloane din database.
	new
		pName[ 24 ] ,
		test[ 256 ] ;

	GetPlayerName( playerid , pName , 24 );

	format( test , 256 , "UPDATE `accounts` SET `pLEvel` = '7' WHERE `UserName` = '%s' LIMIT 1;" , pName );
	mysql_tquery( Handle , test , "" , "" );

DELETE - ?terge coloane din database.
	new
		pName[ 24 ] ,
		test[ 256 ] ;

	GetPlayerName( playerid , pName , 24 );

	format( test , 256 , "DELETE FROM `accounts` WHERE `UserName` = '%s' LIMIT 1;" , pName );
	mysql_tquery( Handle , test , "" , "" );

LIMIT - Limiteaz? Intr?rile/?tergerile/Updatarile
	new
		pName[ 24 ] ,
		test[ 256 ] ;

	GetPlayerName( playerid , pName , 24 );

	format( test , 256 , "UPDATE `accounts` SET `pLEvel` = '7' WHERE `UserName` = '%s' LIMIT 1;" , pName );
	mysql_tquery( Handle , test , "" , "" );

Oserva?ii:

1. Pentru a folosi MySQL trebuie s? ave?i instalat Wamp/Xampp

2. Pentru a perveni query-urile r?u inten?ionate( AKA SQL_Injection ) folositi mysql_real_escape_string

Download:

Google Project Page

Acesta a fost tutorialul am încercat s? îl fac cât mai complex posibil !

I'm back bitches !

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 3 weeks later...

Buna ziua tuturor

[XSR]NexT,cred ca vrei sa spui ca este foarte usor sa iti creezi un cont dupa numele altcuiva dupa alta comunitate:)) . Nu stiu sigur dar chiar am sa ma interesez daca tu esti The Row de pe alta comunitate unde a fost postat acest tutorial.Pana acum nu s-a potrivit absolut nimic.Incepand de la nickname : Row unde celalalt are pe comunitate nickname:[LK]..Alucard..[.].

In fine,frumos tutorial si sper sa fie facut de tine.Si nu,nu cred ca ai cunostintele lui [XSR]NexT...

Sarbatori fericite !

[Pawn]/Onica Razvan

EDIT: Acel Row de pe comunitatea cealalta a fost userul de la noi cu numele [!]RoW[!].

Pentru suport nu ezitati sa ma contactati printr-un mesaj privat sau un mesaj pe Y/M.(Scripting sa:mp/cs,ScripturiWEB,phpbb,mysql,ipb,photoshop,html)

Link to comment
Share on other sites

  • 2 weeks later...

Sunt acelasi trimite un pm cu textul "Tu esti Row de pe sa-mp.ro ?" iar eu iti voi raspunde.

Ma cam enerveaza ca se da asa mare, dar daca il pun sa faca o functie cu argumente multiple moare ..

Toti copii retardati si prosti spun aceeasi vorba ;)

35012l1.png.aee1a3398b9bd9f8eec50574d2cd

Link to comment
Share on other sites

Nu as zice mare.

Dar ma pricep destul de bine si am ajuns la rankul de "Profesionist"

Pot face aproape orice.

Wow, incredibil!

Profesionist zici?

Spunene si noua ce face codul asta

BlaBla( Float: rX, Float: rY, Float: r_X, Float: r_Y, &Float: gA_DIS )
{
        gA_DIS = floatsqroot( floatpower( r_X - rX, 2 ) + floatpower( r_Y - rY, 2 ) );
        return floatround( gA_DIS );
}

Si nu te obosii sa cauti pe .com ca nu il gasesti.

Just Rock

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.