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
timer

 
Post new topic   Reply to topic Printable version
 View previous topic  i need to link what where? (no binaries) Post :: Post PlayerData  View next topic  
Author Message
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Fri Jul 13, 2007 7:48 pm    Post subject: timer Reply to topic Reply with quote

I was wondering about a timer required in a module i'm creating. In order to make this easier though, i thought i might ask, how long does it take for the "packets"(i don't know if this is right but i think so) to give player location? in the halo_hill module, i don't see a timer, i just see a

Code: Show/Hide
if(true) --seconds remaning


sorda thing(that's not the exact code). if smong could respond to how he did his hill timer that would be great.

My goal:for every second a person is in a location, turn on another image.

My question:how do you find out how long a person is in a location.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Fri Jul 13, 2007 9:53 pm    Post subject: Reply to topic Reply with quote

I've found a way, i just don't know what the call back is for when someone is IN the zone. not entering. this is not what i want at all.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sat Jul 14, 2007 4:27 am    Post subject: Reply to topic Reply with quote

tcsoccerman wrote:
I've found a way, i just don't know what the call back is for when someone is IN the zone. not entering. this is not what i want at all.


I never coded for ASSS, but:

If someone enters the zone, he/she is in there until leaving it!?
_________________
It's a shark! Oh my god! Unbelievable!
Back to top
View users profile Send private message Add User to Ignore List
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Sat Jul 14, 2007 11:01 am    Post subject: Reply to topic Reply with quote

Lol, sorry. i meant region, not zone.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:37
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Sat Jul 14, 2007 2:58 pm    Post subject: Reply to topic Reply with quote

I'm pretty sure for that, you'll have to use ASSS Regions. Make the "hill" a region, and use the region callback to see when people enter. Just interrupt the timer if if the player ever leaves the region. You could record their position every second or something, and check to see if it was within a certain boundary, but... I'm sure regions are much easier. Only problem I would see is if regions happen to take a while to respond(if I remember right it does take a second or so).
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Sat Jul 14, 2007 3:53 pm    Post subject: Reply to topic Reply with quote

How many pixels are in a tile?16?24?
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:37
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Sat Jul 14, 2007 3:56 pm    Post subject: Reply to topic Reply with quote

Hm... I always thought it was seven. But I'm probably thinking this because a standard ship's radius is 14, which is big enough to be blocked by a single tile gap, but it fits in a 2 tile gap.

Edit: I found this in the wiki: http://wiki.minegoboom.com/index.php/Tiles which says tiles are 16x16. I confused radius and diameter, which is why my last statement doesn't make sens. >_<
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Sat Jul 14, 2007 5:33 pm    Post subject: Reply to topic Reply with quote

I figured that out w/ dcme. Now all i need is coding that pauses the current process for x seconds(preferabbly small and precise), and then resumes the process after x secnods have passed. know how? C language.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sat Jul 14, 2007 5:55 pm    Post subject: Reply to topic Reply with quote

sleep
and
usleep
Back to top
View users profile Send private message Add User to Ignore List
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Sat Jul 14, 2007 6:05 pm    Post subject: Reply to topic Reply with quote

Example?
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Sat Jul 14, 2007 6:28 pm    Post subject: Reply to topic Reply with quote

You don't want to use sleep in a module, you could end up freezing the entire server.

Also I doubt you want to use regions if this is for a hill that can move around. If all you can get is enter/exit events just follow k's advice and stop/pause the timer as soon as you get an exit event.

What I did in the original halo_hill module was set an asss timer to trigger on every second. Then inside this timer I checked all the player positions to see if they were inside the hill or not. If one team had more players inside than the other than I decremented that team's timer by 1.

Now about your goal, did you want like a meter than increases the longer you stay in the area? And then this meter resets as soon as you leave it?

Or did you want to display how many players each team currently has inside the hill?
_________________
ss news
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Sat Jul 14, 2007 6:43 pm    Post subject: Reply to topic Reply with quote

Ok, i see. i do want to use regions because the hills don't move. What area of code did you trigger the timer every second?I want the idea of a meter that increases every second in the hill, but doesn't reset when you leave it.once they are in the hill for long enough, that players team owns the hill.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Sat Jul 14, 2007 6:51 pm    Post subject: Reply to topic Reply with quote

I see it now in mainloop.h . What do the keys and stuff represent? What should i set them to if i want something similiar to you're hill module to occur, every second.

It would be most useful if it waits for 1 second, then continues. The purpose of this coding is to put a second b/w the meter gfx so the meter doesn't fill up in a instant, but instead takes a while.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:37
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Sat Jul 14, 2007 11:55 pm    Post subject: Reply to topic Reply with quote

Unfortunately there isn't really a way to just pause your module, you have to use timers. :| It WOULD be nice to have a way to delay a module for a few seconds, and it might even be possible to write a Pause() function that took a number of seconds in as a parameter. I might try that some time, but I keep forgetting how timers work.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sun Jul 15, 2007 6:50 am    Post subject: Reply to topic Reply with quote

The problem with that is that while the module is in the Pause() function the module is unable to handle any other events that might occur.
And if you use a timer with a callback you're not able to jump back to where you called Pause().

You could start a different thread that does whatever you want and where it is safe to sleep in, though.
The manpage of sleep and usleep say that sleep suspends a process, however I remember using sleep in a threaded program without a problem.
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Sun Jul 15, 2007 6:57 am    Post subject: Reply to topic Reply with quote

The key in SetTimer is so you can cancel a specific timer. You might want to do this when the module detaches, to clean up neatly. In this case setting the key to be the arena is a good idea. You don't have to use a key if you don't need to, but if your module detaches/unloads and any running timers are not stopped could crash the server.

To make the timer get called ever second set the interval to 100 ticks. The initial delay can be anything small, maybe 500 if you are calling it in MM_ATTACH or set it to 0 if the game starts on command.

You'll want to set the "param" parameter to the arena, so you can access the arena data inside the timer.

Also don't forget to make the timer return 1 so it repeats.

Code: Show/Hide
local int timer(void *arena_)
{
   Arena *arena = arena_;
   struct adata *ad = P_ARENA_DATA(arena, adkey);

   //count players here, etc

   return 1;
}

EXPORT int MM_halo_hill(int action, Imodman *mm_, Arena *arena)
{
...
   else if (action == MM_ATTACH)
   {
      ml->SetTimer(timer, 500, 100, arena, arena);
   }
   else if (action == MM_DETACH)
   {
      ml->ClearTimer(timer, arena);
   }
Back to top
View users profile Send private message Add User to Ignore List Visit posters website 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: Sun Jul 15, 2007 10:39 am    Post subject: Reply to topic Reply with quote

Smong wrote:
The key in SetTimer is so you can cancel a specific timer. You might want to do this when the module detaches, to clean up neatly. In this case setting the key to be the arena is a good idea. You don't have to use a key if you don't need to, but if your module detaches/unloads and any running timers are not stopped could crash the server.


You can use use ml->ClearTimer(timer, NULL) to clear without keys.
_________________
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
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: 202 page(s) served in previous 5 minutes.

phpBB Created this page in 0.479031 seconds : 41 queries executed (91.5%): GZIP compression disabled