Jump to content

Noob, function help please


Recommended Posts

Hi,

I'm making a wee script to automate some basic commands for my gaming server, I'd like to send the game some commands at time intervales (every 1 minute or every 1o minutes etc)

I'm new to Auto It script writing, so not sure what I need to do. I have 3 Functions that get called by the AdlibEnable, but only the last on runs see my test (see code below)

How do I get all 3 Functions to run in the same script?

AdlibEnable("NetDelay", 60000)
AdlibEnable("PuntCRC", 65000)
AdlibEnable("Promote", 70000)

While 1
;wait
WEnd

Func NetDelay()
    Send("`netdelay 0{ENTER}")
EndFunc

Func PuntCRC()
    Send("`")
    Sleep(1000)
    Send("puntcrc")
    Sleep(1000)
    Send("{ENTER}")
EndFunc

Func Promote()
    Send("`")
    Sleep(1000)
    Send("talk")
    Sleep(1000)
    Send("{ENTER}")
    Sleep(1000)
    Send("Download this map from: http://www.killingfields.net")
    Send("{ENTER}")
EndFunc

My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Link to comment
Share on other sites

Welcome to the forums!

AdLibEnable() will only ever run one function at a specified interval. The following code will do what you set out to do with yours:

Local $NetDelayTimer = TimerInit()
Local $PuntCRCTimer = TimerInit()
Local $PromoteTimer = TimerInit()

While 1

    If TimerDiff($NetDelayTimer) > 60000 Then
        $NetDelayTimer = TimerInit()
        Send('`netdelay 0{ENTER}')
    EndIf
    If TimerDiff($PuntCRCTimer) > 65000 Then
        $PuntCRCTimer = TimerInit()
        Send('`')
        Sleep(1000)
        Send('puntcrc')
        Sleep(1000)
    EndIf
    If TimerDiff($PromoteTimer) > 70000 Then
        $PromoteTimer = TimerInit()
        Send('`')
        Sleep(1000)
        Send('talk')
        Sleep(1000)
        Send('{ENTER}')
        Sleep(1000)
        Send('Download this map from: http://www.killingfields.net{ENTER}')
    EndIf
; Briefly pause to avoid excessive CPU usage
    Sleep(1000)

WEnd
Link to comment
Share on other sites

Thanks LxP!

That does the trick perfectly.

Next is error testing to make sure they don't try to run while the game is in the process of switching maps. I'll proberly be back... :">

My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...