DestroyPlayerObject help needed. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: DestroyPlayerObject help needed. (
/showthread.php?tid=251751)
DestroyPlayerObject help needed. -
Antonio144 - 28.04.2011
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.
Re: DestroyPlayerObject help needed. -
DeathOnaStick - 28.04.2011
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.
Re: DestroyPlayerObject help needed. -
Antonio144 - 28.04.2011
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!