[Ajuda] Carregar Mysql
#1

Ola estou iniciando o mysql no ppc_trucking.. e para carregar scores e dinheiro й fбcil

PHP код:
    SetPlayerScore(playeridAPlayerData[playerid][PlayerScore]);
    
GivePlayerMoney(playeridAPlayerData[playerid][PlayerMoney]); 
Mais e agora para carregar tipo :

PHP код:
APlayerData[playerid][StatsTruckerJobs
Como eu fasso?
Reply
#2

Faz assim

PHP код:
        new query[128];
        
format(querysizeof(query), "UPDATE `Jogadores` SET StatsTruckerJobs='%i' WHERE `Jogador` = '%s'"APlayerData[i][StatsTruckerJobs], Nome(i));
        
mysql_function_query(mysqlqueryfalse""""); 
Reply
#3

Eu fasso assim, mais isso ґnгo й pra salvar?
Reply
#4

uй usa "INSERT"
Reply
#5

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(playeridNome24);
    
mysql_format(StringConexaoQuerysizeof(Query), "SELECT * FROM `Contas` WHERE `Nome`='%s'"Nome);
    
mysql_tquery(StringConexaoQuery"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
Reply
#6

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
Reply
#7

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], Namefalse) == 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 iMAX_BUSINESSPERPLAYERi++)
 {
  
// Check if there is a valid business-id in this slot
  
if (APlayerData[playerid][Business][i] != 0)
  {
   
format(LineForFile100"Business %i\r\n"APlayerData[playerid][Business][i]); // Construct the line: "Business <BusinessID>"
   
fwrite(PFileLineForFile); // And save it to the file
  
}
 } 
PHP код:
BusinessTime_Load()
{
 
// Setup local variables
 
new File:BFileLineFromFile[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(BFileLineFromFile); // 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]"ParameterNameParameterValue); // 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(BFileLineFromFile);
  }
        
// 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:BFileLineForFile[100];
 
BFile fopen("ServerData/Business/BusinessTime.ini"io_write); // Open the businesstime-file for writing
 
format(LineForFile100"BusinessTime %i\r\n"BusinessTransactionTime); // Construct the line: "BusinessTime <BusinessTransactionTime>"
 
fwrite(BFileLineForFile); // And save it to the file
 
fclose(BFile); // Close the file
 
return 1;

Alguem poderia me ajudar com alguns salvamentos?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)