Carregar Mysql -
LuisFerreira - 26.08.2015
Ola estou iniciando o mysql no ppc_trucking.. e para carregar scores e dinheiro й fбcil
PHP код:
SetPlayerScore(playerid, APlayerData[playerid][PlayerScore]);
GivePlayerMoney(playerid, APlayerData[playerid][PlayerMoney]);
Mais e agora para carregar tipo :
PHP код:
APlayerData[playerid][StatsTruckerJobs]
Como eu fasso?
Re: Carregar Mysql -
IgorLuiz - 26.08.2015
Faz assim
PHP код:
new query[128];
format(query, sizeof(query), "UPDATE `Jogadores` SET StatsTruckerJobs='%i' WHERE `Jogador` = '%s'", APlayerData[i][StatsTruckerJobs], Nome(i));
mysql_function_query(mysql, query, false, "", "");
Re: Carregar Mysql -
LuisFerreira - 26.08.2015
Eu fasso assim, mais isso ґnгo й pra salvar?
Re: Carregar Mysql -
IgorLuiz - 26.08.2015
uй usa "INSERT"
Re: Carregar Mysql -
Cleyson - 26.08.2015
INSERT й para inserir algo no banco de dados.
Se vocк quer carregar na variavel um valor contido no banco de dados й dessa maneira:
PHP код:
new Query[80], Nome[24];
GetPlayerName(playerid, Nome, 24);
mysql_format(StringConexao, Query, sizeof(Query), "SELECT * FROM `Contas` WHERE `Nome`='%s'", Nome);
mysql_tquery(StringConexao, Query, "ResultadoConsulta", "i", playerid); // troque StringConexao pela sua variavel de conexao
forward ResultadoConsulta(playerid);
public ResultadoConsulta(playerid)
{
if(cache_get_row_count(StringConexao) == 1) // se os dados existirem
{
APlayerData[playerid][StatsTruckerJobs] = cache_get_field_content_int(0, "StatsTruckerJobs");
}
return 1;
}
Й apenas um exemplo, mais seria bom vc ler esse tutorial antes de comeзar seus cуdigos:
Tutorial
Re: Carregar Mysql -
Dayvison_ - 26.08.2015
Leia isto, apуs aprender este basico do SQL vocк entenderб como Salvar, Carregar, Inserir e Deletar.
http://www.linhadecodigo.com.br/arti...-e-select.aspx
PS:Os exemplos acima tambem ajudam
Re: Carregar Mysql -
LuisFerreira - 26.08.2015
Esta parte eu consegui.. mais ae chego nas nas casas/empresas/banco tem coisas estranhas tipo:
PHP код:
if (strcmp(ParameterName, "Business", false) == 0) // If the parametername is correct ("Business")
{
if (strcmp(ABusinessData[strval(ParameterValue)][Owner], Name, false) == 0) // Check if the player is the true owner of the business
{
APlayerData[playerid][Business][BusIndex] = strval(ParameterValue); // Store the BusinessID at the selected slot
BusIndex++; // Select the next business-slot in case another business-id is found
}
}
PHP код:
for (new i; i < MAX_BUSINESSPERPLAYER; i++)
{
// Check if there is a valid business-id in this slot
if (APlayerData[playerid][Business][i] != 0)
{
format(LineForFile, 100, "Business %i\r\n", APlayerData[playerid][Business][i]); // Construct the line: "Business <BusinessID>"
fwrite(PFile, LineForFile); // And save it to the file
}
}
PHP код:
BusinessTime_Load()
{
// Setup local variables
new File:BFile, LineFromFile[100], ParameterName[50], ParameterValue[50];
// Try to load the businesstime file
if (fexist("ServerData/Business/BusinessTime.ini"))
{
BFile = fopen("ServerData/Business/BusinessTime.ini", io_read); // Open the businesstime-file for reading
fread(BFile, LineFromFile); // Read the first line of the file
// Keep reading until the end of the file is found (no more data)
while (strlen(LineFromFile) > 0)
{
StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
sscanf(LineFromFile, "s[50]s[50]", ParameterName, ParameterValue); // Extract parametername and parametervalue
// Store the proper value in the proper place
if (strcmp(ParameterName, "BusinessTime", false) == 0) // If the parametername is correct ("BusinessTime")
BusinessTransactionTime = strval(ParameterValue); // Store the BusinessTime
// Read the next line of the file
fread(BFile, LineFromFile);
}
// Close the file
fclose(BFile);
// Return if the file was read correctly
return 1;
}
else
return 0; // Return 0 if the file couldn't be read (doesn't exist)
}
// This function saves the file that holds the current business-time
BusinessTime_Save()
{
new File:BFile, LineForFile[100];
BFile = fopen("ServerData/Business/BusinessTime.ini", io_write); // Open the businesstime-file for writing
format(LineForFile, 100, "BusinessTime %i\r\n", BusinessTransactionTime); // Construct the line: "BusinessTime <BusinessTransactionTime>"
fwrite(BFile, LineForFile); // And save it to the file
fclose(BFile); // Close the file
return 1;
}
Alguem poderia me ajudar com alguns salvamentos?