Jump to content

help...


Recommended Posts

I am finishing up my game and i ran into a problem

This is what my script Looks like

CODE

Func _Game

Opt("GUIOnEventMode", 1)

$Level = 1

sound()

$Form1 = GUICreate("Shoot the President", 678, 586, 218, 117)

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Ammo")

$Health = GUICtrlCreateProgress(144, 552, 513, 25)

GUICtrlSetData($Health, 100)

$dsgg = GUICtrlCreateLabel("President Health", 0, 552, 142, 28)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$Input = GUICtrlCreateInput("Cheat Box", 8, 495)

$Label2 = GUICtrlCreateLabel("Timer", 8, 520, 53, 28)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$Time = GUICtrlCreateLabel("480", 72, 520, 34, 28)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0xFF0000)

$Label4 = GUICtrlCreateLabel("Seconds", 120, 520, 79, 28)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$bush = GUICtrlCreatePic("Bush.jpg", 162, 135, 67, 77, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))

GUICtrlSetCursor(-1, 3)

$1 = GUICtrlCreatePic("hijacker.jpg", 162, 135, 67, 77, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))

GUICtrlSetCursor(-1, 3)

GUICtrlSetOnEvent($bush, "shoot")

GUICtrlSetOnEvent($1, "mg")

GUISetState(@SW_SHOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "quit")

$timesound = 0

AdlibEnable("Timer", 1000)

While $Level = 1

GUICtrlSetPos($bush, Random(1, 600, 1), Random(1, 500, 1))

GUICtrlSetPos($1, Random(1, 600, 1), Random(1, 500, 1))

Sleep(750)

If GUICtrlRead($Time) <= 0 Then

MsgBox(0, "HAHa!", "Out Of Time!")

mg2()

EndIf

If GUICtrlRead($Health) <= 0 Then

MsgBox(0, "Congratz!", "You killed the Pres. Next Level")

SoundPlay("Wingame.wav", 1)

$Level = $Level + .5

ExitLoop

EndIf

If GUICtrlRead($Input) = "automaticwinhehehe" Then

GUICtrlSetData($Health, 0)

EndIf

If GUICtrlRead($Input) = "unlimitedtimeplease" Then

GUICtrlSetData($Time, 480)

EndIf

If GUICtrlRead($Input) = "pleasegotolevel4" Then

$Level = 3.5

EndIf

If GUICtrlRead($Input) = "pleasegotolevel7" Then

$Level = 6.5

EndIf

WEnd

EndFunc

Func Timer()

GUICtrlSetData($Time, GUICtrlRead($Time) - 1)

$timesound = $timesound + 1

If $timesound = 60 Then

sound()

EndIf

EndFunc ;==>Timer

Now for the problem.. whenever i play it says that i am not using an undefined varible ($Time) Why does it say that?? Any Suggestions??

code
Link to comment
Share on other sites

I am finishing up my game and i ran into a problem

Now for the problem.. whenever i play it says that i am not using an undefined varible ($Time) Why does it say that?? Any Suggestions??

If you declare a variable inside a Function, it is Local in scope by default. Declare $Time as Global at the top of your script if you need it to persist outside of a single function.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

If you declare a variable inside a Function, it is Local in scope by default. Declare $Time as Global at the top of your script if you need it to persist outside of a single function.

:)

Ok thank you...

Edit: Never mind i found out lol

Thank you again

Edited by Nooblet
code
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...