Raised This Month: $32 Target: $400
 8% 

Waiting without creating timers?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dragonshadow
BANNED
Join Date: Jun 2008
Old 07-19-2009 , 16:29   Waiting without creating timers?
Reply With Quote #1

Is there a way to "wait" without creating a timer?

I wish there was a such thing as
PHP Code:

wait
(seconds)
//like
wait(1.0)
//or
wait(3.7)
//or
wait(500.0
Dragonshadow is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 07-19-2009 , 16:50   Re: Waiting without creating timers?
Reply With Quote #2

Quote:
Originally Posted by Dragonshadow View Post
Is there a way to "wait" without creating a timer?

I wish there was a such thing as
PHP Code:
 
wait
(seconds)
//like
wait(1.0)
//or
wait(3.7)
//or
wait(500.0
I havent seen any thing but i would think timer is most efficient
Doc-Holiday is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 07-19-2009 , 17:11   Re: Waiting without creating timers?
Reply With Quote #3

No, there isn't.
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
Dragonshadow
BANNED
Join Date: Jun 2008
Old 07-19-2009 , 19:35   Re: Waiting without creating timers?
Reply With Quote #4

The problem I have with timers is that the uhh.. (new something = whatevver) don't go with it, so I can't , say,

PHP Code:

{
    new 
random GetRandomInt(120)
    
//stufffffffs
    
CreateTimer(5.0whateveractionclient)
}

public 
Action:whateveraction(timerstuffgoeshere)
{
    
printtochatall("The number is %i"random)

I think I could use globals but ehhhhh.
Dragonshadow is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 07-19-2009 , 20:00   Re: Waiting without creating timers?
Reply With Quote #5

If you need to pass multiple variable through timer use datapacks
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Dragonshadow
BANNED
Join Date: Jun 2008
Old 07-19-2009 , 20:06   Re: Waiting without creating timers?
Reply With Quote #6

Quote:
Originally Posted by teame06 View Post
If you need to pass multiple variable through timer use datapacks
I have no idea what those are nor how to use them.
Dragonshadow is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 07-19-2009 , 20:57   Re: Waiting without creating timers?
Reply With Quote #7

They are pretty straight forwards. Look at this example:
PHP Code:
public Action:someFunction()
{
...
        new 
Handle:dp// Create a new handle for our datapack (dp)
        
CreateDataTimer(10.0Timer_MyDataPackTimerdp); // Same as CreateTimer just your 3rd argument is the datapack
        
WritePackCell(dpClient); // Write your values to the dp, makes sure you write them in a suitable order as you have to read them in the same order (see below)
        
WritePackString(dp"A string");
}

public 
Action:Timer_MyDataPackTimer(Handle:timerHandle:dp)
{
     if (
dp == INVALID_HANDLE)
     {
         
// Oh no, we have a problem
     
}

    new 
String:buffer[64];

    
ResetPack(dp); // First reset the data pack
    
new Client ReadPackCell(dp); // Then you can read the dp, you must read it in the exact same order that you packed it.
    
ReadPackString(dpbuffersizeof(buffer));        
    
    
// Do stuff

Wazz is offline
Dragonshadow
BANNED
Join Date: Jun 2008
Old 07-19-2009 , 21:06   Re: Waiting without creating timers?
Reply With Quote #8

Can you only have one string, etc, per datapack or is that why you have to read them in the exact same order?
Dragonshadow is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-19-2009 , 22:27   Re: Waiting without creating timers?
Reply With Quote #9

You can have as many of anything as you want in the datapack.
bl4nk is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-20-2009 , 02:24   Re: Waiting without creating timers?
Reply With Quote #10

In Wazz's example I think it would be better practice to write to the datapack before sending the timer, although it works either way.

I do agree though, timers are a lot of work. They can be difficult to maintain if you are inexperienced. I wish there was an easier way, but for Source Pawn I don't think there are any simpler solutions.
__________________
Greyscale is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode