10.05.2013, 14:19
follow code
MySQLFetchAcctSingle
OnAccountUpdate
OnPlayerLogin
command /givetag
from code when i type language different english and save account via SQL and when (log in again) that record has change from old
follow picture
how to fix this because when player log in and log out make server crashed
i need to save other language
MySQLFetchAcctSingle
Код:
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 OnAccountUpdate(playerid) { if(IsPlayerConnected(playerid)) { if(gPlayerLogged[playerid]) { MySQLCheckConnection(); new query[MAX_STRING]; format(query, MAX_STRING, "UPDATE players SET "); MySQLUpdatePlayerStr(query, PlayerInfo[playerid][pSQLID], "Tag", PlayerInfo[playerid][pTagger]); MySQLUpdatePlayerStr(query, PlayerInfo[playerid][pSQLID], "Tag2", PlayerInfo[playerid][pTagger2]); MySQLUpdatePlayerStr(query, PlayerInfo[playerid][pSQLID], "Tag3", PlayerInfo[playerid][pTagger3]); MySQLUpdatePlayerStr(query, PlayerInfo[playerid][pSQLID], "Tag4", PlayerInfo[playerid][pTagger4]); MySQLUpdatePlayerStr(query, PlayerInfo[playerid][pSQLID], "Tag5", PlayerInfo[playerid][pTagger5]); MySQLUpdateFinish(query, PlayerInfo[playerid][pSQLID]); } } return 1; }
Код:
public OnPlayerLogin(playerid,password[]) { if(IsPlayerNPC(playerid)) return 1; MySQLCheckConnection(); new tmp2[256]; new string2[256]; new playername2[MAX_PLAYER_NAME]; new playernamesplit[3][MAX_PLAYER_NAME]; GetPlayerName(playerid, playername2, sizeof(playername2)); split(playername2, playernamesplit, '_'); MySQLFetchAcctSingle(PlayerInfo[playerid][pSQLID], "Password", PlayerInfo[playerid][pPassword]); if(strcmp(PlayerInfo[playerid][pPassword],password, true ) == 0 ) { new Data[1024]; new Field[64]; new rcnt = 1; MySQLFetchAcctRecord(PlayerInfo[playerid][pSQLID], Data); samp_mysql_strtok(Field, "|", Data); while (samp_mysql_strtok(Field, "|", "")==1) { // The rcnt values here represent the order of the columns in the characters table, so don't mess with them // If you add a column to the table, just add a new line with a +1 rcnt to the block below // Start it at 3 to skip the first few records we don't need (id, player name, password) if (rcnt == 109) MySQLFetchAcctSingle(PlayerInfo[playerid][pSQLID], "Tag", PlayerInfo[playerid][pTagger]); if (rcnt == 110) MySQLFetchAcctSingle(PlayerInfo[playerid][pSQLID], "Tag2", PlayerInfo[playerid][pTagger2]); if (rcnt == 111) MySQLFetchAcctSingle(PlayerInfo[playerid][pSQLID], "Tag3", PlayerInfo[playerid][pTagger3]); if (rcnt == 112) MySQLFetchAcctSingle(PlayerInfo[playerid][pSQLID], "Tag4", PlayerInfo[playerid][pTagger4]); if (rcnt == 113) MySQLFetchAcctSingle(PlayerInfo[playerid][pSQLID], "Tag5", PlayerInfo[playerid][pTagger5]); rcnt++; } }
Код:
if(strcmp(cmd, "/gtag", true) == 0 || strcmp(cmd, "/givetag", true) == 0) { if (PlayerInfo[playerid][pALevel] <= 4578) { return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, "Usage: /maketag [playerid/PartOfName] [color] [Tag Number 1-5] [text]"); 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]"); return 1; } new colorztag; colorztag = strval(tmp); if(colorztag < 1 || colorztag > 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]"); 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]"); 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), "added Tag 1 finish !", giveplayer); SendClientMessage(playerid, COLOR_WHITE, string); }
follow picture
how to fix this because when player log in and log out make server crashed
i need to save other language