SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Romānă/Romanian

 
 
Thread Tools Display Modes
Old 30/08/2013, 10:30 PM   #1
WopsS
Huge Clucker
 
WopsS's Avatar
 
Join Date: Nov 2011
Posts: 490
Reputation: 70
Default [MySQL] R31 - Nelamurit

Salut, deci pentru inceput. Am avansat destul de mult de cand am inceput scripting, ~1 luna. Si m-am gandit sa-mi fac un server, pentru ca-s satul de server dupa net cu buguri care apar la fiecare secunda. Asa ca, am luat R31 BlueG dupa ****** Project. Si am facut tot, cand se inregistreaza ii baga in baza de date username si password, dar cand sa extraga, ciuciu! Nu merge, incerc sa folosesc cache, pentru ca este mai rapid.

Asa ca:

1. Cand folosesc
Code:
mysql_function_query ( 1, "SELECT * FROM players", false, "aici liber", "" );
sa las unde scrie "aici liber" sa pun Callback-ul sau sa las ""
2. Cand extrag din MySQL sa folosesc
Code:
mysql_function_query ( 1, "SELECT * FROM players", false, "aici liber", "" );
sau
Code:
mysql_function_query ( 1, "SELECT * FROM players", false, "CallBack", "" );
3. Ce sa folosesc thread sau non-thread?
4. N-am inteles cache. Cand vreau sa iau date din MySQL ce folosesc? cache_get_row, sau?
Attached Files
File Type: pwn w3op.pwn (6.4 KB, 3 views)
WopsS is offline  
Old 31/08/2013, 05:28 AM   #2
im
Huge Clucker
 
im's Avatar
 
Join Date: Mar 2012
Location: Romānia
Posts: 213
Reputation: 21
Default Re: [MySQL] R31 - Nelamurit

Nu mai poti folosi non-thread in pluginul mysql de mult timp.
Se foloseste mysql_tquery in loc de mysql_function_query. Toate query-urile folossc cache.
mysql_tquery( handle, query, <Callback>, <call back params. ex: ddd>, <params values. ex: playerid, vehicleid, whateverid).

Dupa ce se executa un query, functia setata la callback este apelata (trebuie sa fie public) si acolo alegi ce se intampla cu datele selectate din query.

Pentru codul tau, logarea ar fi:

Code:
public OnPlayerConnect(playerid)
{
    gAccount[playerid] = 1; gLogged[playerid] = 0;

	new pName[30];
	new query[256];
	GetPlayerName(playerid, pName, sizeof(pName));
 	format(query, sizeof(query), "SELECT * FROM `players` WHERE `username` = `%s`", pName);
	mysql_tquery(handle, query, "OnPlayerDataLoad", "i", playerid);

	return 1;
}

forward OnPlayerDataLoad(playerid);
public OnPlayerDataLoad(playerid){
	new rows, fields;
 	cache_get_data(rows, fields);
 	if(rows != 0)
	{
		gAccount[playerid] = 1;
  	}
  	else
  	{
  	    gAccount[playerid] = 0;
   	}
 return 1;
}
Apoi in OnPlayerDataLoad ar trebui sa afisezi dialogul de logare.
__________________
im is offline  
Old 31/08/2013, 09:46 AM   #3
WopsS
Huge Clucker
 
WopsS's Avatar
 
Join Date: Nov 2011
Posts: 490
Reputation: 70
Default Re: [MySQL] R31 - Nelamurit

Deci inloc de mysql_function_query pun mysql_tquery, de ce?
Si la toate trebuie sa am un CallBack... Merci
WopsS is offline  
Old 31/08/2013, 09:51 AM   #4
nGen.SoNNy
Gangsta
 
nGen.SoNNy's Avatar
 
Join Date: Sep 2009
Location: Romania
Posts: 929
Reputation: 69
Default Re: [MySQL] R31 - Nelamurit

Pentru ca tu ca sa sa extragi ceva din baza de date trebuie sa faci un thread. Doar la UPDATE si la CREATE parca poti folosi fara mysql_tquery.
__________________
If i've helped you, please click
nGen.SoNNy is offline  
Old 31/08/2013, 10:11 AM   #5
WopsS
Huge Clucker
 
WopsS's Avatar
 
Join Date: Nov 2011
Posts: 490
Reputation: 70
Default Re: [MySQL] R31 - Nelamurit

Aha, va multumesc!
WopsS is offline  
Old 01/09/2013, 06:06 PM   #6
WopsS
Huge Clucker
 
WopsS's Avatar
 
Join Date: Nov 2011
Posts: 490
Reputation: 70
Default Re: [MySQL] R31 - Nelamurit

Dar non-thread nu mai pot folosi? Sau cand o sa-l putem folosi iar? Pentru ca nu vreau sa creeze cate un public sau un stock pentru a verifica un bizz un player, etc. Si cand fac update de ex. Am Update(playerid, pLevelu);
si la pLevelu am query "UPDATE bla bla bla Level = '%d'" cum fac aici? Adica cum apelez callback-ul?
WopsS is offline  
Old 01/09/2013, 06:50 PM   #7
nGen.SoNNy
Gangsta
 
nGen.SoNNy's Avatar
 
Join Date: Sep 2009
Location: Romania
Posts: 929
Reputation: 69
Default Re: [MySQL] R31 - Nelamurit

La UPDATE nu trebuie. Dar la fiecare SELECT sau cum le spui tu "verifica un bizz" trebuie sa faci cate un callback xD
Daca nu-ti place si crezi ca nu ai nevoie asa mare... foloseste un R5-6 si gata
__________________
If i've helped you, please click
nGen.SoNNy is offline  
Old 01/09/2013, 06:56 PM   #8
WopsS
Huge Clucker
 
WopsS's Avatar
 
Join Date: Nov 2011
Posts: 490
Reputation: 70
Default Re: [MySQL] R31 - Nelamurit

Nu, credeam ca si la UPDATE trebuie ... Merci
WopsS is offline  
 

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[GameMode] Basic MySQL Account Script [MySQL R7, cache functions, easydialog, Whirlpool, salted passwords] ReneG Gamemode Scripts 70 02/03/2014 11:48 AM
[GameMode] MySQL CLEAN GAMEMODE [Whirlpool, MySQL BlueG R7, Cache, Ready Package (Windows)] GiamPy. Gamemode Scripts 13 13/09/2013 04:31 PM
BlueG MySQL plugin - Failed (plugins/mysql.so: undefined symbol: _Z13stringvprintfPKcPc) linuxthefish Plugin Development 10 13/07/2013 10:56 AM
[Tool/Web/Other] MySQL DB Manager - Easily manage your MySQL databases with this remote application fiki574 Tools and Files 13 22/07/2012 09:41 AM


All times are GMT. The time now is 03:45 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.