16.01.2017, 16:56
(
Последний раз редактировалось James585; 16.01.2017 в 17:10.
Причина: Code
)
Hello 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
Garage:
Garage:
Код:
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; }