Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Time

 
Post new topic   Reply to topic Printable version
 View previous topic  Vista & compiling Post :: Post Fake player positions  View next topic  
Author Message
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Thu Jul 10, 2008 1:42 pm    Post subject: Time Reply to topic Reply with quote

Alright, so I'm not too familiar with how to work time in ASSS. Basically, what I want to do, is start a timer (not a countdown one) when a race begins, then display the time once Player X enters a region (i.e. finish line or checkpoint) and then stop the timer.

To put this into context, I want to implement this into a simple race module which has already been outlined, I would just like to know how to create a timer that would display a player's result.
Back to top
View users profile Send private message Add User to Ignore List Send email
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Jul 11, 2008 10:31 am    Post subject: Reply to topic Reply with quote

you don't need to start a timer, just record the time when the race begins, record the time when the player enters the finish line region and subtract.

there's an enter region callback, although you'll want to tweak with the settings to make it check on every position packet instead of every second (probably better off making the finish line a safe zone so the client will send a packet as soon as he enters)
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Fri Jul 11, 2008 12:17 pm    Post subject: Reply to topic Reply with quote

Ok, then how do I record the time when the race begins and ends?
Back to top
View users profile Send private message Add User to Ignore List Send email
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sat Jul 12, 2008 12:06 am    Post subject: Reply to topic Reply with quote

just like you would in any other program: GetTickCount on windows gettimeofday on linux
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sat Jul 12, 2008 11:19 am    Post subject: Reply to topic Reply with quote

No, use ASSS's current_ticks(). It's in util.h.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sat Jul 12, 2008 11:22 am    Post subject: Reply to topic Reply with quote

Bak wrote:
(probably better off making the finish line a safe zone so the client will send a packet as soon as he enters)


By the way, that's not exactly what happens. All it means is the next packet will be reliable, not that it's send immediately. I used to use safe zones for all the warps in hyperspace but found that I didn't get any better results than not using safeties, for that reason.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
D1st0rt
Miss Directed Wannabe


Age:37
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Sat Jul 12, 2008 12:05 pm    Post subject: Reply to topic Reply with quote

Here's the relevant portion from the (albeit old, I might not do it the same way if I was writing it now but it works) Hyperspace Racing module:
Code: Show/Hide
local void posUpdate(Player *p, byte *data, int len)

{

   race_pdata *rpd;

   struct C2SPosition *pos = (struct C2SPosition *)data;

   race_adata *ad = P_ARENA_DATA(p->arena, adkey);

   rpd = PPDATA(p, pdkey);



   if (p->arena == NULL)

      return;



   if (ad->status <= READY)

      return;



   if (rpd->status == PRE_CHECKPOINT)

   {

      if(checkPos(CHECKPOINT, pos->x >> 4, pos->y >> 4))

      {

         long dT = current_millis() - ad->startTime;

         checkPoint(p, dT);

      }

   }

   else if (rpd->status == POST_CHECKPOINT)

   {

      if(checkPos(FINISH, pos->x >> 4, pos->y >> 4))

      {

         long dT = current_millis() - ad->startTime;

         addFinish(p, dT);

      }

   }

}



local int checkPos(int loc,int x, int y)

{

   switch(loc)

   {

      case CHECKPOINT:

         return (abs(x - 506) < 20) && y > 655;

      break;

      case FINISH:

         return (abs(x - 506) < 20) && y < 361;

      break;

   }

   return 0;

}


where PosUpdate is the callback from Net->AddPacket
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sat Jul 12, 2008 2:25 pm    Post subject: Reply to topic Reply with quote

all current_ticks does is call GetTickCount or gettimeofday... cut out the middle man
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sat Jul 12, 2008 4:00 pm    Post subject: Reply to topic Reply with quote

Bak wrote:
all current_ticks does is call GetTickCount or gettimeofday... cut out the middle man


And make the code harder to port? Why bother? The efficiency of one function call isn't relevant, and current_ticks() has the added advantage of being the compatible with all the position packet times.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 106 page(s) served in previous 5 minutes.

phpBB Created this page in 0.426222 seconds : 33 queries executed (93.2%): GZIP compression disabled