View Full Version : need a little script help.

12-21-2003, 02:33 AM
I am working on a mod, but I need to limit the number of uses per day .
A small snippet of script would be nice! http://www.rtsoft.com/iB_html/non-cgi/emoticons/biggrin.gif I just need to be pointed in the right direction.

12-21-2003, 03:17 AM
This is a little involved, but doable. You should declare a global variable in init.c. That variable will be visible to all scripts. Inside of script_event.c, you need to increment that variable and if you exceed whatever limit you set, you should call another event instead. Finally, you need to reset your variable every day during maintenance, which can be done in maint.c.

So, let's make this a little more concrete.

file: init.c
// added to the end of Main()
global int G_EVENT_COUNTER = 0;

file: script_event.c
// added to Main(), remember to adjust RandomRange()

if (i_random == 3) {
if (G_EVENT_COUNTER < 5) {
} else {
LogMsg("Event called too often today.");

file: maint.c
// added to Main(), reset the global event counter

You could also inspect G_EVENT_COUNTER inside of your event and take whatever non-action you want. In my black cat event, I have some non-message for players without very high luck values.

Hope that helps and good luck&#33;

12-21-2003, 03:51 AM
Thanks.. I will use it with your permission.
I should have wrote that Iam writing for the Graveyard.
I need it to limit the uses per day , so it is not abused.

12-21-2003, 03:59 AM
Of course you can use it, Lance. The code&#39;s not tested yet. http://www.rtsoft.com/iB_html/non-cgi/emoticons/biggrin.gif

It should work. If you don&#39;t want to share your code, it least post a description of what you&#39;re working on.

12-21-2003, 04:43 AM
Russian roulette but I it is not done yet.