Jump to content

Adding to variables together. Is it possible?


RawrOmg
 Share

Recommended Posts

$firstvar = "+sv_gamemode"
$secondvar = inputbox("Enter gamemode below", "Enter gamemode below)

$gamemode = $firstvar $secondvar

so if I typed in Deathmatch it would come out as

"+sv_gamemode Deathmatch"

The only problem is it doesnt, It just replaces Deathmatch with "0"

What am I doing wrong?

Edited by RawrOmg
Link to comment
Share on other sites

$firstvar = "+sv_gamemode"
$secondvar = inputbox("Enter gamemode below", "Enter gamemode below)

$gamemode = $firstvar $secondvar

so if I typed in Deathmatch it would come out as

"+sv_gamemode Deathmatch"

The only problem is it doesnt, It just replaces Deathmatch with "0"

What am I doing wrong?

$firstvar = "+sv_gamemode"
$secondvar = inputbox("Enter gamemode below","Enter Gamemode below")
$whatyouwant = $firstvar & " " & $secondvar
ConsoleWrite($whatyouwant)

It's called concatenation.

Link to comment
Share on other sites

Im having another problem now, when I combine all the stuff together it just prints random numbers instead of the input.

+map 6 +maxplayers 7 +sv_gamemode 5 +sv_defaultgamemode 5 +rcon_password 9 -port 8 -hostname 4

like that instead of it saying something like +Map MAPNAMEHERE

Func button1()
    #cs------------------------------------------------------------------------------------------------
    Diggity Diggity Dawg Fo sho, Here comes adding all the variables together and running the sheeeettt
    #ce------------------------------------------------------------------------------------------------
    $Mapvar = $map & " " & $input3
    $Maxplayersvar = $maxplayers & " " & $input4
    $gamemodevar = $gamemode & " " & $input2
    $gamemodedefaultvar = $gamemodedefault & " " & $input2
    $rconpasswordvar = $rconpassword & " " & $input6
    $portvar = $port & " " & $input5
    $hostnamevar = $name & " " & $input1
    #cs------------------------------------------------------------------------------------------------------
    Adding Together complete, now lets rap it up by writing all these into one line and running srcds.Execute
    #ce------------------------------------------------------------------------------------------------------
    
    $commands = $mapvar & " " & $maxplayersvar & " " & $gamemodevar & " " & $gamemodedefaultvar & " " & $rconpasswordvar & " " & $portvar & " " & $hostnamevar
    msgbox(0, "test", $commands)
EndFunc

Thats where all the combining is happening and this is the entire script

GuiCreate("Home",344,239,978,305)
#cs------------------------
Teh Commands Dawwg
#ce------------------------
$game = "-game garrysmod"
$map = "+map"
$maxplayers = "+maxplayers"
$gamemode = "+sv_gamemode"
$gamemodedefault = "+sv_defaultgamemode"
$rconpassword = "+rcon_password"
$port = "-port"
$name = "-hostname"
#cs--------------------------------------------------------
Teh Commands are Over Foo, Here comes the GUI Maan
#ce--------------------------------------------------------
$button1=GuiCtrlCreateButton("Start Server",10,179,325,60)
$input1=GuiCtrlCreateInput("Server Name",4,12,27,20)
$input2=GuiCtrlCreateInput("Game mode",4,36,-177,20)
$input3=GuiCtrlCreateInput("Map",4,61,238,20)
$input4=GuiCtrlCreateInput("Max Players",4,85,27,20)
$input5=GuiCtrlCreateInput("UDP Port",4,126,27,20)
$input6=GuiCtrlCreateInput("Rcon Password",7,152,126,20)
$label1=GuiCtrlCreateLabel("Most Commonly 27015 or 27017",5,108,190,15)
GuiSetState()
#cs---------------------------------------------------------
Gui Over, here comes shit I dont understand, Plus the button
#ce---------------------------------------------------------
While 1
$msg=GuiGetMsg()
If $msg=-3 Then Exit
If $msg=$button1 Then button1()
Wend




Func button1()
    #cs------------------------------------------------------------------------------------------------
    Diggity Diggity Dawg Fo sho, Here comes adding all the variables together and running the sheeeettt
    #ce------------------------------------------------------------------------------------------------
    $Mapvar = $map & " " & $input3
    $Maxplayersvar = $maxplayers & " " & $input4
    $gamemodevar = $gamemode & " " & $input2
    $gamemodedefaultvar = $gamemodedefault & " " & $input2
    $rconpasswordvar = $rconpassword & " " & $input6
    $portvar = $port & " " & $input5
    $hostnamevar = $name & " " & $input1
    #cs------------------------------------------------------------------------------------------------------
    Adding Together complete, now lets rap it up by writing all these into one line and running srcds.Execute
    #ce------------------------------------------------------------------------------------------------------
    
    $commands = $mapvar & " " & $maxplayersvar & " " & $gamemodevar & " " & $gamemodedefaultvar & " " & $rconpasswordvar & " " & $portvar & " " & $hostnamevar
    msgbox(0, "test", $commands)
EndFunc

Ps. Dont mind my comments, Im extremely bored xD

Edited by RawrOmg
Link to comment
Share on other sites

Im having another problem now, when I combine all the stuff together it just prints random numbers instead of the input.

+map 6 +maxplayers 7 +sv_gamemode 5 +sv_defaultgamemode 5 +rcon_password 9 -port 8 -hostname 4

like that instead of it saying something like +Map MAPNAMEHERE

Func button1()
     #cs------------------------------------------------------------------------------------------------
     Diggity Diggity Dawg Fo sho, Here comes adding all the variables together and running the sheeeettt
     #ce------------------------------------------------------------------------------------------------
     $Mapvar = $map & " " & $input3
     $Maxplayersvar = $maxplayers & " " & $input4
     $gamemodevar = $gamemode & " " & $input2
     $gamemodedefaultvar = $gamemodedefault & " " & $input2
     $rconpasswordvar = $rconpassword & " " & $input6
     $portvar = $port & " " & $input5
     $hostnamevar = $name & " " & $input1
     #cs------------------------------------------------------------------------------------------------------
     Adding Together complete, now lets rap it up by writing all these into one line and running srcds.Execute
     #ce------------------------------------------------------------------------------------------------------
     
     $commands = $mapvar & " " & $maxplayersvar & " " & $gamemodevar & " " & $gamemodedefaultvar & " " & $rconpasswordvar & " " & $portvar & " " & $hostnamevar
     msgbox(0, "test", $commands)
 EndFunc

Thats where all the combining is happening and this is the entire script

GuiCreate("Home",344,239,978,305)
 #cs------------------------
 Teh Commands Dawwg
 #ce------------------------
 $game = "-game garrysmod"
 $map = "+map"
 $maxplayers = "+maxplayers"
 $gamemode = "+sv_gamemode"
 $gamemodedefault = "+sv_defaultgamemode"
 $rconpassword = "+rcon_password"
 $port = "-port"
 $name = "-hostname"
 #cs--------------------------------------------------------
 Teh Commands are Over Foo, Here comes the GUI Maan
 #ce--------------------------------------------------------
 $button1=GuiCtrlCreateButton("Start Server",10,179,325,60)
 $input1=GuiCtrlCreateInput("Server Name",4,12,27,20)
 $input2=GuiCtrlCreateInput("Game mode",4,36,-177,20)
 $input3=GuiCtrlCreateInput("Map",4,61,238,20)
 $input4=GuiCtrlCreateInput("Max Players",4,85,27,20)
 $input5=GuiCtrlCreateInput("UDP Port",4,126,27,20)
 $input6=GuiCtrlCreateInput("Rcon Password",7,152,126,20)
 $label1=GuiCtrlCreateLabel("Most Commonly 27015 or 27017",5,108,190,15)
 GuiSetState()
 #cs---------------------------------------------------------
 Gui Over, here comes shit I dont understand, Plus the button
 #ce---------------------------------------------------------
 While 1
 $msg=GuiGetMsg()
 If $msg=-3 Then Exit
 If $msg=$button1 Then button1()
 Wend
 
 
 
 
 Func button1()
     #cs------------------------------------------------------------------------------------------------
     Diggity Diggity Dawg Fo sho, Here comes adding all the variables together and running the sheeeettt
     #ce------------------------------------------------------------------------------------------------
     $Mapvar = $map & " " & $input3
     $Maxplayersvar = $maxplayers & " " & $input4
     $gamemodevar = $gamemode & " " & $input2
     $gamemodedefaultvar = $gamemodedefault & " " & $input2
     $rconpasswordvar = $rconpassword & " " & $input6
     $portvar = $port & " " & $input5
     $hostnamevar = $name & " " & $input1
     #cs------------------------------------------------------------------------------------------------------
     Adding Together complete, now lets rap it up by writing all these into one line and running srcds.Execute
     #ce------------------------------------------------------------------------------------------------------
     
     $commands = $mapvar & " " & $maxplayersvar & " " & $gamemodevar & " " & $gamemodedefaultvar & " " & $rconpasswordvar & " " & $portvar & " " & $hostnamevar
     msgbox(0, "test", $commands)
 EndFunc

Ps. Dont mind my comments, Im extremely bored xD

Scite told me that there is an error in your comments. I think it might be how you have your #ce before your --------------- I dunno though. I just removed your comments and it worked fine for me.

edit**

Yup, that's what it is. Put your #ce on the next line after your -------------------

Edited by jaberwocky6669
Link to comment
Share on other sites

Scite told me that there is an error in your comments. I think it might be how you have your #ce before your --------------- I dunno though. I just removed your comments and it worked fine for me.

edit**

Yup, that's what it is. Put your #ce on the next line after your -------------------

It's still returning numbers (+map 6) instead of words (+Map gm_whatever)

Link to comment
Share on other sites

It's still returning numbers (+map 6) instead of words (+Map gm_whatever)

If you want to use the contents of an input then you don't use the variable name, you have to read the contents of the variable.

So instead of

$Mapvar = $map & " " & $input3; $input3 is the variable name for the input ID which has the value of some number.

you should have

$Mapvar = $map & " " & GuiCtrlRead($input3);add the text in the input to the end of $map

EDIT: Corrected to use GuiCTrlRead

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

If you want to use the contents of an input then you don't use the variable name, you have to read the contents of the variable.

So instead of

$Mapvar = $map & " " & $input3; $input3 is the variable name for the input ID which has the value of some number.

you should have

$Mapvar = $map & " " & GuiCtrlGetData($input3);add the text in the input to the end of $map
Okay thanks, Ill try that
Link to comment
Share on other sites

>C:\Program Files\AutoIt3\SciTE\..\au3check.exe "C:\srcds\Dedicated server\Gameserver\orangebox\Gmod Serverbeta.au3"
AutoIt3 Syntax Checker v1.54.8  Copyright (c) Tylo 2007

C:\srcds\Dedicated server\Gameserver\orangebox\Gmod Serverbeta.au3(41,47) : ERROR: GuiCtrlGetData(): undefined function.
    $Mapvar = $map & " " & GuiCtrlGetData($input3)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

I'm getting that error.

GuiCtrlGetData isnt a command I think, It doesnt highlight and it doesn't show up in the auto complete list

Link to comment
Share on other sites

  • Developers

I'm getting that error.

GuiCtrlGetData isnt a command I think, It doesnt highlight and it doesn't show up in the auto complete list

It isn't in my helpfile either .... pretty sure Martin meant GUICtrlRead() :)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

>C:\Program Files\AutoIt3\SciTE\..\au3check.exe "C:\srcds\Dedicated server\Gameserver\orangebox\Gmod Serverbeta.au3"
AutoIt3 Syntax Checker v1.54.8  Copyright (c) Tylo 2007

C:\srcds\Dedicated server\Gameserver\orangebox\Gmod Serverbeta.au3(41,47) : ERROR: GuiCtrlGetData(): undefined function.
    $Mapvar = $map & " " & GuiCtrlGetData($input3)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

I'm getting that error.

GuiCtrlGetData isnt a command I think, It doesnt highlight and it doesn't show up in the auto complete list

Sorry RawrOmg, I don't know why I said GuiCtrGetData, it's GuiCtrlRead.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Haha, Its okay, Thank you to everyone, the script works now.

I have learned two things today.

One is about adding variables together and reading gui inputs

and the other is i should ask the Autoit forum community more questions in the future

Thanks everyone :]

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...