[Ajuda] MySQL dados - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (
https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] MySQL dados (
/showthread.php?tid=659427)
MySQL dados -
Electrifying - 02.10.2018
Olб, estou tentando fazer um comando pra trocar o nome do jogador, porйm meu servidor й em MySQL, e o nome do jogador й salvo em uma coluna chamada "NOME" mas o problema й que eu preciso checar se o nome do jogador jб existe no banco de dados em outra linha, por exemplo, se existe um jogador que jб registrou o nome no banco de dados com o nome "John" e outro jogador tenta mudar o nick pra "John" bagunзaria tudo. Como eu checo se existe dois nomes diferentes numa linha de uma coluna? E se os nomes sгo iguais, como envio uma mensagem pro player avisando?
Re: MySQL dados -
Malandrin - 02.10.2018
Estude e adapte para sua GM:
PHP код:
CMD:mudarnick(playerid, params[]) {
new NovoNome[24], Msg[144];
if(PlayerInfo[playerid][pDinheiro] < 0) return SendClientMessage(playerid, -1, "{ff0000}Para mudar de nick Г© necessГЎrio R$1000");
if(sscanf(params, "s[20]", NovoNome)) return SendClientMessage(playerid, -1, "{ff0000}Use: /mudarnick [novo nick]");
new Query[256], Cache:MudarNick;
mysql_format(mysql, Query, sizeof(Query), "SELECT name FROM dmplayers WHERE name='%e'", NovoNome);
MudarNick = mysql_query(mysql, Query, true);
if(cache_num_rows(mysql)) return SendClientMessage(playerid, -1, "{ff0000}AlguГ©m jГЎ usa este nick!"), cache_delete(MudarNick, mysql);
cache_delete(MudarNick, mysql);
if(SetPlayerName(playerid, NovoNome) != 1) return SendClientMessage(playerid, -1, "{ff0000}Este nome estГЎ em uso ou Г© invГЎlido!");
SetPlayerName(playerid, NovoNome);
format(Msg, sizeof(Msg), "{ffff00}[Mudar Nick] %s mudou para %s", PlayerInfo[playerid][pNome], NovoNome);
SendClientMessageToAll(-1, Msg);
GivePlayerMoney(playerid, (-1000));
format(PlayerInfo[playerid][pNome], 24, NovoNome);
SalvarConta(playerid);
return 1;
}
Tуpico que retirei o comando:
https://sampforum.blast.hk/showthread.php?tid=579433
Re: MySQL dados -
Electrifying - 02.10.2018
Quote:
Originally Posted by Malandrin
Estude e adapte para sua GM:
PHP код:
CMD:mudarnick(playerid, params[]) {
new NovoNome[24], Msg[144];
if(PlayerInfo[playerid][pDinheiro] < 0) return SendClientMessage(playerid, -1, "{ff0000}Para mudar de nick Г© necessГЎrio R$1000");
if(sscanf(params, "s[20]", NovoNome)) return SendClientMessage(playerid, -1, "{ff0000}Use: /mudarnick [novo nick]");
new Query[256], Cache:MudarNick;
mysql_format(mysql, Query, sizeof(Query), "SELECT name FROM dmplayers WHERE name='%e'", NovoNome);
MudarNick = mysql_query(mysql, Query, true);
if(cache_num_rows(mysql)) return SendClientMessage(playerid, -1, "{ff0000}AlguГ©m jГЎ usa este nick!"), cache_delete(MudarNick, mysql);
cache_delete(MudarNick, mysql);
if(SetPlayerName(playerid, NovoNome) != 1) return SendClientMessage(playerid, -1, "{ff0000}Este nome estГЎ em uso ou Г© invГЎlido!");
SetPlayerName(playerid, NovoNome);
format(Msg, sizeof(Msg), "{ffff00}[Mudar Nick] %s mudou para %s", PlayerInfo[playerid][pNome], NovoNome);
SendClientMessageToAll(-1, Msg);
GivePlayerMoney(playerid, (-1000));
format(PlayerInfo[playerid][pNome], 24, NovoNome);
SalvarConta(playerid);
return 1;
}
Tуpico que retirei o comando: https://sampforum.blast.hk/showthread.php?tid=579433
|
Valeu cara, abriu minha mente isso aqui
Код:
mysql_format(mysql, Query, sizeof(Query), "SELECT name FROM dmplayers WHERE name='%e'", NovoNome);