Carros -
caoraivoso3 - 22.08.2012
Boas,desculpem mas chegei a uma conclusao boa e conseuig fazer alguma coisa,й o o seguinte,eu tenho defenido 501 carros,depois resetei todos
pawn Код:
if(strcmp(cmd, "/fodercarros", true) == 0)
{
if(PlayerInfo[playerid][mstrvbcAdmin] < 13)
return SendClientMessage(playerid, COLOR_WHITE, "Nгo йs Administrador.");
new i,
Float:distance = 6.0,
Float:metres = distance;
for(; i < sizeof(DynamicCars); i++, metres += distance)
{
GetPlayerPos(playerid, DynamicCars[i][CarX], DynamicCars[i][CarY], DynamicCars[i][CarZ]);
new Float:a;
GetPlayerFacingAngle(playerid, a);
DynamicCars[i][CarColor1] = -1;
DynamicCars[i][CarColor2] = -1;
DynamicCars[i][FactionCar] = 255;
DynamicCars[i][CarType] = 0;
DynamicCars[i][CarAngle] = a;
DynamicCars[i][CarModel] = 510; //Bicicleta
DynamicCars[i][CarX] += (metres * floatsin(-a, degrees));
DynamicCars[i][CarY] += (metres * floatcos(-a, degrees));
DynamicCars[i][Neon] = 0;
DestroyVehicle(i);
Fuel[i] = GasMax;
EngineStatus[i] = 0;
VehicleLocked[i] = 0;
CarWindowStatus[i] = 1; //1 = up, 0 = down.
}
SaveDynamicCars();
return 1;
}
resetei os carros sem de ter os criar. Depois faзo
pawn Код:
if(strcmp(cmd, "/acarsetpos", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Comando: /acarsetpos [carid]");
return 1;
}
new id = strval(tmp);
if (PlayerInfo[playerid][mstrvbcAdmin] >= 20)
{
if(id != INVALID_VEHICLE_ID)
{
new Float:x,Float:y,Float:z;
new Float:a;
GetPlayerPos(playerid, x, y, z);
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
else
{
GetPlayerFacingAngle(playerid, a);
}
DynamicCars[id-1][CarX] = x;
DynamicCars[id-1][CarY] = y;
DynamicCars[id-1][CarZ] = z;
DynamicCars[id-1][CarAngle] = a;
DestroyVehicle(id);
CreateVehicle(DynamicCars[id-1][CarModel],DynamicCars[id-1][CarX],DynamicCars[id-1][CarY],DynamicCars[id-1][CarZ],DynamicCars[id-1][CarAngle],DynamicCars[id-1][CarColor1],DynamicCars[id-1][CarColor2], -1);
SaveDynamicCars();
LoadComponents(id);
//PutPlayerInVehicle(playerid,id,0);
new wstring[128];
format(wstring, sizeof(wstring), "Tu escolheste o veiculo ID: %d's para esta localizaзгo.", id);
SendClientMessage(playerid,COLOR_ADMINCMD, wstring);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "ERRO: Invalido veiculo ID.");
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "Nгo йs Administrador.");
}
}
return 1;
}
esse comando,e cria o carro й so fazer /acarsetpos 1 e cria o carro ID 1 prontos,atй ai tudo bem. Comprava carros no stand e via depois ID 2,como eu queria,fantastico,estava todo feliz,mas quando depois dou GMX,apareзia novamente os 500 carros no mapa '-' Como faзo pra mudar? /fodercarros e reset os carros todos,sem criando,depois uso /acarsetpos para criar o carro,mas quando dou gmx volta tudo como dantes,apareзe os 500 carros. E AGORA? ajuda!
Re: Carros -
caoraivoso3 - 22.08.2012
Consegui fazer mas como salvo agora?
Re: Carros -
Hydra_RuleZ - 22.08.2012
cara voce quer que ao /acarsetpos guarde as coordenadas do veiculo em que o player esta nй?
Re: Carros -
Hydra_RuleZ - 22.08.2012
pawn Код:
forward LoadCarros();
public LoadCarros()
{
new arquivo[256];
new idx = 1;
while (idx < sizeof(DynamicCars))
{
format(arquivo, sizeof(arquivo), "/Carros/carro%d.ini",idx);
if(!fexist(arquivo))
{
print("[caoraivoso3] Os Arquivos dos Carros nгo foram encontrados !");
print("[caoraivoso3] O Gamemode Estб Criando os Arquivos dos Carros......");
dini_Create(arquivo);
dini_IntSet(arquivo,"CarColor1",0);
dini_IntSet(arquivo,"CarColor2",0);
dini_IntSet(arquivo,"FactionCar",0);
dini_IntSet(arquivo,"CarType",0);
dini_IntSet(arquivo,"CarAngle",0);
dini_IntSet(arquivo,"CarModel",411);
dini_IntSet(arquivo,"CarX",0);
dini_IntSet(arquivo,"CarY",0);
}
DynamicCars[idx][CarColor1] = dini_Int(arquivo,"CarColor1");
DynamicCars[idx][CarColor2] = dini_Int(arquivo,"CarColor2");
DynamicCars[idx][FactionCar] = dini_Int(arquivo,"FactionCar");
DynamicCars[idx][CarType] = dini_Int(arquivo,"CarType");
DynamicCars[idx][CarAngle] = dini_Int(arquivo,"CarAngle");
DynamicCars[idx][CarModel] = dini_Int(arquivo,"CarModel");
DynamicCars[idx][CarX] = dini_Int(arquivo,"CarX");
DynamicCars[idx][CarY] = dini_Int(arquivo,"CarY");
idx ++;
}
return 1;
}
pawn Код:
forward SaveCarros();
public SaveCarros()
{
new arquivo[256];
new idx = 1;
while (idx < sizeof(DynamicCars))
{
format(arquivo, sizeof(arquivo), "/Carros/carro%d.ini",idx);
dini_IntSet(arquivo,"CarColor1",DynamicCars[idx][CarColor1]);
dini_IntSet(arquivo,"CarColor2",DynamicCars[idx][CarColor2]);
dini_IntSet(arquivo,"FactionCar",DynamicCars[idx][FactionCar]);
dini_IntSet(arquivo,"CarType",DynamicCars[idx][CarType]);
dini_FloatSet(arquivo,"CarAngle",DynamicCars[idx][CarAngle]);
dini_IntSet(arquivo,"CarModel",DynamicCars[idx][CarModel]);
dini_FloatSet(arquivo,"CarX",DynamicCars[idx][CarX]);
dini_FloatSet(arquivo,"CarY",DynamicCars[idx][CarY]);
idx ++;
}
return 1;
}
no seu cmd de /acarsetpos onde tem SaveDynamicCars(); substitui por SaveCarros();
fala ae depois se funfou :P
Re: Carros -
caoraivoso3 - 22.08.2012
e como й? tenho que criar a pasta Carros e ficheiro carro.inc dentro dos scriptfiles?
Re: Carros -
Hydra_RuleZ - 22.08.2012
Dentro da pasta scritfiles tem de criar a pasta Carros , somente isso ao ligar o sampserver ele iб criar as pastas dos carros "DynamicCars" deu pra entender?
Re: Carros -
caoraivoso3 - 22.08.2012
Eu consegui fazer o que queria,dei reset nos carros e foi scriptfiles apgalos. Agora,queriavos pedir era o comando de criar carro sу para admin. Exemplo /criarcarro 1 e criava o carro com id 510 б minha frente com o ID 1,quando digo ID 1 й aquilo do /DL :S um comando do meu GM que secalhar podevos ajudar
pawn Код:
if(strcmp(cmd, "/comprarveiculo", true) == 0)
{
if(PlayerInfo[playerid][msNCarKey] != 4)
{
for(new i = 0; i < sizeof(Businesses); i++)
{
if (PlayerToPoint(25.0, playerid,Businesses[i][ExitX], Businesses[i][ExitY], Businesses[i][ExitZ]))
{
if(GetPlayerVirtualWorld(playerid) == i)
{
if(Businesses[i][BizType] == 9)
{
if(PlayerToPoint(10.0, playerid,345.5447,160.1090,1014.1875))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Comando: /comprarveiculo [modelo]");
return 1;
}
new TCarModel = strval(tmp);
ShopCar[playerid] = CreateVehicle(TCarModel, -538.8217, 2599.4775, 53.0267, 271.4271, 1, 1, -1);
if(IsValidModel(TCarModel))
{
new valor= TCarModel-400;
new price = VehiclePrices[valor][0];
new ctill = VehiclePrices[valor][0]/4;
new vprice;
if(PlayerInfo[playerid][msVipActive] != 0)
{
vprice = VehiclePrices[valor][0]/2;
}
else
{
vprice = VehiclePrices[valor][0];
}
if (vprice <= GetPlayerEuros(playerid))
{
PlayerActionMessage(playerid,15.0,"entrega um cheque ao gerente do Stand, que dб em troca a chave do carro");
SendClientMessage(playerid, COLOR_YELLOW2, "Compraste o carro com sucesso.");
Car[ShopCar[playerid]][CarModel] = TCarModel;
Car[ShopCar[playerid]][CarID] = ShopCar[playerid];
Car[ShopCar[playerid]][ParkX] = 2461.6431;
Car[ShopCar[playerid]][ParkY] = -41.9446;
Car[ShopCar[playerid]][ParkZ] = 26.1095;
Car[ShopCar[playerid]][ParkAngle] = 0.0;
Car[ShopCar[playerid]][CarColor1] = 1;
Car[ShopCar[playerid]][CarColor2] = 1;
Car[ShopCar[playerid]][Owned] = 1;
Car[ShopCar[playerid]][Materials] = 0;
Car[ShopCar[playerid]][cCocaina] = 0;
Car[ShopCar[playerid]][cHeroina] = 0;
Car[ShopCar[playerid]][cExtasy] = 0;
Car[ShopCar[playerid]][cErva] = 0;
Car[ShopCar[playerid]][cPolen] = 0;
Car[ShopCar[playerid]][Sell] = 0;
Car[ShopCar[playerid]][Locked] = 0;
new Matri = random(sizeof(MatriculasNames));
if(Car[ShopCar[playerid]][Matriculed]==0)
{
if(ShopCar[playerid] <= 10)
{
format(string, sizeof(string), "0%d-%s-%d", ShopCar[playerid], MatriculasNames[Matri], ShopCar[playerid]+15);
strmid(Car[ShopCar[playerid]][Matricula], string, 0, strlen(string), 999);
Car[ShopCar[playerid]][Matriculed]= 1;
}
else if(ShopCar[playerid] <= 80 && ShopCar[playerid] >= 10)
{
format(string, sizeof(string), "%d-%s-%d", ShopCar[playerid], MatriculasNames[Matri], ShopCar[playerid]+15);
strmid(Car[ShopCar[playerid]][Matricula], string, 0, strlen(string), 999);
Car[ShopCar[playerid]][Matriculed]= 1;
}
else if(ShopCar[playerid] <= 100 && ShopCar[playerid] >= 80)
{
format(string, sizeof(string), "%d-%s-%d", ShopCar[playerid], MatriculasNames[Matri], ShopCar[playerid]-15);
strmid(Car[ShopCar[playerid]][Matricula], string, 0, strlen(string), 999);
Car[ShopCar[playerid]][Matriculed]= 1;
}
else
{
format(string, sizeof(string), "%d-%s-%d", ShopCar[playerid]-90, MatriculasNames[Matri], ShopCar[playerid]-85);
strmid(Car[ShopCar[playerid]][Matricula], string, 0, strlen(string), 999);
Car[ShopCar[playerid]][Matriculed]= 1;
}
}
format(string, sizeof(string), "%s", Car[ShopCar[playerid]][Matricula]);
SetVehicleNumberPlate(ShopCar[playerid],string);
ShowMenuForPlayer(Colors, playerid);
SaveCars();
if(PlayerInfo[playerid][msVipActive] != 0)
{
GivePlayerEuros(playerid, -price/2);
Businesses[i][Products]--;
Businesses[i][Till]+=price/2-ctill;
}
else
{
GivePlayerEuros(playerid, -price);
Businesses[i][Products]--;
Businesses[i][Till]+=price-ctill;
}
for(new h = 0; h < sizeof(Car); h++)
{
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
strmid(Car[ShopCar[playerid]][Owner], playername, 0, strlen(playername), 999);
}
if(PlayerInfo[playerid][msNCarKey] == 0)
{
PlayerInfo[playerid][msCarKey1] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
else if(PlayerInfo[playerid][msNCarKey] == 1)
{
if(PlayerInfo[playerid][msCarKey1] == 255)
{
PlayerInfo[playerid][msCarKey1] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
else if(PlayerInfo[playerid][msCarKey2] == 255)
{
PlayerInfo[playerid][msCarKey2] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
else if(PlayerInfo[playerid][msCarKey3] == 255)
{
PlayerInfo[playerid][msCarKey3] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
else if(PlayerInfo[playerid][msCarKey4] == 255)
{
PlayerInfo[playerid][msCarKey4] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
}
else if(PlayerInfo[playerid][msNCarKey] == 2)
{
if(PlayerInfo[playerid][msCarKey1] == 255)
{
PlayerInfo[playerid][msCarKey1] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
else if(PlayerInfo[playerid][msCarKey2] == 255)
{
PlayerInfo[playerid][msCarKey2] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
else if(PlayerInfo[playerid][msCarKey3] == 255)
{
PlayerInfo[playerid][msCarKey3] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
else if(PlayerInfo[playerid][msCarKey4] == 255)
{
PlayerInfo[playerid][msCarKey4] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
}
else if(PlayerInfo[playerid][msNCarKey] == 3)
{
if(PlayerInfo[playerid][msCarKey1] == 255)
{
PlayerInfo[playerid][msCarKey1] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
else if(PlayerInfo[playerid][msCarKey2] == 255)
{
PlayerInfo[playerid][msCarKey2] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
else if(PlayerInfo[playerid][msCarKey3] == 255)
{
PlayerInfo[playerid][msCarKey3] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
else if(PlayerInfo[playerid][msCarKey4] == 255)
{
PlayerInfo[playerid][msCarKey4] = ShopCar[playerid];
PlayerInfo[playerid][msNCarKey] = 1 + PlayerInfo[playerid][msNCarKey];
OnPlayerDataSave(playerid);
}
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "ERRO: Nгo tens dinheiro!");
DestroyVehicle(ShopCar[playerid]);
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "ERRO: Modelo invбlido.");
DestroyVehicle(ShopCar[playerid]);
}
}
}
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "ERRO: Jб tens carros sufecientes!");
}
return 1;
}
Re: Carros -
Hydra_RuleZ - 22.08.2012
funcionou o sistema que lhe fiz?
Re: Carros -
caoraivoso3 - 22.08.2012
nгo :S mas agora jб consegui fazer o que eu queria,so falta й agora o comando de criar