29.12.2009, 18:14
Quote:
Originally Posted by Wicko
Код:
native mysql_fetch_row_format(string[],const delimiter[] = "|"); #define mysql_fetch_row(%1) mysql_fetch_row_format(%1," ") Код:
mysql_fetch_row(BizzName[i]);
|
Originally Posted by Wicko
Код:
native mysql_fetch_row_format(string[],const delimiter[] = "|"); #define mysql_fetch_row(%1) mysql_fetch_row_format(%1," ") Код:
mysql_fetch_row(BizzName[i]);
|
Originally Posted by Wicko
Код:
native mysql_fetch_row_format(string[],const delimiter[] = "|"); #define mysql_fetch_row(%1) mysql_fetch_row_format(%1," ") Код:
mysql_fetch_row(BizzName[i]);
|
#define mysql_fetch_row(%1) mysql_fetch_row_format(%1," ")
#define mysql_fetch_row(%1) mysql_fetch_row_format(%1)
public MySQLConnect(sqlhost[], sqluser[], sqlpass[], sqldb[]) // by Luk0r
{
print("MYSQL: Attempting to connect to server...");
mysql_connect(sqlhost, sqluser, sqlpass, sqldb);
if(mysql_ping()==0)
{
print("MYSQL: Database connection established.");
return 1;
}
else
{
print("MYSQL: Connection error, retrying...");
mysql_connect(sqlhost, sqluser, sqlpass, sqldb);
if(mysql_ping()==0)
{
print("MYSQL: Reconnection successful. We can continue as normal.");
return 1;
}
else
{
print("MYSQL: Could not reconnect to server, terminating server...");
SendRconCommand("exit");
return 0;
}
}
}
mysql_connect(const host[],const user[],const database[],const password[])
Originally Posted by Dreft
mysql_connect(sqlhost, sqluser, sqlpass, sqldb);
change to mysql_connect(sqlhost, sqluser, sqldb, sqlpass); pawn Код:
|
###################[ Beginning first 1000 lines from log ]############## [Wed Dec 30 10:05:33 2009] Launching server with the following commandline: # /home/julianv/.gameservers/samp_0/samp03svr +exec server.cfg ---------- Loaded log file: "server_log.txt". ---------- SA-MP Dedicated Server ---------------------- v0.3a R4, ©2005-2009 SA-MP Team [10:05:33] gamemode1 = "" (string) [10:05:33] gamemode2 = "" (string) [10:05:33] gamemode3 = "" (string) [10:05:33] [10:05:33] Server Plugins [10:05:33] -------------- [10:05:33] Loading plugin: mysql.so [10:05:33] > MySQL plugin loaded on. | [10:05:33] Loaded. [10:05:33] Loaded 1 plugins. [10:05:33] [10:05:33] Filter Scripts [10:05:33] --------------- [10:05:33] Loading filter script 'adminspec.amx'... [10:05:33] Loading filter script 'vactions.amx'... [10:05:33] Unable to load filter script 'vactions.amx'. [10:05:33] Loading filter script 'actions.amx'... [10:05:33] Loaded 2 filter scripts. [10:05:33] MYSQL: Attempting to connect to server... [10:05:33] MYSQL: Connection error, retrying... [10:05:33] MYSQL: Could not reconnect to server, terminating server... [10:05:33] MYSQL: Connection seems dead, retrying... [10:05:33] MYSQL: Attempting to connect to server... [10:05:33] MYSQL: Connection error, retrying... [10:05:33] MYSQL: Could not reconnect to server, terminating server... [10:05:33] MYSQL: Could not reconnect to server, terminating server... ###################[ End of log ]######################### |
Originally Posted by $ЂЯĢ
You can use mysql_fetch_int if query gets you only one value (integer). In your case you need to use mysql_fetch_row_format and then split it with something (you can also use mysql_fetch_field_row afterwards).
|
case LOGIN_THREAD_ID:
{
if(IsPlayerConnected(LOGIN_PLAYER_ID))
{
mysql_store_result(); new resultline[64],fetch[64];; //adjust it to your needs
if(mysql_fetch_row_format(resultline))
{
mysql_fetch_field_row(fetch,"money"); PlayerInfo[LOGIN_PLAYER_ID][pMoney] = strval(fetch); //your filed name
PlayerInfo[LOGIN_PLAYER_ID][pMoney] = mysql_fetch_int();
GivePlayerMoney(LOGIN_PLAYER_ID,PlayerInfo[LOGIN_PLAYER_ID][pMoney]);
mysql_fetch_field_row(fetch,"deaths"); PlayerInfo[LOGIN_PLAYER_ID][pDeaths] = strval(fetch); //your field name
LoggedIn[LOGIN_PLAYER_ID] = true;
format(string,sizeof(string),">> You have been successfully logged in. (Money: %d, Deaths: %d)",PlayerInfo[LOGIN_PLAYER_ID][pMoney],PlayerInfo[LOGIN_PLAYER_ID][pDeaths]);
SendClientMessage(LOGIN_PLAYER_ID,GREY,string);
mysql_free_result();
}
Originally Posted by Dreft
I have some text in database with utf8 unicode characters like Ą Č Ę Ė Į Љ Ų Ū Ћ (Lithuanian characters).
Database and tables character set is "utf8" and collation is "utf8_lithuanian_ci". When i take that text and show it with message in samp instead of these special characters I see only ?? or $!% or something like that. Is there some thing I can do to avoid this problem ? |
case LOGIN_THREAD_ID: { if(IsPlayerConnected(LOGIN_PLAYER_ID)) { mysql_store_result(); if(mysql_num_rows() == 1) { new Field[64]; for(new rcnt = 33; mysql_fetch_field(rcnt, Field); rcnt++) { if (rcnt == 33) PlayerInfo[LOGIN_PLAYER_ID][pAdmin] = strval(Field); printf("Admin: %d", Field); if (rcnt == 34) PlayerInfo[LOGIN_PLAYER_ID][pLevel] = strval(Field); if (rcnt == 35) PlayerInfo[LOGIN_PLAYER_ID][pRegistered] = strval(Field); if (rcnt == 36) PlayerInfo[LOGIN_PLAYER_ID][pRegZeit] = strval(Field); if (rcnt == 37) PlayerInfo[LOGIN_PLAYER_ID][pSex] = strval(Field); if (rcnt == 38) PlayerInfo[LOGIN_PLAYER_ID][pAge] = strval(Field); if (rcnt == 39) PlayerInfo[LOGIN_PLAYER_ID][pExp] = strval(Field); if (rcnt == 40) PlayerInfo[LOGIN_PLAYER_ID][pCash] = strval(Field); if (rcnt == 41) PlayerInfo[LOGIN_PLAYER_ID][pBank] = strval(Field); // "Bank" if (rcnt == 42) PlayerInfo[LOGIN_PLAYER_ID][pSkin] = strval(Field); // "Skin" if (rcnt == 43) PlayerInfo[LOGIN_PLAYER_ID][pLastSkin] = strval(Field); // "LastSkin" if (rcnt == 44) PlayerInfo[LOGIN_PLAYER_ID][pKoks] = strval(Field); // "Koks" if (rcnt == 45) PlayerInfo[LOGIN_PLAYER_ID][pGras] = strval(Field); // "Gras" if (rcnt == 46) PlayerInfo[LOGIN_PLAYER_ID][pMHx] = floatstr(Field); // "aGrasX" if (rcnt == 47) PlayerInfo[LOGIN_PLAYER_ID][pMHy] = floatstr(Field); // "aGrasY" if (rcnt == 48) PlayerInfo[LOGIN_PLAYER_ID][pMHz] = floatstr(Field); // "aGrasZ" if (rcnt == 49) PlayerInfo[LOGIN_PLAYER_ID][pMHa] = floatstr(Field); // "aGrasA" if (rcnt == 50) PlayerInfo[LOGIN_PLAYER_ID][pMH] = strval(Field); // "aGras" if (rcnt == 51) PlayerInfo[LOGIN_PLAYER_ID][pMHZeit] = strval(Field); // "aGrasZeit" if (rcnt == 52) PlayerInfo[LOGIN_PLAYER_ID][pCrashX] = floatstr(Field); // "Crash_X" if (rcnt == 53) PlayerInfo[LOGIN_PLAYER_ID][pCrashY] = floatstr(Field); // "Crash_Y" if (rcnt == 54) PlayerInfo[LOGIN_PLAYER_ID][pCrashZ] = floatstr(Field); // "Crash_Z" if (rcnt == 55) PlayerInfo[LOGIN_PLAYER_ID][pCrashInt] = strval(Field); // "Crash_Int" if (rcnt == 56) PlayerInfo[LOGIN_PLAYER_ID][pCrashW] = strval(Field); // "Crash_Welt" if (rcnt == 57) PlayerInfo[LOGIN_PLAYER_ID][pCrashed] = strval(Field); // "Crashed" if (rcnt == 58) PlayerInfo[LOGIN_PLAYER_ID][pCarLic] = strval(Field); // "AutoSchein" if (rcnt == 59) PlayerInfo[LOGIN_PLAYER_ID][pFlyLic] = strval(Field); // "FlugSchein" if (rcnt == 60) PlayerInfo[LOGIN_PLAYER_ID][pBootLic] = strval(Field); // "BootsSchein" if (rcnt == 61) PlayerInfo[LOGIN_PLAYER_ID][pBikeLic] = strval(Field); // "BikeSchein" if (rcnt == 62) PlayerInfo[LOGIN_PLAYER_ID][pWepLic] = strval(Field); // "WaffeSchein" if (rcnt == 63) PlayerInfo[LOGIN_PLAYER_ID][pJob] = strval(Field); // "Job" if (rcnt == 64) PlayerInfo[LOGIN_PLAYER_ID][pTruckSkill] = strval(Field); // "TruckSkill" if (rcnt == 65) PlayerInfo[LOGIN_PLAYER_ID][pMechSkill] = strval(Field); // "MechanikerSkill" if (rcnt == 66) PlayerInfo[LOGIN_PLAYER_ID][pJackSkill] = strval(Field); // "JackSkill" if (rcnt == 67) PlayerInfo[LOGIN_PLAYER_ID][pBankSkill] = strval(Field); // "BankSkill" if (rcnt == 68) PlayerInfo[LOGIN_PLAYER_ID][pPlayingHours] = strval(Field); // "SpielStunden" if (rcnt == 69) PlayerInfo[LOGIN_PLAYER_ID][pPaydayZeit] = strval(Field); // "PayDayZeit" if (rcnt == 70) PlayerInfo[LOGIN_PLAYER_ID][pPayCheck] = strval(Field); // "PayCheck" if (rcnt == 71) PlayerInfo[LOGIN_PLAYER_ID][pDonator] = strval(Field); // "Premium" if (rcnt == 72) PlayerInfo[LOGIN_PLAYER_ID][pFaction] = strval(Field); // "Fraktion" if (rcnt == 73) PlayerInfo[LOGIN_PLAYER_ID][pRank] = strval(Field); // "Rank" if (rcnt == 74) PlayerInfo[LOGIN_PLAYER_ID][pHouseKey] = strval(Field); // "HausKey" if (rcnt == 75) PlayerInfo[LOGIN_PLAYER_ID][pGemietet] = strval(Field); // "MietKey" if (rcnt == 76) PlayerInfo[LOGIN_PLAYER_ID][pBizKey] = strval(Field); // "BizKey" if (rcnt == 77) PlayerInfo[LOGIN_PLAYER_ID][pSpawnPoint] = strval(Field); // "SpawnPunkt" if (rcnt == 78) PlayerInfo[LOGIN_PLAYER_ID][pBanned] = strval(Field); // "Gebannt" if (rcnt == 79) PlayerInfo[LOGIN_PLAYER_ID][pWarnings] = strval(Field); // "Verwarnungen" if (rcnt == 80) PlayerInfo[LOGIN_PLAYER_ID][pCarLicSperre] = strval(Field); // "FahrVerbot" if (rcnt == 81) PlayerInfo[LOGIN_PLAYER_ID][pBlitzPunkte] = strval(Field); // "BlitzPunkte" if (rcnt == 82) PlayerInfo[LOGIN_PLAYER_ID][pPhoneNumber] = strval(Field); // "TelefonNummer" if (rcnt == 83) PlayerInfo[LOGIN_PLAYER_ID][pPhoneC] = strval(Field); // "TelefonC" if (rcnt == 84) PlayerInfo[LOGIN_PLAYER_ID][pInetC] = strval(Field); // "InternetC" if (rcnt == 85) PlayerInfo[LOGIN_PLAYER_ID][pPhoneBook] = strval(Field); // "TelefonBuch" if (rcnt == 86) PlayerInfo[LOGIN_PLAYER_ID][pNotizblock] = strval(Field); // "NotizBlock" if (rcnt == 87) PlayerInfo[LOGIN_PLAYER_ID][pKoffer] = strval(Field); // "Koffer" if (rcnt == 88) PlayerInfo[LOGIN_PLAYER_ID][pLaptop] = strval(Field); // "LapTop" if (rcnt == 89) PlayerInfo[LOGIN_PLAYER_ID][pKanister] = strval(Field); // "Kanister" if (rcnt == 90) PlayerInfo[LOGIN_PLAYER_ID][pErsteHilfe] = strval(Field); // "ErsteHilfe" if (rcnt == 91) PlayerInfo[LOGIN_PLAYER_ID][pMorphium] = strval(Field); // "Morphium" if (rcnt == 92) PlayerInfo[LOGIN_PLAYER_ID][pGPS] = strval(Field); // "GPS" if (rcnt == 93) PlayerInfo[LOGIN_PLAYER_ID][pMaske] = strval(Field); // "Maske" if (rcnt == 94) PlayerInfo[LOGIN_PLAYER_ID][pMaskeauf] = strval(Field); // "MaskeAn" if (rcnt == 95) PlayerInfo[LOGIN_PLAYER_ID][pListNumber] = strval(Field); // "ListNummer" if (rcnt == 96) PlayerInfo[LOGIN_PLAYER_ID][pJailed] = strval(Field); // "Verhaftet" if (rcnt == 97) PlayerInfo[LOGIN_PLAYER_ID][pJailTime] = strval(Field); // "KnastZeit" if (rcnt == 98) WantedLevel[LOGIN_PLAYER_ID] = strval(Field); // "WantedLevel" if (rcnt == 99) PlayerInfo[LOGIN_PLAYER_ID][pProducts] = strval(Field); // "Produkte" if (rcnt == 100) PlayerInfo[LOGIN_PLAYER_ID][pJobTimer] = strval(Field); // "JobTimer" if (rcnt == 101) PlayerInfo[LOGIN_PLAYER_ID][pCarTime] = strval(Field); // "CarTime" if (rcnt == 102) PlayerInfo[LOGIN_PLAYER_ID][pFightStyle] = strval(Field); // "KampfStil" if (rcnt == 103) PlayerInfo[LOGIN_PLAYER_ID][pBoxen] = strval(Field); // "Boxen" if (rcnt == 104) PlayerInfo[LOGIN_PLAYER_ID][pKungFu] = strval(Field); // "KungFu" if (rcnt == 105) PlayerInfo[LOGIN_PLAYER_ID][pItems] = strval(Field); // "Items" if (rcnt == 106) PlayerInfo[LOGIN_PLAYER_ID][pFalschgeld] = strval(Field); // "FalschGeld" if (rcnt == 107) PlayerInfo[LOGIN_PLAYER_ID][pKredit] = strval(Field); // "Kredit" //rcnt++; } mysql_free_result(); format(string,sizeof(string),">> Du wurdest eingeloggt. (Geld: %d, Level: %d)",PlayerInfo[LOGIN_PLAYER_ID][pCash],PlayerInfo[LOGIN_PLAYER_ID][pLevel]); SendClientMessage(LOGIN_PLAYER_ID,COLOR_LIGHTGREEN,string); } else { Wrongattempt[LOGIN_PLAYER_ID] += 1; printf("Bad log in attempt by %s (Total attempts: %d)",pName,Wrongattempt[LOGIN_PLAYER_ID]); if(Wrongattempt[LOGIN_PLAYER_ID] >= 3) { mysql_free_result(); return Kick(LOGIN_PLAYER_ID); } mysql_free_result(); } } LOGIN_PLAYER_ID = INVALID_PLAYER_ID; return 0;
case LOGIN_THREAD_ID: { if(IsPlayerConnected(LOGIN_PLAYER_ID)) { mysql_store_result(); new resultline[64],fetch[64]; if(mysql_fetch_row_format(resultline)) { mysql_fetch_field_row(fetch,"AdminLevel"); PlayerInfo[LOGIN_PLAYER_ID][pAdmin] = strval(fetch); PlayerInfo[LOGIN_PLAYER_ID][pAdmin] = mysql_fetch_int(); LoggedIn[LOGIN_PLAYER_ID] = true; format(string,sizeof(string),">> You have been successfully logged in. (Money: %d)",PlayerInfo[LOGIN_PLAYER_ID][pAdmin]); SendClientMessage(LOGIN_PLAYER_ID,COLOR_GREEN,string); mysql_free_result(); } /*else { Wrongattempt[LOGIN_PLAYER_ID] += 1; printf("Bad log in attempt by %s (Total attempts: %d)",pName,Wrongattempt[LOGIN_PLAYER_ID]); if(Wrongattempt[LOGIN_PLAYER_ID] >= 3) { mysql_free_result(); return Kick(LOGIN_PLAYER_ID); } mysql_free_result(); }*/ }
14:22:55] --------------------------- [14:22:55] MySQL Debugging activated (01/24/10) [14:22:55] --------------------------- [14:22:55] [14:22:55] mysql_connect("127.0.0.1","root","wcf","xxxxxx"); [14:22:55] MySQL connection has been established [14:22:55] mysql_stat(); Return "Uptime: 18809 Threads: 1 Questions: 358 Slow queries: 0 Opens: 221 Flush tables: 1 Open tables: 0 Queries per second avg: 0.19" [14:24:36] mysql_ping(); Return: 1 [14:24:36] mysql_query("SELECT * FROM `wcf1_user` WHERE username = 'Dwayne_Johnsol'",Resultid: 1); [14:24:36] New thread created (Thread ID: 572 | Result ID: 1 | Threadsafe: Yes) [14:24:36] mysql_store_result(); [14:24:36] mysql_num_rows(); Return: 1 [14:24:36] mysql_free_result(); [14:24:52] mysql_ping(); Return: 1 [14:24:52] mysql_real_escape_string(Dwayne_Johnsol); Escaped 14 characters [14:24:52] mysql_real_escape_string(xxxx); Escaped 8 characters [14:24:52] mysql_query("SELECT * FROM `wcf1_user` WHERE username = 'Dwayne_Johnsol' AND password = 'xxxx' LIMIT 1",Resultid: 3); [14:24:52] New thread created (Thread ID: 592 | Result ID: 3 | Threadsafe: Yes) [14:24:52] mysql_store_result(); [14:24:52] mysql_fetch_row_format(Delimiter: |); Return: "5|Dwayne_Johnsol||xxxxx||0|0|0|0||0|||0||0|0|0|NU LL|0||0|0|0|0|0|NULL|NULL|1|0|1|0|NULL|20|5|1|0|0| 0|0|114|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| 0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| 0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0" |