[Help] Destroying objects
#1

So in the past few days i've been working on some system, everything is fine, but one thing, one of these 2 codes are wrong, when i create 10 objects, and use the function to destroy em, 9 objects are destroyed but 1 can not be destroyed, i really dont know why, so please help me if you know how to.

// Creating Objects

Код:
		if(FarmerRadi[playerid] == 1 && FarmerUbacio[playerid] == 1)
		{
			if(GetVehicleModel(GetClosestVehicle(playerid)) == 531 )
			{
			    new Float:Pos[3], str[250], ajdi = ZasadioPsenice[playerid];
			    for(new id = 0; id < 10; id++)
			    {
			        GetDynamicObjectPos(FarmerObjekt[playerid][id], Pos[0], Pos[1], Pos[2]);
			        if(IsPlayerInRangeOfPoint(playerid, 7.0, Pos[0], Pos[1], Pos[2])) return 1;
			    }

				ZasadioPsenice[playerid] ++;
				GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
				FarmerObjekt[playerid][ajdi] = CreateDynamicObject(855, Pos[0], Pos[1], Pos[2], 0.00000000,0.00000000,0.00000000);
				format(str, sizeof(str), "{FFFFFF}[Plantaza Psenice]\nZasadio: {00FFEE}%s\n{FFFFFF}Preradjeno: {00FFEE}NE", ImeIgraca(playerid));
				FarmerLabel[ajdi] = CreateDynamic3DTextLabel(str, LIGHTBLUE, Pos[0], Pos[1], Pos[2], 30, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);

				if(ZasadioPsenice[playerid] == 10)
				{
				    FarmerPosejano[playerid] = 1;
					FarmerUbacio[playerid] = 0;
				}
			}
		}
// Destroying Objects

Код:
		if(!IsPlayerInAnyVehicle(playerid) && FarmerPosejano[playerid] == 1)
		{
			new Float:Pos[3], Farmer_Slot = -1;
			for(new id = 0; id < 10; id++)
			{
			    if(UsevSpusten[id] == 1)
			    {
				    GetDynamicObjectPos(FarmerObjekt[playerid][id], Pos[0], Pos[1], Pos[2]);
				    if(IsPlayerInRangeOfPoint(playerid, 2.0, Pos[0], Pos[1], Pos[2]+3))
				    {
						Farmer_Slot = id;
					}
				}
			}
			if(Farmer_Slot != -1)
			{
			    if(UzeoUsev[playerid] == 1) return SCM(playerid, TOMATO, " (greska) Vec ste pokupili jedan usev, odnesite ga u staju !");
			    SetPlayerAttachedObject(playerid, 0, 2901, 1, -0.022000, -0.212999, -0.007000, 0.000000, -2.099999, -2.599998, 0.612999, 0.439000, 0.607999, 0, 0);
			    SCM(playerid, YELLOW, " (info) Uspesno ste uzeli usev, odnesite ga u staju !");
			    UzeoUsev[playerid] = 1;
			    DestroyDynamicObject(FarmerObjekt[playerid][Farmer_Slot]);
			}
		}
	}
Reply
#2

I think that your mistake is in for.

Try to use:

pawn Код:
for(new id = 0; id < MAX_OBJECTS; id++)
Reply
#3

Well the max ammount of the object for this system is 10, so i don't really think that this is a mistake, but sure, im gonna try it.
Reply
#4

Nah, that is not the mistake, with that code you gave me it won't even create the object.
Reply
#5

Try my code only in destroy system, or if you can destroy only 9/10 object do in for "11" instead of "10" try if it works.
Reply
#6

No, again.
Reply
#7

ok, then try to be more specific and add comments on your lines, becouse i don't understand what means your variables.
Reply
#8

I think that the problem is in this

pawn Код:
if(!IsPlayerInAnyVehicle(playerid) && FarmerPosejano[playerid] == 1) // Checking on Variables
        {
            new Float:Pos[3], Farmer_Slot = -1; // Farmer_Slot is slot that will convert ID to it.
            for(new id = 0; id < 11; id++) // loop
            {
                GetDynamicObjectPos(FarmerObjekt[playerid][id], Pos[0], Pos[1], Pos[2]); // Getting the position of the object
                if(IsPlayerInRangeOfPoint(playerid, 2.0, Pos[0], Pos[1], Pos[2]+3)) // Checking if the player is in the range of the point
                {
                    Farmer_Slot = id; // Converting id to Farmer Slot
                }
            }
            if(Farmer_Slot != -1) // If farmer slot is not negative command will execute
            {
                if(UzeoUsev[playerid] == 1) return SCM(playerid, TOMATO, " (greska) Vec ste pokupili jedan usev, odnesite ga u staju !"); // If the function has already been used
                SetPlayerAttachedObject(playerid, 0, 2901, 1, -0.022000, -0.212999, -0.007000, 0.000000, -2.099999, -2.599998, 0.612999, 0.439000, 0.607999, 0, 0); // attaching object
                SCM(playerid, YELLOW, " (info) Uspesno ste uzeli usev, odnesite ga u staju !"); // Shows the message if the command is sucessfully executed
                UzeoUsev[playerid] = 1; // Sets variable to 1 for something other
                DestroyDynamicObject(FarmerObjekt[playerid][Farmer_Slot]); // Destroyin the Object
            }
        }
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)