09.02.2014, 12:52
I got this right now:
And the loading
But its not loading the mods. Any idea why?
pawn Код:
House_AddVehicle(HouseID, cModel, Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2, CarID, playerid, cComponents[])
{
new vid, CarSlot, pName[MAX_PLAYER_NAME], string[126], modelid;//, string2[128];
GetPlayerName(playerid, pName, sizeof(pName));
CarSlot = House_GetFreeCarSlot(HouseID);
printf("House_AddVehicle::CarSlot = %d", CarSlot);
if (CarSlot != -1)
{
vid = Vehicle_Create(cModel, cx, cy, cz, crot, Col2, Col1, 600);
printf("House_AddVehicle::vid= %d", vid);
AHouseData[HouseID][VehicleIDs][CarSlot] = vid;
printf("House_AddVehicle::AHouseData[%d][VehicleIDs][%d]= %d", HouseID, CarSlot, AHouseData[HouseID][VehicleIDs][CarSlot]);
AVehicleData[vid][CarModel] = cModel;
AVehicleData[AHouseData[HouseID][VehicleIDs][CarSlot]][SaveID] = CarID;
// Save the spawn-data of the vehicle
AVehicleData[vid][SpawnX] = cx;
AVehicleData[vid][SpawnY] = cy;
AVehicleData[vid][SpawnZ] = cz;
AVehicleData[vid][SpawnRot] = crot;
AVehicleData[vid][Color1] = Col2;
AVehicleData[vid][Color2] = Col1;
for (new s; s != 14; ++s)
{
if (cComponents[s]) AddVehicleComponent(vid, cComponents[s]);
}
// Apply the given parameters to the vehicle
AVehicleData[vid][FuelData] = MaxFuel;
AVehicleData[vid][Owned] = true;
ChangeVehicleColor(vid, AVehicleData[vid][Color1], AVehicleData[vid][Color2]);
format(AVehicleData[vid][Owner], 24, pName);
AVehicleData[vid][BelongsToHouse] = HouseID;
modelid = GetVehicleModel(vid);
format(string, sizeof(string), "%s's %s", pName, VehicleNames2[modelid-400]);
VehText[vid] = Create3DTextLabel(string,0xFFFFFFFF,0,0,0,100.0,0);
Attach3DTextLabelToVehicle(VehText[vid], vid, 0,0,0);
print("Vehicle loaded");
}
else
{
print ("No free carslot");// No free carslot was found, return 0
return 0;
}
// Exit the function and return the vehicle-id
return vid;
}
pawn Код:
public OnPlayerHousesVehiclesLoad(playerid, houseid_)
{
printf( "OnPlayerHousesVehiclesLoad::houseid_ = %d", houseid_ );
new rows, fields;
cache_get_data( rows, fields, Handle );
if( rows )
{
print("There are rows - Vehicles");
new
idx = 0,
cmodel2, Float: cx2, Float: cy2, Float: cz2, Float: crot2, ccol1, ccol2, _carid, mods[71], a[14];
while( rows > idx )
{
_carid = cache_get_row_int(idx, 1);
cmodel2 = cache_get_row_int( idx, 3 );
cx2 = cache_get_row_float( idx, 4 );
cy2 = cache_get_row_float( idx, 5 );
cz2 = cache_get_row_float( idx, 6 );
crot2 = cache_get_row_float( idx, 7 );
ccol1 = cache_get_row_int( idx, 8 );
ccol2 = cache_get_row_int( idx, 9 );
//Modding
cache_get_row( 0, 14, mods, Handle, 71 );
sscanf(mods, "p<,>a<i>[14]", a);
printf("ccol1: %i, ccol2: %i", ccol1, ccol2);
printf("House_AddVehicle(%d,%d,%f,%f,%f,%f,%d,%d, %d);", houseid_, cmodel2, cx2, cy2, cz2, crot2, ccol1, ccol2, _carid);
House_AddVehicle(houseid_, cmodel2, cx2, cy2, cz2, crot2, ccol1, ccol2, _carid, playerid, a);
print("Car loaded");
idx++;
}
}
return 1;
}