[SOLVED]Createobjects and removeobject question. -
Faith - 11.05.2010
I'm starting to make the impossible.. for me.
Atleast i hope that i could get a little help with this one.
I've made a command to /planttree.
I've implemented a timer and it works great.
Here comes my question.
First, i'm gonna make the tree created at the players position. I think i have an idea of how to do that.
public PlantedTree
{
Createobject at playerposition?
}
Second, i'm going to make a /cuttree
But the person has to be near the tree to cut it, and then the tree gets destroyed.
Do you have any idea of how i can do that?
The problem that i so far noticed that, if i give the object a name, Etc FinishedTree = CreateObject, and i be nearby FinishedTree and do DestroyObject, then all the trees gets removes and not the one nearby.
Help greatly appreciated.
Re: Createobjects and removeobject question. -
aircombat - 11.05.2010
new Float:X; new Float:Y; new Float:Z; GetPlayerPos(playerid,X,Y,Z);
CreateObject(objectid,X,Y,Z,etc...);
that will create the object in current player position
Re: Createobjects and removeobject question. -
Faith - 11.05.2010
So far so good.
That was also kind of what i had in my mind
But thanks ;P
Now, how do i remove the closest object, and not all objects when i do /cuttree?
Re: Createobjects and removeobject question. -
aircombat - 11.05.2010
new Tree; new Float:X; new Float:Y; new Float:Z; GetPlayerPos(playerid,X,Y,Z);
Tree = CreateObject(objectid,,X,Y,Z,etc..);
Код:
DestroyObject(Tree);
Re: Createobjects and removeobject question. -
Faith - 11.05.2010
yesyes :P
But then when i /cuttree, it will remove ALL trees on the whole server.
How can i cut the one i am nearby? That's the question!
Re: Createobjects and removeobject question. -
Las Venturas CNR - 11.05.2010
Quote:
Originally Posted by Faith
yesyes :P
But then when i /cuttree, it will remove ALL trees on the whole server.
How can i cut the one i am nearby? That's the question! 
|
Just sorta remember the varyable or whatever and under the command, use DestroyObject.
EDIT: I didn't read correctly.
Re: Createobjects and removeobject question. -
aircombat - 12.05.2010
there is no other way to destroy the object except by saving it to a variable like the pos :
new Tree; Tree = CreateObject(...)
Re: Createobjects and removeobject question. -
Faith - 12.05.2010
Damn..
But isn't it possible to make it something like this:
Tree = CreateObject.
and then if Tree is already made, then make Tree1, Tree2, Tree3 etc ?
Re: Createobjects and removeobject question. -
Zimon95 - 12.05.2010
Not sure but, try with this code...
pawn Код:
new Tree[MAX_PLAYERS],Float:TreeX[MAX_PLAYERS],Float:TreeY[MAX_PLAYERS],Float:TreeZ[MAX_PLAYERS];
//In the commands..
new float:x,y,z;
GetPlayerPos(playerid,x,y,z);
Tree[playerid] = CreateObject(model,x,y,z,...);
TreeX[playerid] = x;
TreeY[playerid] = y;
TreeZ[playerid] = z;
if(IsPlayerInRangeOfPoint(playerid,10.0,TreeX,TreeY,TreeZ)) DestroyObject(Tree[playerid]);
Re: Createobjects and removeobject question. -
Faith - 12.05.2010
the isplayerinrangeofpoint gives this error:
: error 035: argument type mismatch (argument 3)
unfortunately. but it was a nice try!