[SOLVED]Createobjects and removeobject question.
#1

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.
Reply
#2

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
Reply
#3

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?
Reply
#4

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);
Reply
#5

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!
Reply
#6

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.
Reply
#7

there is no other way to destroy the object except by saving it to a variable like the pos :

new Tree; Tree = CreateObject(...)
Reply
#8

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 ?
Reply
#9

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]);
Reply
#10

the isplayerinrangeofpoint gives this error:
: error 035: argument type mismatch (argument 3)

unfortunately. but it was a nice try!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)