[AJUDA] Car system (nao funciona) -
taborda11 - 21.02.2012
Boas a toda a gente, Eu tenho um server SA:MP e tenho um GM feito por mim e por mais um membro da minha equipa de scripters.
Код:
if(strcmp(cmd, "/buycar", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You need to login first ! ");
return 1;
}
new car = GetPlayerVehicleID(playerid);
new model = GetVehicleModel(idcar);
if(IsASalesVehicle(idcar))
{
if(PlayerInfo[playerid][pPcarkey] == 9999 || PlayerInfo[playerid][pPcarkey2] == 9999) { }
else return SendClientMessage(playerid, COLOR_GREY,"* You already own Two cars!");
if(GetPlayerMoney(playerid) >= GetVehiclePrice(idcar))
{
if(PlayerInfo[playerid][pCarLic] == 1)
{
for(new h = 1; h < sizeof(CarInfo); h++)
{
if(CarInfo[h][cOwned] == 0)
{
car = h;
h = 9999;
}
}
format(string, sizeof(string),"Vehicles/%d.ini",car)
dini_Create(string);
if(PlayerInfo[playerid][pPcarkey] != 9999) { PlayerInfo[playerid][pPcarkey2] = car; }
else { PlayerInfo[playerid][pPcarkey] = car; }
CarInfo[car][cOwner] = 1;
strmid(CarInfo[car][cOwner], sendername, 0, strlen(sendername), 999);
SafeGivePlayerMoney(playerid,-GetVehiclePrice(idcar));
if(IsModelAPlane(idcar) || IsModelAHeli(idcar))
{
SafeSetPlayerPos(playerid, 2020.6288,-2448.9353,13.5469);
CarInfo[car][cLocationx] = 2020.6288;
CarInfo[car][cLocationy] = -2448.9353;
CarInfo[car][cLocationz] = 13.5469;
CarInfo[car][cAngle] = 90.0000;
SendClientMessage(playerid, COLOR_YELLOW2, "Your Aircraft has been deliveried in your position, you can get it there!");
SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!");
SendClientMessage(playerid, COLOR_NICERED, "REMEMBER: Leaving your car in the deliver point can get your car SOLD by an administration without refund!");
GameTextForPlayer(playerid, "~p~Congratulations~n~~w~Don't forget to pickup your car at the ~b~Las Venturas Airport!", 5000, 3);
}
else if(IsModelABoat(idcar))
{
new Float:X, Float:Y, Float:Z; GetPlayerPos(playerid, X,Y,Z); SafeSetPlayerPos(playerid, X,Y,Z);
SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle has been deliveried in your position, you can get it there!");
SendClientMessage(playerid, COLOR_NICERED, "REMEMBER: Leaving your car in the deliver point can get your car SOLD by an administration without refund!");
}
else
{
SafeSetPlayerPos(playerid,2449.9614,-2620.5871,13.4661);
CarInfo[car][cLocationx] = 2461.6628;
CarInfo[car][cLocationy] = -2617.1330;
CarInfo[car][cLocationz] = 13.4630;
CarInfo[car][cAngle] = 90.0000;
SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle has been deliveried in your position, you can get it there!");
SendClientMessage(playerid, COLOR_NICERED, "REMEMBER: Leaving your car in the deliver point can get your car SOLD by an administration without refund!");
}
CarInfo[car][cModel] = model;
CarInfo[car][cVirWorld] = 0;
CarInfo[car][cPaintjob] = 999;
CarInfo[car][cColorOne] = 1;
CarInfo[car][cColorTwo] = 1;
CarInfo[car][cComponent0] = 0;
CarInfo[car][cComponent1] = 0;
CarInfo[car][cComponent2] = 0;
CarInfo[car][cComponent3] = 0;
CarInfo[car][cComponent4] = 0;
CarInfo[car][cComponent5] = 0;
CarInfo[car][cComponent6] = 0;
CarInfo[car][cComponent7] = 0;
CarInfo[car][cComponent8] = 0;
CarInfo[car][cComponent9] = 0;
CarInfo[car][cComponent10] = 0;
CarInfo[car][cComponent11] = 0;
CarInfo[car][cComponent12] = 0;
CarInfo[car][cComponent13] = 0;
DestroyVehicle(car);
ownedcar[car] = CreateVehicle(CarInfo[car][cModel],CarInfo[car][cLocationx],CarInfo[car][cLocationy],CarInfo[car][cLocationz],90.0,1,1,30000);
PlayerPlayMusic(playerid);
SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
SendClientMessage(playerid, COLOR_GRAD2, "Type /carhelp to view the vehicle manual!");
gEngine[playerid] = 0;
engineOn[GetPlayerVehicleID(playerid)] = false;
OnPropUpdate(4,car);
OnPlayerUpdateEx(playerid);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "* For security reasons, a Driving License is needed to buy a car!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You don't have enough cash with you ! ");
return 1;
}
}
}
return 1;
}
O problema й que quando alguem dб "/buycar", o carro criado vai tomar lugar de um carro ja existente, nгo criando assim um novo carro mas substituindo por outro.
Agradecido pela vossa ajuda,
Taborda11
Re: [AJUDA] Car system (nao funciona) -
SPOT_M16 - 21.02.2012
й porque sу tem um vбriavel de carro, cria mais uma e coloka um limite de carros p n ter q fazer 10 variaveis
faz car1 car2 car3 e etc
faz uns if p q quand ele compre o primeiro a variavel do segund seja car2 e por ai vai
dps faz un if p ver se ele tm o carro 3, se ele tiver ele n pode compra mais
ou tira
DestroyVehicle(car); - pode ser isso tb huehuheuehueheu
Re: [AJUDA] Car system (nao funciona) -
taborda11 - 22.02.2012
Basicamente o meu problema era o DestroyVehicle(car);
Mas agora tou com problemas com o owner, pois quando compro um carro, este assimila o id do 1є e nao cria o 2є.
Re: [AJUDA] Car system (nao funciona) -
taborda11 - 22.02.2012
e deixa os outros carros seguintes sem owner.
Re: [AJUDA] Car system (nao funciona) -
SPOT_M16 - 22.02.2012
faz akilo que eu falei d vбriavel.
Re: [AJUDA] Car system (nao funciona) -
taborda11 - 22.02.2012
for(new h >= 192; h < sizeof(CarInfo); h++)
isto nao podera resolver o problema, й que so o carro com o id 1 fica-me com o nome
Re: [AJUDA] Car system (nao funciona) -
taborda11 - 22.02.2012
Podes-me fazere isso SPOT plz, preciso mesmo disso.
Re: [AJUDA] Car system (nao funciona) -
SPOT_M16 - 22.02.2012
eu so preguiзoso p caralh*
Re: [AJUDA] Car system (nao funciona) -
taborda11 - 22.02.2012
Anda la por favor, estou mesmo a precisar meu.
Re: [AJUDA] Car system (nao funciona) -
taborda11 - 27.02.2012
Alguem de ajudA?