DestroyPlayerObject help needed.
#1

Helo ppl. Need help
I have made a command that will create an object
example
pawn Код:
new bc;
if (strcmp("/bc", cmdtext, true, 10) == 0)
{
    bc = CreatePlayerObject(playerid,1484,Float:x,Flo..........);
}
if (strcmp("/bcd", cmdtext, true, 10) == 0)
{
    DestroyPlayerObject(playerid, bc);
}
This works but the problem starts when I want to destroy objects (using cmd /bcd) that I have created (using cmd /bc)
It only destroys one of them.

How to create that it destroys all the objects that I have created (using cmd /bc)?

Thanks for help.
Reply
#2

Quote:
Originally Posted by Antonio144
Посмотреть сообщение
Helo ppl. Need help
I have made a command that will create an object
example
pawn Код:
new bc;
if (strcmp("/bc", cmdtext, true, 10) == 0)
{
    bc = CreatePlayerObject(playerid,1484,Float:x,Flo..........);
}
if (strcmp("/bcd", cmdtext, true, 10) == 0)
{
    DestroyPlayerObject(playerid, bc);
}
This works but the problem starts when I want to destroy objects (using cmd /bcd) that I have created (using cmd /bc)
It only destroys one of them.

How to create that it destroys all the objects that I have created (using cmd /bc)?

Thanks for help.
You need to store your objects in an array then. Try this:
pawn Код:
new bc[50], counter=0; //50=limit of created objects
//This was above the script
//Commands:
if (strcmp("/bc", cmdtext, true, 10) == 0)
{
    if(counter<50){
    bc[counter] = CreatePlayerObject(playerid,1484,Float:x,Flo..........);
    counter++
    }
    else{
    SendClientMessage(plaerid, COLOR_RED, "Object limit reach, please destroy your objects");
    }
}
The /destroy command should be a loop, if you wanna destroy all objects by one.
If not, just destroy the recent object and make counter--;
If the objects of other players should be handled differently, you would need to make 'bc' a PVar or a 2-dimensional array.

I hope I could help you so far.
Reply
#3

I'm still new to the pawn scripting so I haven't met with loops yet, if you can explain further I would be grateful.
this is the par of the code I need help with http://pastebin.com/zkfFf0EW

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)