Doesn't clean objects
#1

new obect;

I use in a command:
Код:
if(strcmp(cmd, "/com", true) == 0)
{
obect = CreateObject(18690, 280.996704, 1876.698120, 14.849337, 90.2407954, -2.57831008, 1.71887339); 
obect = CreateObject(18690, -2794.0922851563, -12.043877601624, 9.0996828079224, 0, 0, 270.67565917969); 
obect = CreateObject(18690, -2793.998046875, -13.272877693176, 9.0931529998779, 0, 0, 270.67565917969); 
obect = CreateObject(18690, -2793.4816894531, -15.914033889771, 6.9843993186951, 0, 0, 272.66064453125); 
obect = CreateObject(18690, -2794.2727050781, -17.160186767578, 9.304069519043, 0, 0, 270.67565917969); 
obect = CreateObject(18690, -2792.0141601563, -17.860973358154, 6.7548785209656, 0, 0, 270.67565917969);
return 1;
}
Command for removal of objects:
Код:
if(strcmp(cmd, "/deletecom", true) == 0)
{
DestroyObject(obect);
return 1;
}
Deletes only one object
How to make that deleted all objects?
Reply
#2

If you assign the last object to "object", the previous objects will no loger be controlled by using the "object" var.
You will have to set a different name for each object, instead of making 6 objects under the same name.
Reply
#3

how to make so not to set for each object a name?
Reply
#4

you have to go like

pawn Код:
new obect1;
new obect2;
new obect3;
new obect4;
new obect5;
new obect6;
pawn Код:
if(strcmp(cmd, "/com", true) == 0)
{
obect1 = CreateObject(18690, 280.996704, 1876.698120, 14.849337, 90.2407954, -2.57831008, 1.71887339);
obect2 = CreateObject(18690, -2794.0922851563, -12.043877601624, 9.0996828079224, 0, 0, 270.67565917969);
obect3 = CreateObject(18690, -2793.998046875, -13.272877693176, 9.0931529998779, 0, 0, 270.67565917969);
obect4 = CreateObject(18690, -2793.4816894531, -15.914033889771, 6.9843993186951, 0, 0, 272.66064453125);
obect5 = CreateObject(18690, -2794.2727050781, -17.160186767578, 9.304069519043, 0, 0, 270.67565917969);
obect6 = CreateObject(18690, -2792.0141601563, -17.860973358154, 6.7548785209656, 0, 0, 270.67565917969);
return 1;
}
pawn Код:
if(strcmp(cmd, "/deletecom", true) == 0)
{
DestroyObject(obect1);
DestroyObject(obect2);
DestroyObject(obect3);
DestroyObject(obect4);
DestroyObject(obect5);
DestroyObject(obect6);
return 1;
}
Reply
#5

Quote:
Originally Posted by Roma555
Посмотреть сообщение
how to make so not to set for each object a name?
Well you have to, unless you use a loop whitch automaticly creats the name for each object.
You can also create some objects without assigning them to a var, but you won't be able to delete them later.
Reply
#6

pawn Код:
new Objs[6];

Objs[0] = Createobj...
Objs[1] = Createobj...
....
Objs[6] = Createobj...


When deleting them:
for(new i = 0; i < 6; i++)
{
    DestroyObject(Objs[i]);
}
Reply
#7

Used in a command:

Код:
for(new i = 0; i < 18; i++)
{
DestroyObject(Objs[i]);
}
Gives errors^
(463 : error 017: undefined symbol "Objs"
(463 : warning 215: expression has no effect
(463 : error 001: expected token: ";", but found "]"
(463 : error 029: invalid expression, assumed zero
(463 : fatal error 107: too many error messages on one line
Reply
#8

You have to rename all of your objects' names. Do not copy-paste the givven function, try to understand what he did there, and remake it for your own goods.
Reply
#9

Here is how has made:
Код:
new Objs[9];
Objs[0] = CreateObject(18690, 280.996704, 1876.698120, 14.849337, 90.2407954, -2.57831008, 1.71887339);
Objs[1] = CreateObject(18690, -2794.0922851563, -12.043877601624, 9.0996828079224, 0, 0, 270.67565917969);
Objs[2] = CreateObject(18690, -2793.998046875, -13.272877693176, 9.0931529998779, 0, 0, 270.67565917969);
Objs[3] = CreateObject(18690, -2793.4816894531, -15.914033889771, 6.9843993186951, 0, 0, 272.66064453125);
Objs[4] = CreateObject(18690, -2794.2727050781, -17.160186767578, 9.304069519043, 0, 0, 270.67565917969);
Objs[5] = CreateObject(18690, -2792.0141601563, -17.860973358154, 6.7548785209656, 0, 0, 270.67565917969);
Objs[6] = CreateObject(18690, -2794.1572265625, -12.692586898804, 12.16376209259, 0, 0, 270.67565917969);
Objs[7] = CreateObject(18690, -2794.1821289063, -17.23037147522, 12.207744598389, 0, 0, 270.67565917969);
Objs[8] = CreateObject(18690, -2781.8154296875, -12.107675552368, 6.7634339332581, 0, 0,
Код:
if(strcmp(cmd, "/delete", true) == 0)
{

for(new i = 0; i < 9; i++)
{
DestroyObject(Objs[i]);
} 
return 1;
}
Here on this line gives an error:
DestroyObject(Objs[i]);
Reply
#10

All has understood.
Thanks for the help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)