Blister Posted July 28, 2008 Author Share Posted July 28, 2008 Hey guys!First: I'm using EE 2.7 And I want to try out some easy scripting to learn it better. Learning by doing so to speak. I tried some messages that display if you step on some place. I have a question to this also but i'll come to this later.The first more complex thing I want to do is make a simple, nonsenseless script, which allows me to play a sound by tiping a text command.So I think the beginning of the script should be something like thisIf LCase(Mid(TextSay, 1, 8)) = "/belch" Then (<–- now get why it's nonsenseless? ;P)But I'm not sure if this is right and also I don't know the right command to play a sound or how I shall write the script further.This is why I aks you to explain to me how to proceed with the script.So now to the thing with the script that starts if you step somewhere. Well in the map editor there are the 2 attributes "Scripted" (i think thats the one you step on) and "click" (I thought you have to press enter or space if you're at this? I used the rm2k in the past this is why this stuff confuses me a little bit)When you setup those you have to choose a script number. So how do I mark any Script as.. don't know.. number 100? is this the line in the main.txt ?speaking of the main.txt: where would I have to place those scripts in there?I'm so damn clueless :confused: Link to comment Share on other sites More sharing options...
allanws Posted July 28, 2008 Share Posted July 28, 2008 Ok1st: About the sound play command.You'd want to do something like:```Case "/command"PlaySound(Index, "sound_name.wav")Exit Sub```So this is what it does:Case "/command" => Specifies in which case u want the script to happen (in this case, when player types /command)PlaySound => is the command to play the sound chosen (u must specify to whom u wish the sound to play to (this case index, which the the user of the command) and which .wav sound u wish to play (this case "sound_name.wav" (look in ur sfx folder for .wav sounds))Exit Sub => ends the currend case.This should go under Sub Commands on ur Main.txt2nd: Map editor attributes:Scripted: will search in ur main.txt for the script under Sub ScriptedTiles. For example: if u build a script under Sub ScriptedTiles with the Case 4 on, you'd have to choose the script 4 in the script attribute.```Case 4PlaySound(Index, "sound_name.wav")Exit Sub```Its recommended to build scripts in numerical order cases, not to get the main.txt messed up (Case 1, Case 2, Case 3…)Click: sorry but i havent used this attribute yet so i can only guess what it does =/Hope i helped Link to comment Share on other sites More sharing options...
balliztik1 Posted July 28, 2008 Share Posted July 28, 2008 You might also consider:```PlaySoundToMap(index, "sound_name.wav")```That way, others will hear the sound on the map as well. Link to comment Share on other sites More sharing options...
Blister Posted July 28, 2008 Author Share Posted July 28, 2008 Thx very much allanws! The much detail helped me a lot.And also thx to you Balliztik cause I want the whole map to hear the sound.EDIT: damn I can't get it to work. He just says invalid comman or something like this.I added it to nearly the bottom of my main.txt like thisSub Case "/belch" PlaySoundToMap (index, "burrrrrp.wav")End Sub I read this sub at anything so I tried it with the sub (I tried it without bevor but didn't work.)I'm really ashamed of asking but would you mind telling me how to add this? Sry I just don't get it yet.I use version EE 2.7 and theres a command-ini… does it have something to do with this? Link to comment Share on other sites More sharing options...
allanws Posted July 28, 2008 Share Posted July 28, 2008 Do not put sub on case. it should be simply:```Case "/belch" PlaySoundToMap (index, "burrrrrp.wav")End Sub```Case, as the conditional says, is a case that should happen on a sub. So the sub for this is Commands, and the case is /belch.Add that code under Sub Commands on your main.txt EDIT: Don't be ashamed! :cheesy: everyone starts slow then they start picking up. try reading some tuts on SadScripting, thats how i started. Good luckcommand.ini is just for storing commands that were used in the server (i think, not sure). every script u build is basicly placed on the main.txt Then u just have to figure out which section u wish to place it in, depending on when u want the script to run (those are the subs) Link to comment Share on other sites More sharing options...
Blister Posted July 28, 2008 Author Share Posted July 28, 2008 Ahhhh now I understand ^^ ThxEDIT:I'm sorry to ask again but there's a problem.I did everythign as you told me. Script seems to be in the right place and basically it seems to workcause he doesn't say invalid command anymore.But for some reason I can hear no sound oO I thought it could be the wave data and tried the other sounds (even the standart ones) and none did work. I tried PlaySound and PlaySoundToMap but in both cases: total silence.This is how my Sub Command part of the main.txt looks like: (I marked the Custom Script Part)' Executed whenever a slash command is sent to the server.Sub Commands(Index)Dim TextSayDim PlayerIDDim MapNum' Get the command and arguments from the cache.TextSay = Trim(GetVar("Scripts\Command.ini", "TEMP", "Text" & Index))' Split the command into an array. All arguments are seperated by spaces.TextSay = Split(TextSay)Select Case TextSay(0)Case "/testscripts"Call TestMain(Index)Exit SubCase "/help"Call PlayerMsg(Index, "Social Commands:", WHITE)Call PlayerMsg(Index, "'msghere = Broadcast Message", WHITE)Call PlayerMsg(Index, "-msghere = Emote Message", WHITE)Call PlayerMsg(Index, "!namehere msghere = Player Message", WHITE)Call PlayerMsg(Index, "Available Commands: /help, /info, /who, /fps, /inv, /stats, /train, /party, /join, /leave, /refresh", WHITE)Exit SubCase "/calladmins"If GetPlayerAccess(Index) = 0 ThenCall AdminMsg(GetPlayerName(Index) & " needs your help!", BRIGHTGREEN)ElseCall PlayerMsg(Index, "You are an admin! You cannot call for help!", BRIGHTGREEN)End IfExit SubCase "/admin"If GetPlayerAccess(Index) > 0 ThenCall PlayerMsg(Index, "Social Commands:", WHITE)Call PlayerMsg(Index, """msghere = Global Admin Message", WHITE)Call PlayerMsg(Index, "=msghere = Private Admin Message", WHITE)Call PlayerMsg(Index, "Available Commands: /admin, /loc, /mapeditor, /warpmeto, /warptome, /warpto, /setsprite, /mapreport, /kick, /ban, /edititem, /respawn, /editnpc, /motd, /editshop, /ban, /editspell", WHITE)End IfExit Sub **Case "/belch" PlaySoundToMap(index, "belch.wav") End Sub**Case "/warpmeto"If GetPlayerAccess(Index) > 0 ThenPlayerID = FindPlayer(TextSay(1))If PlayerID > 0 ThenCall PlayerWarp(Index, GetPlayerMap(PlayerID), GetPlayerX(PlayerID), GetPlayerY(PlayerID))Call PlayerMsg(Index, "You have been warped to " & GetPlayerName(PlayerID) & ".", BROWN)ElseCall PlayerMsg(Index, "Player is not online.", WHITE)End IfEnd IfExit SubCase "/warptome"If GetPlayerAccess(Index) > 0 ThenPlayerID = FindPlayer(TextSay(1))If PlayerID > 0 ThenCall PlayerWarp(PlayerID, GetPlayerMap(Index), GetPlayerX(Index), GetPlayerY(Index))Call PlayerMsg(PlayerID, "You have been warped to " & GetPlayerName(Index) & ".", BROWN)ElseCall PlayerMsg(Index, "Player is not online.", WHITE)End IfEnd IfExit SubCase "/warpto"If GetPlayerAccess(Index) > 0 ThenMapNum = TextSay(1)If MapNum > 0 And MapNum <= MAX_MAPS ThenCall PlayerWarp(Index, MapNum, GetPlayerX(Index), GetPlayerY(Index))Call PlayerMsg(Index, "You have been warped to map #" & MapNum & ".", BRIGHTBLUE)ElseCall PlayerMsg(Index, "Invalid map number.", BRIGHTRED)End IfEnd IfExit SubEnd SelectCall PlayerMsg(Index, "That is not a valid command.", BRIGHTRED)End Sub Link to comment Share on other sites More sharing options...
Blister Posted July 29, 2008 Author Share Posted July 29, 2008 Just bumping so that the edit will be noticed… SRY I know doubleposters deserve to die :embarrassed: Link to comment Share on other sites More sharing options...
allanws Posted July 29, 2008 Share Posted July 29, 2008 damn sorry i must have typed fast and didnt see that *shoots his own head*```Case "/belch" Call PlaySoundToMap(index, "belch.wav") Exit Sub```You need to Call the command and that would be an exit sub :P Link to comment Share on other sites More sharing options...
Blister Posted July 30, 2008 Author Share Posted July 30, 2008 Ahhhh I already wondered whats the difference between end sub and exit sub.I hope it'll work this time :cheesy: Thank you for your patience ;)EDIT:hmm… thats weird..There's still no sound but the funny thing is every other text commands do not work also oO theres no error message but nothing happens. but in my server panel scripts are turned on oO Link to comment Share on other sites More sharing options...
balliztik1 Posted July 30, 2008 Share Posted July 30, 2008 @Blister:> Ahhhh I already wondered whats the difference between end sub and exit sub.> I hope it'll work this time :cheesy: Thank you for your patience ;)> > EDIT:> hmm… thats weird..> There's still no sound but the funny thing is every other text commands do not work also oO theres no error message but nothing happens. but in my server panel scripts are turned on oOYour main.txt is bugged somewhere, then. Post it or PM it to me, and I can fix it up real quick. Link to comment Share on other sites More sharing options...
brutal Posted August 3, 2008 Share Posted August 3, 2008 First off I'll try to simply explain the diffrenceExit sub = I don't want anymore code in this sub to runEnd Sub = There is no more code that goes in this sub``` Case "/belch" PlaySoundToMap(index, "belch.wav") End Sub```Needs to be``` Case "/belch" Call PlaySoundToMap(index, "belch.wav") Exit Sub```Also Balliztik, he said all his other commands work, which means no matter how bugged his main is this command should work. Link to comment Share on other sites More sharing options...
balliztik1 Posted August 4, 2008 Share Posted August 4, 2008 Yeah…looking back on it, that was a really bad judgment. Lol. What was I thinking? >.<But he did send me his main.txt which had a syntax error. I fixed it, but he said it still didn't work, though it worked fine on my server. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now