I found Vehicle System but if I have two vehicles before and the first to appear first - empty - but I want there to give that player a vehicle .. The thing I do not want to have written - empty - as long as the player does not have 1 or vehicle so the first line can be 'You have no vehicles'.. Thanks
Код:
CMD:garage(playerid, params[]){
new string1[700],string2[100];
for(new i;i<MAX_PLAYER_CARS;i++){
if(ID[playerid][i]==-1){
format(string2,100,"{FFFFFF}- empty -\n");
}else{
format(string2,100,"%s(%i)\n",aVehicleNames[GetVehicleModel(ID[playerid][i])-400], ID[playerid][i]);
}
format(string1,256,"%s%s",string1,string2);
}
ShowPlayerDialog(playerid,DIALOG_MENU,DIALOG_STYLE_LIST,"Garage",string1,"Select","Close");
return 1;
}
stock CreatePlayerVehicle(playerid,slot,model){
new str[100];
format(str,100,"SAF/Cars/%s.%d.cfg",PlayerName(playerid),slot);
fcreate(str);
new Float:pos[4];
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
GetPlayerFacingAngle(playerid, pos[3]);
InfrontOf(playerid,pos[0],pos[1],4);
ID[playerid][slot] = CreateVehicle(model,pos[0],pos[1],pos[2],pos[3],0,0,-1);
Model[playerid][slot] = model;
Pos[playerid][slot][0] = pos[0];
Pos[playerid][slot][1] = pos[1];
Pos[playerid][slot][2] = pos[2];
Pos[playerid][slot][3] = pos[3];
return true;
}
stock DeletePlayerVehicle(playerid,slot){
if(ID[playerid][slot] == -1) return 0;
new str[100];
format(str,100,"SAF/Cars/%s.%d.cfg",PlayerName(playerid),slot);
if(fexist(str))
fremove(str);
DestroyVehicle(ID[playerid][slot]);
ID[playerid][slot] = -1;
return true;
}
stock SavePlayerVehicles(playerid){
for(new i; i < MAX_PLAYER_CARS;i++){
if(ID[playerid][i] != -1){
new str[100],bigstr[798],Float:health;
new panels,doors,lights,tires;
GetVehicleDamageStatus(ID[playerid][i],panels,doors,lights,tires);
GetVehicleHealth(ID[playerid][i],health);
format(str,100,"SAF/Cars/%s.%d.cfg",PlayerName(playerid),i);
if(!fexist(str)) continue;
new File:file = fopen(str, io_write);
format(bigstr,798,"%d %0.3f %0.3f %0.3f %0.3f %0.3f %d %d %d %d\r\n",Model[playerid][i],Pos[playerid][i][0],Pos[playerid][i][1],Pos[playerid][i][2],Pos[playerid][i][3],health,panels,doors,lights,tires);
// model x y z a health panels doors lights tires
fwrite(file,bigstr);
format(bigstr,798,"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", GetVehicleComponentInSlot(ID[playerid][i],0),
/* 1 2 3 4 5 6 7 8 9 10 11 12 13 c1 c2 pj*/ GetVehicleComponentInSlot(ID[playerid][i],1),
GetVehicleComponentInSlot(ID[playerid][i],2),
GetVehicleComponentInSlot(ID[playerid][i],3),
GetVehicleComponentInSlot(ID[playerid][i],4),
GetVehicleComponentInSlot(ID[playerid][i],5),
GetVehicleComponentInSlot(ID[playerid][i],6),
GetVehicleComponentInSlot(ID[playerid][i],7),
GetVehicleComponentInSlot(ID[playerid][i],8),
GetVehicleComponentInSlot(ID[playerid][i],9),
GetVehicleComponentInSlot(ID[playerid][i],10),
GetVehicleComponentInSlot(ID[playerid][i],11),
GetVehicleComponentInSlot(ID[playerid][i],12),
GetVehicleComponentInSlot(ID[playerid][i],13),
Color[playerid][i][0],
Color[playerid][i][1],
Paintjob[playerid][i]);
fwrite(file,bigstr);
fclose(file);
DestroyVehicle(ID[playerid][i]);
ID[playerid][i] = -1;
}
}
}
stock LoadPlayerVehicles(playerid){
for(new i; i < MAX_PLAYER_CARS;i++){
new str[100];
format(str,100,"SAF/Cars/%s.%d.cfg",PlayerName(playerid),i);
if(fexist(str)){
new bigstr[798];
new File:file = fopen(str,io_read);
fread(file,bigstr);
DelChar(bigstr);
new panels,doors,lights,tires;
sscanf(bigstr, "dfffffdddd", Model[playerid][i],Pos[playerid][i][0],Pos[playerid][i][1],Pos[playerid][i][2],Pos[playerid][i][3],Health[playerid][i],panels,doors,lights,tires);
fread(file,bigstr);
DelChar(bigstr);
sscanf(bigstr, "dddddddddddddddd",Mod[playerid][i][0],Mod[playerid][i][1],Mod[playerid][i][2],Mod[playerid][i][3],Mod[playerid][i][4],Mod[playerid][i][5],Mod[playerid][i][6],Mod[playerid][i][7],Mod[playerid][i][8],Mod[playerid][i][9],Mod[playerid][i][10],Mod[playerid][i][11],Mod[playerid][i][12],Mod[playerid][i][13],Color[playerid][i][0],Color[playerid][i][1],Paintjob[playerid][i]);
fclose(file);
ID[playerid][i] = CreateVehicle(Model[playerid][i],Pos[playerid][i][0],Pos[playerid][i][1],Pos[playerid][i][2],Pos[playerid][i][3],Color[playerid][i][0],Color[playerid][i][1],-1);
SetTimerEx("TunePlayerCar",150,false,"iiiiii",playerid,i,panels,doors,lights,tires);
}
}
}
stock BuyCar(playerid,model,cena,type = 1,id = -1){
if(GetMoney(playerid) < cena) return SCM(playerid,-1,"...");
GiveMoney(playerid,-cena);
new slot = -1;
if(type == 1){
slot = GetPVarInt(playerid,"VehiclesSelected");
}else{
for(new i; i < MAX_PLAYER_CARS;i++){
if(ID[playerid][i] == -1){
slot = i;
break;
}
}
}
if(slot == -1) return SCM(playerid,-1,"...");
CreatePlayerVehicle(playerid,slot,model);
return true;
}
public TunePlayerCar(playerid,slot,panels,doors,lights,tires){
//print("TunePlayerCar");
for(new i; i < 14;i++){
AddVehicleComponent(ID[playerid][slot], Mod[playerid][slot][i]);
}
SetVehicleHealth(ID[playerid][slot],Health[playerid][slot]);
UpdateVehicleDamageStatus(ID[playerid][slot],panels,doors,lights,tires);
ChangeVehiclePaintjob(ID[playerid][slot], Paintjob[playerid][slot]);
return true;
}
Do you actually expect us to help you when your code looks like that? I mean its unreadable and improperly indented, properly from the copy and paste, but you could of put a few extra seconds into making it readable for us.
I have absolutely no idea what your trying to achieve here? Your grammar is pretty poor. I am struggling to understand what it is your trying to tell us? Maybe someone else can, but I certainly can't.
Grammar is thus possible that the texts are copied with ****** translate because I'm not an Englishman or an American. I do not know English as well as you who have it in native language.
I need it when I have the 3 vehicle to be first so that it is not - empty - on the first line but last to empty slots implying for the last, and the first vehicles ..
So if I understand you.
Yes.. Please send me code
However, in your DIALOG_MENU dialog response should be changed too...
Sorry, that's a mistake.
Please send a link to a simple Vehicle System with saving DOF2 or file.inc and easily add / delete player's car where you can use the command / garage (no plugins or dynamic) please