[Ajuda] Concessionaria
#1

Pessoal, entгo, meio que desenvolvi/base de uma concessionaria SUPER SIMPLES, porйm, estou com um problema, em vez de salvar todos os dados no arquivo criado, ele fica tudo zero!

PHP код:
ModelID 0
Owner 
= (null)
NrPlate = (null)
Position X 0.00000000
Position Y 
0.00000000
Position Z 
0.00000000
Position A 
0.00000000
ColorA 
0
ColorB 
0
Locked 
0
Faction 

Aonde estaria o erro? Pois ao selecionar o carro desejado, existe uma stock CreatePlayerVehicle, e para salvar os veнculos e carrega-lфs й SaveVehicles() e LoadVehicles().
Reply
#2

Mostre a parte de criar o carro e de salvar.

A de carregar nгo precisa (ainda).
Reply
#3

PHP код:
SaveVehicles()
{
    new 
file[64];
    for(new 
1MAX_CARS++)
    {
        
format(file64CARROSv);
        if(
DOF2_FileExists(file))
        
DOF2_SetInt(file"ModelID"VehicleInfo[v][ModelID]);
        
DOF2_SetString(file"Owner"VehicleInfo[v][Owner]);
        
DOF2_SetString(file"NrPlate"VehicleInfo[v][NrPlate]);
        
DOF2_SetFloat(file"Position X"VehicleInfo[v][posX]);
        
DOF2_SetFloat(file"Position Y"VehicleInfo[v][posY]);
        
DOF2_SetFloat(file"Position Z"VehicleInfo[v][posZ]);
        
DOF2_SetFloat(file"Position A"VehicleInfo[v][posA]);
        
DOF2_SetInt(file"ColorA"VehicleInfo[v][ColorA]);
        
DOF2_SetInt(file"ColorB"VehicleInfo[v][ColorB]);
        
DOF2_SetInt(file"Locked"VehicleInfo[v][Locked]);
        
DOF2_SetInt(file"Faction"VehicleInfo[v][Faction]);
        
DOF2_SaveFile();
    }
    return 
1;

PHP код:
stock CreatePlayerVehicle(playeridmodel)
{
    new 
file[64], playercarv;
    
playercar CreateVehicle(model, -156.0357,1181.0258,19.3808,179.2710random(5), random(5), -1);
    
PutPlayerInVehicle(playeridplayercar0);
    
VehicleInfo[playercar][ModelID] = model;
    
VehicleInfo[playercar][NrPlate] = "BB-0000";
    
format(VehicleInfo[playercar][Owner], 100"%s"RPName(playerid));
    
VehicleInfo[playercar][posX] = -156.0357;
    
VehicleInfo[playercar][posY] = 1181.0258;
    
VehicleInfo[playercar][posZ] = 19.3808;
    
VehicleInfo[playercar][posA] = 179.2710;
    
VehicleInfo[playercar][ColorA] = random(5);
    
VehicleInfo[playercar][ColorB] = random(5);
    
VehicleInfo[playercar][Locked] = 1;
    
VehicleInfo[playercar][Faction] = 0;
    
format(file64CARROSv);
    if(!
DOF2_FileExists(file)) DOF2_CreateFile(file);
    {
        
DOF2_SetInt(file"ModelID"VehicleInfo[v][ModelID]);
        
DOF2_SetString(file"Owner"VehicleInfo[v][Owner]);
        
DOF2_SetString(file"NrPlate"VehicleInfo[v][NrPlate]);
        
DOF2_SetFloat(file"Position X"VehicleInfo[v][posX]);
        
DOF2_SetFloat(file"Position Y"VehicleInfo[v][posY]);
        
DOF2_SetFloat(file"Position Z"VehicleInfo[v][posZ]);
        
DOF2_SetFloat(file"Position A"VehicleInfo[v][posA]);
        
DOF2_SetInt(file"ColorA"VehicleInfo[v][ColorA]);
        
DOF2_SetInt(file"ColorB"VehicleInfo[v][ColorB]);
        
DOF2_SetInt(file"Locked"VehicleInfo[v][Locked]);
        
DOF2_SetInt(file"Faction"VehicleInfo[v][Faction]);
        
        
DOF2_SaveFile();
    }
    
PlayerInfo[playerid][VehicleOwner] = playercar;
    return 
1;

Reply
#4

Aumenta essas cйlulas ai, 64 й muito pouco.
Teste com 128.
PHP код:
new file[128]; 
PHP код:
format(file128CARROSv); 
Obs estou pelo celular.

@Edit
A variбvel "v" na funзгo de criar o carro estб sem sentido. Quando eu chegar de noite se vc nгo tiver resolvido eu te ajudo.
Reply
#5

seria mais ou menos assim.. obs vocк utiliza o nome do jogador para saber se ele й o dono.

PHP код:
new VEICULOS_CONCESSIONARIA[MAX_CARS]; /* ARMAZENAR OS CARROS DA CONCESSIONARIA */
SaveVehicles(){
    new
        
file[64]
    ;
    for(new 
1MAX_CARS++){
        
format(file64CARROSv);
        if(
DOF2_FileExists(file)){
            
DOF2_SetInt(file"ModelID"VehicleInfo[v][ModelID]);
            
DOF2_SetString(file"Owner"VehicleInfo[v][Owner]);
            
DOF2_SetString(file"NrPlate"VehicleInfo[v][NrPlate]);
            
DOF2_SetFloat(file"Position X"VehicleInfo[v][posX]);
            
DOF2_SetFloat(file"Position Y"VehicleInfo[v][posY]);
            
DOF2_SetFloat(file"Position Z"VehicleInfo[v][posZ]);
            
DOF2_SetFloat(file"Position A"VehicleInfo[v][posA]);
            
DOF2_SetInt(file"ColorA"VehicleInfo[v][ColorA]);
            
DOF2_SetInt(file"ColorB"VehicleInfo[v][ColorB]);
            
DOF2_SetInt(file"Locked"VehicleInfo[v][Locked]);
            
DOF2_SetInt(file"Faction"VehicleInfo[v][Faction]);
            
DOF2_SaveFile();
        }
    }
    return 
1;
}
stock CreatePlayerVehicle(playeridmodel)
{
    new
        
file[64]
    ;
    for( new 
vMAX_CARSv++ ){
        
format(file64CARROSv);
        if(
DOF2_FileExists(v)) continue;
        
VehicleInfo[v][ModelID] = model;
        
VehicleInfo[v][NrPlate] = "BB-0000";
        
format(VehicleInfo[v][Owner], 100"%s"RPName(playerid));
        
VehicleInfo[v][posX] = -156.0357;
        
VehicleInfo[v][posY] = 1181.0258;
        
VehicleInfo[v][posZ] = 19.3808;
        
VehicleInfo[v][posA] = 179.2710;
        
VehicleInfo[v][ColorA] = random(5);
        
VehicleInfo[v][ColorB] = random(5);
        
VehicleInfo[v][Locked] = 1;
        
VehicleInfo[v][Faction] = 0;
        
DOF2_CreateFile(v);
        
DOF2_SetInt(file"ModelID"VehicleInfo[v][ModelID]);
        
DOF2_SetString(file"Owner"VehicleInfo[v][Owner]);
        
DOF2_SetString(file"NrPlate"VehicleInfo[v][NrPlate]);
        
DOF2_SetFloat(file"Position X"VehicleInfo[v][posX]);
        
DOF2_SetFloat(file"Position Y"VehicleInfo[v][posY]);
        
DOF2_SetFloat(file"Position Z"VehicleInfo[v][posZ]);
        
DOF2_SetFloat(file"Position A"VehicleInfo[v][posA]);
        
DOF2_SetInt(file"ColorA"VehicleInfo[v][ColorA]);
        
DOF2_SetInt(file"ColorB"VehicleInfo[v][ColorB]);
        
DOF2_SetInt(file"Locked"VehicleInfo[v][Locked]);
        
DOF2_SetInt(file"Faction"VehicleInfo[v][Faction]);
        
DOF2_SaveFile();
        
VEICULOS_CONCESSIONARIA[v] = CreateVehicleVehicleInfo[v][ModelID], VehicleInfo[v][posX],VehicleInfo[v][posY],VehicleInfo[v][posZ],VehicleInfo[v][posA], VehicleInfo[v][ColorA], VehicleInfo[v][ColorB], -1);
        
PutPlayerInVehicle(playeridVEICULOS_CONCESSIONARIA[v], 0);
        break;
    }
    return 
1;

Reply
#6

@edit esta correto

um pequeno erro

PHP код:

stock CreatePlayerVehicle
(playeridmodel)
{
    new
        
file[64]
    ;
    for( new 
vMAX_CARSv++ ){
        
format(file64CARROSv);
        if(
DOF2_FileExists(file)) continue; // Aqui estava o erro
        
VehicleInfo[v][ModelID] = model;
        
VehicleInfo[v][NrPlate] = "BB-0000";
        
format(VehicleInfo[v][Owner], 100"%s"RPName(playerid));
        
VehicleInfo[v][posX] = -156.0357;
        
VehicleInfo[v][posY] = 1181.0258;
        
VehicleInfo[v][posZ] = 19.3808;
        
VehicleInfo[v][posA] = 179.2710;
        
VehicleInfo[v][ColorA] = random(5);
        
VehicleInfo[v][ColorB] = random(5);
        
VehicleInfo[v][Locked] = 1;
        
VehicleInfo[v][Faction] = 0;
        
DOF2_CreateFile(v);
        
DOF2_SetInt(file"ModelID"VehicleInfo[v][ModelID]);
        
DOF2_SetString(file"Owner"VehicleInfo[v][Owner]);
        
DOF2_SetString(file"NrPlate"VehicleInfo[v][NrPlate]);
        
DOF2_SetFloat(file"Position X"VehicleInfo[v][posX]);
        
DOF2_SetFloat(file"Position Y"VehicleInfo[v][posY]);
        
DOF2_SetFloat(file"Position Z"VehicleInfo[v][posZ]);
        
DOF2_SetFloat(file"Position A"VehicleInfo[v][posA]);
        
DOF2_SetInt(file"ColorA"VehicleInfo[v][ColorA]);
        
DOF2_SetInt(file"ColorB"VehicleInfo[v][ColorB]);
        
DOF2_SetInt(file"Locked"VehicleInfo[v][Locked]);
        
DOF2_SetInt(file"Faction"VehicleInfo[v][Faction]);
        
DOF2_SaveFile();
        
VEICULOS_CONCESSIONARIA[v] = CreateVehicleVehicleInfo[v][ModelID], VehicleInfo[v][posX],VehicleInfo[v][posY],VehicleInfo[v][posZ],VehicleInfo[v][posA], VehicleInfo[v][ColorA], VehicleInfo[v][ColorB], -1);
        
PutPlayerInVehicle(playeridVEICULOS_CONCESSIONARIA[v], 0);
        break;
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)