30.03.2013, 16:46
(
Последний раз редактировалось edwardluciano; 31.03.2013 в 03:26.
)
Код:
Sql File `Tag` varchar(50) collate utf8_general_ci NOT NULL default ' ', in script pTagger[128], MySQLUpdatePlayerStr(query, PlayerInfo[playerid][pSQLID], "Tag", PlayerInfo[playerid][pTagger]); if (rcnt == 105) MySQLFetchAcctSingle(PlayerInfo[playerid][pSQLID], "Tag", PlayerInfo[playerid][pTagger]); Commands if(strcmp(cmd, "/mtag", true) == 0 || strcmp(cmd, "/maketag", true) == 0) { if (PlayerInfo[playerid][pAdmin] <= 3545) { return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, "Usage: /maketag [playerid/PartOfName] [color] [Tag Number 1-5] [text]"); SendClientMessage(playerid, COLOR_GRAD1, "Color: 1.ᴧ 2.аўХВЗ 3.їйТ 4.ЄБѕЩ 5.КйБ 6.№йУа§Ф№ 7.БиЗ§ 8.ўТЗ 9.а·Т"); SendClientMessage(playerid, COLOR_GRAD1, "Color: 10.ᴧЁТ§ 11.аўХВЗЁТ§ 12.їйТЁТ§ 13.ЄБѕЩЁТ§ 14.КйБЁТ§ 15.БиЗ§ЁТ§"); return 1; } giveplayerid = ReturnUser(tmp); GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); if(IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD1, "Usage: /maketag [playerid/PartOfName] [color] [Tag Number 1-5] [text]"); SendClientMessage(playerid, COLOR_GRAD1, "Color: 1.ᴧ 2.аўХВЗ 3.їйТ 4.ЄБѕЩ 5.КйБ 6.№йУа§Ф№ 7.БиЗ§ 8.ўТЗ 9.а·Т"); SendClientMessage(playerid, COLOR_GRAD1, "Color: 10.ᴧЁТ§ 11.аўХВЗЁТ§ 12.їйТЁТ§ 13.ЄБѕЩЁТ§ 14.КйБЁТ§ 15.БиЗ§ЁТ§"); return 1; } new colorztag; colorztag = strval(tmp); if(colorztag < 1 || colorztag > 15) { SendClientMessage(playerid, COLOR_GRAD1, " КХ Tag јФґѕЕТґ !"); SendClientMessage(playerid, COLOR_GRAD1, "Color: 1.ᴧ 2.аўХВЗ 3.їйТ 4.ЄБѕЩ 5.КйБ 6.№йУа§Ф№ 7.БиЗ§ 8.ўТЗ 9.а·Т"); SendClientMessage(playerid, COLOR_GRAD1, "Color: 10.ᴧЁТ§ 11.аўХВЗЁТ§ 12.їйТЁТ§ 13.ЄБѕЩЁТ§ 14.КйБЁТ§ 15.БиЗ§ЁТ§"); return 1; } new x_nr[256]; x_nr = strtok(cmdtext, idx); if(!strlen(x_nr)) { SendClientMessage(playerid, COLOR_GRAD1, "Usage: /maketag [playerid/PartOfName] [color] [Tag Number 1-5] [text]"); SendClientMessage(playerid, COLOR_GRAD1, "Color: 1.ᴧ 2.аўХВЗ 3.їйТ 4.ЄБѕЩ 5.КйБ 6.№йУа§Ф№ 7.БиЗ§ 8.ўТЗ 9.а·Т"); SendClientMessage(playerid, COLOR_GRAD1, "Color: 10.ᴧЁТ§ 11.аўХВЗЁТ§ 12.їйТЁТ§ 13.ЄБѕЩЁТ§ 14.КйБЁТ§ 15.БиЗ§ЁТ§"); return 1; } if(strcmp(x_nr,"1",true) == 0) { new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[128]; while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; } result[idx - offset] = EOS; if(!strlen(result)) { SendClientMessage(playerid, COLOR_GRAD1, "Usage: /maketag [playerid/PartOfName] color] [Tag Number 1-5] [text]"); SendClientMessage(playerid, COLOR_GRAD1, "Color: 1.ᴧ 2.аўХВЗ 3.їйТ 4.ЄБѕЩ 5.КйБ 6.№йУа§Ф№ 7.БиЗ§ 8.ўТЗ 9.а·Т"); SendClientMessage(playerid, COLOR_GRAD1, "Color: 10.ᴧЁТ§ 11.аўХВЗЁТ§ 12.їйТЁТ§ 13.ЄБѕЩЁТ§ 14.КйБЁТ§ 15.БиЗ§ЁТ§"); return 1; } new stang[128]; format(stang, sizeof(stang), "%s",(result)); strmid(PlayerInfo[giveplayerid][pTagger], result, 0, strlen(result), 255); PlayerInfo[giveplayerid][pTagcolor] = colorztag; format(string, sizeof(string), "¤ШідґйаѕФиБ Tag 1 гЛйЎСє %s аГХВєГйНВбЕйЗ", giveplayer); SendClientMessage(playerid, COLOR_WHITE, string); }
Ok , when insert thai language and look in PhPMyAdmin
This
Can't Read thai language i don't know why
PhPMyAdmin
MySQL charset: UTF-8 Unicode (utf
(T T ) Help me please it make my server crash when exit game if that player has data
I found mysql_set_char -*- how to do it
this is my SQL Script
Код:
#define MYSQL_HOST "127.0.0.1" #define MYSQL_USER "root" #define MYSQL_PASS "root" #define MYSQL_DB "ordinary" #include <a_sampmysql> forward MySQLConnect(sqlhost[], sqluser[], sqlpass[], sqldb[]); forward MySQLDisconnect(); forward MySQLCheckConnection(); forward MySQLUpdateBuild(query[], sqlplayerid); forward MySQLUpdateFinish(query[], sqlplayerid); forward MySQLUpdatePlayerInt(query[], sqlplayerid, sqlvalname[], sqlupdateint); forward MySQLUpdatePlayerIntSingle(sqlplayerid, sqlvalname[], sqlupdateint); forward MySQLUpdatePlayerFlo(query[], sqlplayerid, sqlvalname[], Float:sqlupdateflo); forward MySQLUpdatePlayerStr(query[], sqlplayerid, sqlvalname[], sqlupdatestr[]); forward MySQLCheckAccount(sqlplayersname[]); forward MySQLCheckAccountLocked(sqlplayerid); forward MySQLCheckAccountBanned(sqlplayerid); forward MySQLCheckAccountLeader(sqlplayerid); forward MySQLCheckAccountMember(sqlplayerid); forward MySQLCheckIPBanned(ip[]); forward MySQLFetchAcctSingle(sqlplayerid, sqlvalname[], sqlresult[]); forward MySQLFetchAcctRecord(sqlplayerid, sqlresult[]); forward MySQLCreateAccount(newplayersname[], newpassword[]); forward MySQLAddLoginRecord(sqlplayerid, ipaddr[]); public MySQLConnect(sqlhost[], sqluser[], sqlpass[], sqldb[]) // by Luk0r { print("MYSQL: Attempting to connect to server..."); samp_mysql_connect(sqlhost, sqluser, sqlpass); samp_mysql_select_db(sqldb); if(samp_mysql_ping()==0) { print("MYSQL: Database connection established."); return 1; } else { print("MYSQL: Connection error, retrying..."); samp_mysql_connect(sqlhost, sqluser, sqlpass); samp_mysql_select_db(sqldb); if(samp_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; } } } public MySQLDisconnect() // by Luk0r { samp_mysql_close(); return 1; } public MySQLCheckConnection() // by Luk0r { if(samp_mysql_ping()==0) { return 1; } else { print("MYSQL: Connection seems dead, retrying..."); MySQLDisconnect(); MySQLConnect(MYSQL_HOST,MYSQL_USER,MYSQL_PASS,MYSQL_DB); if(samp_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; } } } public MySQLUpdateBuild(query[], sqlplayerid) // by Luk0r { new querylen = strlen(query); //new querymax = sizeof(query); new querymax = MAX_STRING; if (querylen < 1) format(query, querymax, "UPDATE players SET "); else if (querymax-querylen < 50) // make sure we're being safe here { // query is too large, send this one and reset new whereclause[32]; format(whereclause, sizeof(whereclause), " WHERE id=%d", sqlplayerid); strcat(query, whereclause, querymax); samp_mysql_query(query); format(query, querymax, "UPDATE players SET "); } else if (strfind(query, "=", true) != -1) strcat(query, ",", MAX_STRING); return 1; } public MySQLUpdateFinish(query[], sqlplayerid) // by Luk0r { if (strcmp(query, "WHERE id=", false) == 0) samp_mysql_query(query); else { new whereclause[32]; format(whereclause, sizeof(whereclause), " WHERE id=%d", sqlplayerid); strcat(query, whereclause, MAX_STRING); samp_mysql_query(query); format(query, MAX_STRING, "UPDATE players SET "); } return 1; } public MySQLUpdatePlayerInt(query[], sqlplayerid, sqlvalname[], sqlupdateint) // by Luk0r { MySQLUpdateBuild(query, sqlplayerid); new updval[64]; format(updval, sizeof(updval), "%s=%d", sqlvalname, sqlupdateint); strcat(query, updval, MAX_STRING); return 1; } public MySQLUpdatePlayerFlo(query[], sqlplayerid, sqlvalname[], Float:sqlupdateflo) // by Luk0r { /* new query[128]; format(query, sizeof(query), "UPDATE players SET %s=%f WHERE id=%d", sqlvalname, sqlupdateflo, sqlplayerid); samp_mysql_query(query);*/ new flotostr[32]; format(flotostr, sizeof(flotostr), "%f", sqlupdateflo); MySQLUpdatePlayerStr(query, sqlplayerid, sqlvalname, flotostr); return 1; } public MySQLUpdatePlayerStr(query[], sqlplayerid, sqlvalname[], sqlupdatestr[]) // by Luk0r { MySQLUpdateBuild(query, sqlplayerid); new escstr[128]; new updval[128]; samp_mysql_real_escape_string(sqlupdatestr, escstr); format(updval, sizeof(updval), "%s='%s'", sqlvalname, escstr); strcat(query, updval, MAX_STRING); return 1; } public MySQLUpdatePlayerIntSingle(sqlplayerid, sqlvalname[], sqlupdateint) // by Luk0r { new query[128]; format(query, sizeof(query), "UPDATE players SET %s=%d WHERE id=%d", sqlvalname, sqlupdateint, sqlplayerid); samp_mysql_query(query); return 1; } public MySQLCheckAccount(sqlplayersname[]) // by Luk0r { new query[128]; new escstr[MAX_PLAYER_NAME]; samp_mysql_real_escape_string(sqlplayersname, escstr); format(query, sizeof(query), "SELECT id FROM players WHERE LOWER(Name) = LOWER('%s') LIMIT 1", escstr); samp_mysql_query(query); samp_mysql_store_result(); if (samp_mysql_num_rows()==0) { return 0; } else { new strid[32]; new intid; samp_mysql_fetch_row(strid); intid = strval(strid); return intid; } } public MySQLCheckAccountLocked(sqlplayerid) { new query[64]; new lockedboolstr[4]; format(query, sizeof(query), "SELECT Locked FROM players WHERE id = %d LIMIT 1", sqlplayerid); samp_mysql_query(query); samp_mysql_store_result(); samp_mysql_fetch_row(lockedboolstr); if (strval(lockedboolstr) != 0) { return 1; } return 0; } public MySQLCheckAccountBanned(sqlplayerid) { new query[64]; new bantypestr[4]; new bantypeint; format(query, sizeof(query), "SELECT Banned FROM players WHERE id = %d LIMIT 1", sqlplayerid); samp_mysql_query(query); samp_mysql_store_result(); samp_mysql_fetch_row(bantypestr); bantypeint = strval(bantypestr); return bantypeint; } public MySQLCheckAccountMember(sqlplayerid) { new query[64]; new bantypestr[4]; new bantypeint; format(query, sizeof(query), "SELECT Member FROM players WHERE id = %d LIMIT 1", sqlplayerid); samp_mysql_query(query); samp_mysql_store_result(); samp_mysql_fetch_row(bantypestr); bantypeint = strval(bantypestr); return bantypeint; } public MySQLCheckAccountLeader(sqlplayerid) { new query[64]; new bantypestr[4]; new bantypeint; format(query, sizeof(query), "SELECT Leader FROM players WHERE id = %d LIMIT 1", sqlplayerid); samp_mysql_query(query); samp_mysql_store_result(); samp_mysql_fetch_row(bantypestr); bantypeint = strval(bantypestr); return bantypeint; } public MySQLCheckIPBanned(ip[]) { new query[64]; format(query, sizeof(query), "SELECT type FROM bans WHERE ip = '%s' AND inactive = 0 ORDER BY id DESC LIMIT 1", ip); samp_mysql_query(query); samp_mysql_store_result(); if (samp_mysql_num_rows() != 0) { new bantypestr[4]; new bantypeint; samp_mysql_fetch_row(bantypestr); bantypeint = strval(bantypestr); samp_mysql_store_result(); return bantypeint; } return 0; } public MySQLFetchAcctSingle(sqlplayerid, sqlvalname[], sqlresult[]) { new query[128]; format(query, sizeof(query), "SELECT %s FROM players WHERE id = %d LIMIT 1", sqlvalname, sqlplayerid); samp_mysql_query(query); samp_mysql_store_result(); if(samp_mysql_fetch_row(sqlresult)==1) { return 1; } return 0; } public MySQLFetchAcctRecord(sqlplayerid, sqlresult[]) // by Luk0r { new query[64]; format(query, sizeof(query), "SELECT * FROM players WHERE id = %d LIMIT 1", sqlplayerid); samp_mysql_query(query); samp_mysql_store_result(); if(samp_mysql_fetch_row(sqlresult)==1) { return 1; } return 0; } public MySQLCreateAccount(newplayersname[], newpassword[]) // by Luk0r { new query[128]; new sqlplyname[64]; new sqlpassword[64]; samp_mysql_real_escape_string(newplayersname, sqlplyname); samp_mysql_real_escape_string(newpassword, sqlpassword); format(query, sizeof(query), "INSERT INTO players (Name, Password) VALUES ('%s', '%s')", sqlplyname, sqlpassword); samp_mysql_query(query); new newplayersid = MySQLCheckAccount(newplayersname); if (newplayersid != 0) { return newplayersid; } return 0; } public MySQLAddLoginRecord(sqlplayerid, ipaddr[]) // by Luk0r { new query[128]; new escip[16]; samp_mysql_real_escape_string(ipaddr, escip); format(query, sizeof(query), "INSERT INTO logins (time,ip,userid) VALUES (UNIX_TIMESTAMP(),'%s',%d)", escip, sqlplayerid); samp_mysql_query(query); return 1; }
(T T )