[Ajuda] Salvar EXP com MySQL - 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] Salvar EXP com MySQL (
/showthread.php?tid=646512)
Salvar EXP com MySQL -
zMorningStar - 18.12.2017
Gostaria de ajuda para saber como salvar o EXP de 1 а 4 do player com o banco de dados MySQL.
Este й o meu cуdigo:
PHP Code:
// EXP
new EXP[ MAX_PLAYERS ];
public OnPlayerConnect( playerid )
{
SetTimerEx( "UpPlayer", 600000, true, "i", playerid );
}
// UpPlayer
forward UpPlayer( playerid );
public UpPlayer( playerid )
{
new strEXP[ 128 ],
strLevel[ 128 ];
EXP[ playerid ]++;
if( EXP[ playerid ] == 4 )
{
new Level = GetPlayerScore( playerid );
SetPlayerScore( playerid, Level+1 );
EXP[ playerid ] = 0;
format( strEXP, sizeof( strEXP ), "| UP EXP | Vocк ganhou +1 Ponto de Experiкncia {FFFFFF}[ 4 {33AA33}/ {FFFFFF}4 ]{33AA33}.", EXP[ playerid ] );
SendClientMessage( playerid, COLOR_VERDEESCURO, strEXP );
format( strLevel, sizeof( strLevel ), "| LEVEL UP | Vocк juntou 4 Pontos de Experiкncia e upou para o level {FFFFFF}[ %i ]{33AA33}.", ++Level );
SendClientMessage( playerid, COLOR_VERDEESCURO, strLevel );
PlayerInfo[ playerid ][ pLevel ]++;
PlayerPlaySound( playerid, 1149, 0.0, 0.0, 0.0 );
GameTextForPlayer( playerid, "+UP!", 7000, 6 );
return 0;
}
format( strEXP, sizeof( strEXP ), "| UP EXP | Vocк ganhou +1 Ponto de Experiкncia {FFFFFF}[ %i {33AA33}/ {FFFFFF}4 ]{33AA33}.", EXP[ playerid ] );
SendClientMessage( playerid, COLOR_VERDEESCURO, strEXP );
PlayerPlaySound( playerid, 1139, 0.0, 0.0, 0.0 );
GameTextForPlayer( playerid, "+EXP!", 7000, 6 );
return 1;
}
Crйditos para o Sistema de XP + Level do JPedro:
https://sampforum.blast.hk/showthread.php?tid=580508
Re: Salvar EXP com MySQL -
DelK - 18.12.2017
Tente assim:
PHP Code:
CMD:salvarexp(playerid)
{
SalvarExp(playerid);
return 1;
}
stock SalvarExp(playerid)
{
new Query[50];
mysql_format(ConexaoBDD, Query, sizeof(Query), "SELECT * FROM `Contas` WHERE Nick='%s'", Nome(playerid));//Nгo manjo muito e nгo sei se precisa disso.
mysql_query(ConexaoBDD, Query, true);
format(Query, sizeof(Query), "UPDATE `contas` SET `Exp`='%d'", EXP[playerid]);
mysql_query(ConexaoBDD, Query, false);
return 1;
}
Utilize o comando sу para vк se funciona, se funcionar vocк apagar o comando e usar normalmente. E coloque isso no create table
PHP Code:
Exp int DEFAULT 0
Re: Salvar EXP com MySQL -
IlanZ - 18.12.2017
PHP Code:
stock SalvarExp(playerid)
{
new Query[50];
format(Query, sizeof(Query), "UPDATE `contas` SET `Exp`=%d WHERE `Nome`='%s'", EXP[playerid], Nome(playerid));
mysql_pquery(ConexaoBDD, Query);
}
Re: Salvar EXP com MySQL -
zMorningStar - 18.12.2017
Valeu amigos, obrigado pela ajuda de vocкs.