Problem in this command
#1

its compiled. But it doesn't work

any problem in this command.

Код:
//==============================================================================
CMD:creategvehicle(playerid, params[])
{
	new family, modelid, color1, color2;
	if(sscanf(params, "dddd", family, modelid, color1, color2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /creategvehicle [familyid] [modelid] [color 1] [color 2]");

    if (PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pGangModd] != 1)
    {
    	SendClientMessage(playerid, COLOR_GREY, " You are not allowed to use this command.");
     	return 1;
    }
   	if(family < 1 || family > 14) { SendClientMessage(playerid, COLOR_GREY, " FamilyNr can't be below 1 or above 14!"); return 1; }
   	family-=1;
 	if(FamilyInfo[family][FamilyTaken] != 1)
	{
		SendClientMessage(playerid, COLOR_GREY, "   That FamilyNr hasn't been Taken yet!");
		return 1;
	}
	if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 126 !"); return 1; }
	if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 126 !"); return 1; }
	if(modelid < 400 || modelid > 611) { SendClientMessage(playerid, COLOR_GREY, "   Vehicle Number can't be below 400 or above 611 !"); return 1; }
 	new gangvehicleid = GetGangFreeVehicleId(family);
	if(gangvehicleid == -1) return SendClientMessage(playerid, COLOR_GREY, "ERROR: That family can't have more cars.");
	new Float:X,Float:Y,Float:Z;
 	GetPlayerPos(playerid,X,Y,Z);
  	new Float:Angle;
   	GetPlayerFacingAngle(playerid,Angle);
   	new car = CreateGangVehicle(family, gangvehicleid, modelid, X, Y, Z, Angle, color1, color2, 0);
   	if(car == INVALID_VEHICLE_ID)
	{
 		SendClientMessage(playerid, COLOR_GREY, "ERROR: Something went wrong and the car didn't got created.");
	}
 	else
  	{
   		format(string, sizeof(string), " Vehicle successfully created with ID %d.", car);
    	SendClientMessage(playerid, COLOR_GRAD1, string);
	    SaveFamilies();
	}
	return 1;
}

CMD:destroygvehicle(playerid, params[])
{
	new family, vehicleid;
	if(sscanf(params, "dd", family, vehicleid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /destroygvehicle [familyid] [vehicleid]");

    if (PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pGangModd] != 1)
    {
    	SendClientMessage(playerid, COLOR_GREY, " You are not allowed to use this command.");
     	return 1;
    }
    if(family < 1 || family > 14) { SendClientMessage(playerid, COLOR_GREY, "   FamilyNr can't be below 1 or above 14!"); return 1; }
	family -= 1;
	new gangvehicleid = GetGangVehicle(family, vehicleid);
	if(gangvehicleid == -1) return SendClientMessage(playerid, COLOR_GREY, "ERROR: That family doesn't own that vehicle.");
	DestroyGangVehicle(family, gangvehicleid);
	SaveFamilies();
	return 1;
}


Код:
stock CreateGangVehicle(f, fv, modelid, Float: x, Float: y, Float: z, Float: angle, color1, color2, price)
{
	if(FamilyVehicleInfo[f][fv][fvId] == INVALID_VEHICLE_ID)
	{
		FamilyVehicleInfo[f][fv][fvModelId] = modelid;
		FamilyVehicleInfo[f][fv][fvSpawnx] = x;
		FamilyVehicleInfo[f][fv][fvSpawny] = y;
		FamilyVehicleInfo[f][fv][fvSpawnz] = z;
		FamilyVehicleInfo[f][fv][fvSpawna] = angle;
		FamilyVehicleInfo[f][fv][fvColor1] = color1;
		FamilyVehicleInfo[f][fv][fvColor2] = color2;
		FamilyVehicleInfo[f][fv][fvPrice] = price;
		FamilyVehicleInfo[f][fv][fvFuel] = 100.0;
		new carcreated = CreateVehicle(modelid,x,y,z,angle,color1,color2,-1);
		FamilyVehicleInfo[f][fv][fvId] = carcreated;
		printf("Created the gang vehicle for family %d | vehicleid #%d | familyvehicleslot #%d.", f, FamilyVehicleInfo[f][fv][fvId], fv);
		return carcreated;
	}
	return INVALID_VEHICLE_ID;
}

stock DestroyGangVehicle(f, fv)
{
	if(FamilyVehicleInfo[f][fv][fvId] != INVALID_VEHICLE_ID)
	{
		DestroyVehicle(FamilyVehicleInfo[f][fv][fvId]);
		FamilyVehicleInfo[f][fv][fvModelId] = 0;
		FamilyVehicleInfo[f][fv][fvSpawnx] = 0.0;
		FamilyVehicleInfo[f][fv][fvSpawny] = 0.0;
		FamilyVehicleInfo[f][fv][fvSpawnz] = 0.0;
		FamilyVehicleInfo[f][fv][fvSpawna] = 0.0;
		FamilyVehicleInfo[f][fv][fvPaintJob] = -1;
		FamilyVehicleInfo[f][fv][fvColor1] = 126;
		FamilyVehicleInfo[f][fv][fvColor2] = 126;
		FamilyVehicleInfo[f][fv][fvPrice] = 0;
		FamilyVehicleInfo[f][fv][fvImpounded] = 0;
		FamilyVehicleInfo[f][fv][fvFuel] = 100.0;
		printf("Family %d vehicle %d(vehicleid %d) has been destroyed.", f,fv,FamilyVehicleInfo[f][fv][fvId]);
	    FamilyVehicleInfo[f][fv][fvId] = INVALID_VEHICLE_ID;
	}
}

stock LoadGangVehicles(f)
{
	//printf(" Loading family %d's vehicles.", f);
	for(new fv = 0; fv < MAX_GANG_VEHICLES; fv++)
    {
        if(FamilyVehicleInfo[f][fv][fvModelId] != 0)
        {
			new carcreated = CreateVehicle(FamilyVehicleInfo[f][fv][fvModelId], FamilyVehicleInfo[f][fv][fvSpawnx], FamilyVehicleInfo[f][fv][fvSpawny], FamilyVehicleInfo[f][fv][fvSpawnz], FamilyVehicleInfo[f][fv][fvSpawna],FamilyVehicleInfo[f][fv][fvColor1], FamilyVehicleInfo[f][fv][fvColor2], -1);
			FamilyVehicleInfo[f][fv][fvId] = carcreated;
			if(FamilyVehicleInfo[f][fv][fvLocked] == 1) LockGangVehicle(f, FamilyVehicleInfo[f][fv][fvId], FamilyVehicleInfo[f][fv][fvLock]);
        }
    }
}

stock UnloadGangVehicles(f)
{
	printf(" Unloading %s's vehicles.", FamilyInfo[f][FamilyName]);
	for(new fv = 0; fv < MAX_PLAYERVEHICLES; fv++)
    {
        if(FamilyVehicleInfo[f][fv][fvId] != INVALID_VEHICLE_ID)
        {
            if(LockStatus[FamilyVehicleInfo[f][fv][fvId]] != 0) LockStatus[FamilyVehicleInfo[f][fv][fvId]] = 0;
			DestroyVehicle(FamilyVehicleInfo[f][fv][fvId]);
			FamilyVehicleInfo[f][fv][fvId] = INVALID_VEHICLE_ID;
        }
    }
}

stock UpdateGangVehicleParkPosition(f, fv, Float:newx, Float:newy, Float:newz, Float:newangle, Float:health, temp = 1)
{
	if(FamilyVehicleInfo[f][fv][fvId] != INVALID_VEHICLE_ID)
	{
	    if(temp == 0)
		{
	 		new Float:oldx, Float:oldy, Float:oldz;
			oldx = FamilyVehicleInfo[f][fv][fvSpawnx];
			oldy = FamilyVehicleInfo[f][fv][fvSpawny];
			oldz = FamilyVehicleInfo[f][fv][fvSpawnz];
			if(oldx == newx && oldy == newy && oldz == newz) return 0;
			FamilyVehicleInfo[f][fv][fvSpawnx] = newx;
			FamilyVehicleInfo[f][fv][fvSpawny] = newy;
			FamilyVehicleInfo[f][fv][fvSpawnz] = newz;
			FamilyVehicleInfo[f][fv][fvSpawna] = newangle;
			DestroyVehicle(FamilyVehicleInfo[f][fv][fvId]);
			new carcreated = CreateVehicle(FamilyVehicleInfo[f][fv][fvModelId], FamilyVehicleInfo[f][fv][fvSpawnx], FamilyVehicleInfo[f][fv][fvSpawny], FamilyVehicleInfo[f][fv][fvSpawnz],
			FamilyVehicleInfo[f][fv][fvSpawna],FamilyVehicleInfo[f][fv][fvColor1], FamilyVehicleInfo[f][fv][fvColor2], -1);
	        FamilyVehicleInfo[f][fv][fvId] = carcreated;
	        SetVehicleHealth(carcreated, health);
	        SaveFamiliesHQ();
        	return 1;
		}
		else
		{
		    new Float:oldx, Float:oldy, Float:oldz;
			oldx = FamilyVehicleInfo[f][fv][fvSpawnxtmp];
			oldy = FamilyVehicleInfo[f][fv][fvSpawnytmp];
			oldz = FamilyVehicleInfo[f][fv][fvSpawnztmp];
			if(oldx == newx && oldy == newy && oldz == newz) return 0;
			FamilyVehicleInfo[f][fv][fvSpawnxtmp] = newx;
			FamilyVehicleInfo[f][fv][fvSpawnytmp] = newy;
			FamilyVehicleInfo[f][fv][fvSpawnztmp] = newz;
			FamilyVehicleInfo[f][fv][fvSpawnatmp] = newangle;
			DestroyVehicle(FamilyVehicleInfo[f][fv][fvId]);
			new carcreated = CreateVehicle(FamilyVehicleInfo[f][fv][fvModelId], FamilyVehicleInfo[f][fv][fvSpawnxtmp], FamilyVehicleInfo[f][fv][fvSpawnytmp], FamilyVehicleInfo[f][fv][fvSpawnztmp],
			FamilyVehicleInfo[f][fv][fvSpawnatmp],FamilyVehicleInfo[f][fv][fvColor1], FamilyVehicleInfo[f][fv][fvColor2], -1);
	        FamilyVehicleInfo[f][fv][fvId] = carcreated;
	        SetVehicleHealth(carcreated, health);
	        SaveFamiliesHQ();
        	return 1;
		}
	}
	return 0;
}

stock GetGangFreeVehicleId(f)
{
    new
		i = 0;
	while (i < MAX_GANG_VEHICLES && FamilyVehicleInfo[f][i][fvId] != INVALID_VEHICLE_ID)
	{
		i++;
	}
	if (i == MAX_GANG_VEHICLES) return -1;
	return i;

}

stock GetGangVehicleCount(f)
{
    new
		i = 0,
		cars = 0;
	while (i < MAX_GANG_VEHICLES && FamilyVehicleInfo[f][i][fvId] != INVALID_VEHICLE_ID)
	{
	    cars++;
		i++;
	}
	return cars;

}

stock GetGangVehicle(f, vehicleid)
{
	if(f == 255) return -1;
	if(vehicleid == -1) return -1;
    for(new v = 0; v < MAX_GANG_VEHICLES; v++)
    {
        if(FamilyVehicleInfo[f][v][fvId] == vehicleid)
        {
            return v;
        }
    }
    return -1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)