Destroying a certain object
#10

instead assigning multiple plantids to each playerid[][], why not assign ONE playerid to any planted seed?
instead of:
Code:
PlantID[playerid][0]=CreateObject(blabla..
...with the issue of multiple plants (those [0], [1] etc in the player-plant array), you can do this:
Code:
new PlantID=CreateObject(blabla..
PlantedByPlayerID[PlantID]=playerid;
pay attention to the new PlantID, the "new" is there for a reason. the (returned) PlantID is only required once: as pointer into the PlantedByPlayerID cell.
doing it this way, you dont need to worry about checking if a player plant [0], [1], [2], (or more plant-slots) are free for planting.
the only little downside is the requirement for a sort-of-big array for holding like 10000 playerid's, pointed by each single plant.
to avoid the need for checking 10000 plants to find the closest plant to a player, you can spawn a pickup below each plant, and store the PlantID (same as the returned value above) into the pickup array the same way.

if you're done, your plant script can:
-handle (almost) unlimited amount of plants (per player too, since they all share the same plants array),
-avoid loops and timers. no closest plant-check, no counting for free plantslots etc.

trading a few KBytes RAM (10000 plant-integer-object-ids plus the same for invisible pickups linking to the plants) for using no loops&timers at all, seems to be a good deal. the more plants you intent to use, the more speedup advantages over other plant scripts you'll notice. for free.
Reply


Messages In This Thread
Destroying a certain object - by dusk - 16.02.2013, 11:16
Re: Destroying a certain object - by DaRk_RaiN - 16.02.2013, 11:21
Re: Destroying a certain object - by dusk - 16.02.2013, 11:22
Re: Destroying a certain object - by DaRk_RaiN - 16.02.2013, 11:25
Re: Destroying a certain object - by dusk - 16.02.2013, 11:59
Re: Destroying a certain object - by DaRk_RaiN - 16.02.2013, 12:02
Re: Destroying a certain object - by dusk - 16.02.2013, 12:16
Re: Destroying a certain object - by DaRk_RaiN - 16.02.2013, 12:18
Re: Destroying a certain object - by dusk - 16.02.2013, 12:33
Re: Destroying a certain object - by Babul - 16.02.2013, 13:11

Forum Jump:


Users browsing this thread: 1 Guest(s)