SA-MP Forums Archive
Counters - 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)
+--- Thread: Counters (/showthread.php?tid=452853)



Counters - Mattakil - 22.07.2013

I want to make a counter, where if you say..place an object, it gives it an id of 1, then the next one gives it an id of 2 etc etc. How is this done?


AW: Counters - NaS - 22.07.2013

This is just about the counter?

Use a global variable, like "new ObjectCount = 0;" in the beginning of your script.

Then do something like:

Код:
ObjectID = ObjectCount; // Assign ObjectCount to the variable saving the ID

ObjectCount ++; // Increment ObjectCount by 1.
Or do both in one line:

Код:
ObjectID = ObjectCount ++; // Assign ObjectCount to the variable saving the ID AND Increment ObjectCount by 1 afterwards (++ behind variable name).



Re: Counters - Mattakil - 22.07.2013

well now...that makes too much sense to actually work!

thanks