Concessionaria -
FernandoDutra - 30.06.2016
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 = 0
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().
Re: Concessionaria -
Cleyson - 30.06.2016
Mostre a parte de criar o carro e de salvar.
A de carregar nгo precisa (ainda).
Re: Concessionaria -
FernandoDutra - 30.06.2016
PHP код:
SaveVehicles()
{
new file[64];
for(new v = 1; v < MAX_CARS; v ++)
{
format(file, 64, CARROS, v);
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(playerid, model)
{
new file[64], playercar, v;
playercar = CreateVehicle(model, -156.0357,1181.0258,19.3808,179.2710, random(5), random(5), -1);
PutPlayerInVehicle(playerid, playercar, 0);
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(file, 64, CARROS, v);
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;
}
Re: Concessionaria -
Cleyson - 30.06.2016
Aumenta essas cйlulas ai, 64 й muito pouco.
Teste com 128.
PHP код:
format(file, 128, CARROS, v);
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.
Re: Concessionaria - Whoo - 30.06.2016
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 v = 1; v < MAX_CARS; v ++){
format(file, 64, CARROS, v);
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(playerid, model)
{
new
file[64]
;
for( new v; v < MAX_CARS; v++ ){
format(file, 64, CARROS, v);
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] = CreateVehicle( VehicleInfo[v][ModelID], VehicleInfo[v][posX],VehicleInfo[v][posY],VehicleInfo[v][posZ],VehicleInfo[v][posA], VehicleInfo[v][ColorA], VehicleInfo[v][ColorB], -1);
PutPlayerInVehicle(playerid, VEICULOS_CONCESSIONARIA[v], 0);
break;
}
return 1;
}
Respuesta: Re: Concessionaria -
SammyJ - 01.07.2016
@edit esta correto
um pequeno erro
PHP код:
stock CreatePlayerVehicle(playerid, model)
{
new
file[64]
;
for( new v; v < MAX_CARS; v++ ){
format(file, 64, CARROS, v);
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] = CreateVehicle( VehicleInfo[v][ModelID], VehicleInfo[v][posX],VehicleInfo[v][posY],VehicleInfo[v][posZ],VehicleInfo[v][posA], VehicleInfo[v][ColorA], VehicleInfo[v][ColorB], -1);
PutPlayerInVehicle(playerid, VEICULOS_CONCESSIONARIA[v], 0);
break;
}
return 1;
}