Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Andrea Rovenski

Timer?

Recommended Posts

#include "zcommon.acs"

int Counter[7]=0;

Script 1 ENTER
{
Thing_ChangeTID(0, 1000 + PlayerNumber());

while(getactorproperty(1000 + PlayerNumber(), APROP_Health) > 0)
{
Counter[PlayerNumber()]++;
delay(35);
hudmessage (d:Counter[PlayerNumber()]; HUDMSG_PLAIN, 0, CR_RED, 0.0, 0.0, 1.0);
}
}

Should work.

Share this post


Link to post

int Counter[7]= {0, 0, 0, 0, 0, 0, 0};


But why 7? ZDoom supports up to 8 players; and Skulltag up to 32.(Or was it 64?)

Share this post


Link to post

oops.

int Counter[7] = { 0 };

Should work.

ya in counter[7] there are actually 8 values because 0 counts as a slot.
counter[0] - counter[7]

Share this post


Link to post

Nope, when you initialize an array, the value you use means exactly how many 'slots' or elements or indexes (or whatever you want to call it) it will have, and instead when you access the slots its 0-based, so you need to use a value that is one smaller than the nth-slot you want to access.

So with int Counter[7]; you would only be able to access slots [0] to [6].

You should use a value like int Counter[64]; at least to play it safe for ports with bigger player limits.

Also no need to initialize the array to zeros, ZDoom at least treats uninitialized variables as 0 I think.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×