Duvida com MySql -
Caio_Freeze - 17.09.2013
eu queria saber como eu faзo pra salvar quantos o player matou, morreu estou usando esse fs http:
//forum.sa-mp.com/showthread.php?t=444873 como estou iniciando mysql com pawn queria uma base sу de salvar as mortes
pawn Код:
CREATE TABLE IF NOT EXISTS `contas` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`Nome` varchar(21) NOT NULL,
`Email` varchar(55) NOT NULL,
`Senha` varchar(20) NOT NULL,
`Admin` int(10) NOT NULL DEFAULT '0',
`Matou` int(100) NOT NULL DEFAULT '0',
`Morreu` int(100) NOT NULL DEFAULT '0',
`Dinheiro` int(100) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
Re: Duvida com MySql -
smiiir - 17.09.2013
pawn Код:
new myQuery [ 100 ], Nome [ 21 ] ;
GetPlayerName ( playerid, Nome, 21 ) ;
format ( myQuery, 100, "UPDATE `contas`SET `Morreu`='%d' WHERE Nome='%s'", SUA VARIAVEL DA MORTE, Nome ) ;
mysql_function_query ( SUA_CONEXAO, myQuery, true, #, # ) ;
SUA_CONEXAO = Variбvel de Conexгo
SUA VARIAVEL DA MORTE = Variбvel de contar as mortes
Re: Duvida com MySql -
Caio_Freeze - 18.09.2013
irei tentar aqui
@edit funcionou! muito abrigado agora como eu faзo pra quando o jogador logar na conta carregar as info que foram salva no banco de dados.
Re: Duvida com MySql -
Caio_Freeze - 18.09.2013
alguem pode me da um help?
Re: Duvida com MySql -
smiiir - 18.09.2013
Vк se funciona
pawn Код:
forward carregarContas ( playerid ) ;
public carregarContas ( playerid ) {
new qntD [ 50 ], rows, fields;
cache_get_data ( rows, fields, VARIAVEL_CONEXAO ) ;
cache_get_field_content ( 0, "Morreu", qntD, VARIAVEL_CONEXAO ) ;
Variavel_Para_Receber = strval ( qntD ) ;
return true ;
}
Re: Duvida com MySql -
Caio_Freeze - 18.09.2013
pode usar como stock?
@edit tem um problema tem vezes que ele salva e outras nгo e o dinheiro nao carrega ao logar na conta
pawn Код:
stock CarregarContas(playerid)
{
new qntD[1000], rows, fields;
cache_get_data (rows, fields, xConexao);
cache_get_field_content(0, "Admin", qntD, xConexao);
PlayerInfo[playerid][Admin] = strval(qntD);
cache_get_field_content(0, "Matou", qntD, xConexao);
PlayerInfo[playerid][Matou] = strval(qntD);
cache_get_field_content(0, "Morreu", qntD, xConexao);
PlayerInfo[playerid][Morreu] = strval(qntD);
cache_get_field_content(0, "Dinheiro", qntD, xConexao);
PlayerInfo[playerid][Dinheiro] = strval(qntD);
GivePlayerMoney(playerid, strval(qntD));
return 1;
}
stock SalvarDados(playerid)
{
new myQuery[100];
format(myQuery, 100, "UPDATE `contas` SET `Admin`='%d', `Matou`='%d', `Morreu`='%d', `Dinheiro`='%d' WHERE Nome='%s'", PlayerInfo[playerid][Admin], PlayerInfo[playerid][Matou], PlayerInfo[playerid][Morreu], GetPlayerMoney(playerid), Nome(playerid));
mysql_function_query(xConexao, myQuery, true, #, # );
return 1;
}
eu vi no mysql_log quando eu deslogo ele aparece isso:
pawn Код:
[16:58:58] Passing query UPDATE `contas`SET `Admin`='3001', `Matou`='0',`Morreu`='11', `Dinheiro`='-10' WHERE Nome='Caio_Col |
[16:58:58] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()
Re: Duvida com MySql -
smiiir - 19.09.2013
pawn Код:
stock SalvarDados(playerid)
{
new myQuery[200];
format(myQuery, 200, "UPDATE `contas` SET `Admin`='%d', `Matou`='%d', `Morreu`='%d', `Dinheiro`='%d' WHERE Nome='%s'", PlayerInfo[playerid][Admin], PlayerInfo[playerid][Matou], PlayerInfo[playerid][Morreu], GetPlayerMoney(playerid), Nome(playerid));
mysql_function_query(xConexao, myQuery, true, #, # );
return 1;
}