| Blockland Forums > Modification Help |
| Command to make player play sound (again no GUI) |
| (1/2) > >> |
| Brixmon:
Hey! I've got another problem here. Pretty much the same as what I needed before, but even simpler, and for sound files this time. This is probably a dumb question, the answer to which should be obvious to those more experienced than I, but alas, I can't decipher bldoc.nullable.se to find the information I seek, soo... For the same reasons as before, I want to make a /command to make the player(not the client or server) play a 3d sound. Specifically, I was trying to make it randomly select a sound from a list, which I sampled Player_Overwatch for, since that Tracer playertype can play multiple random sounds for its blink ability. But I obviously messed something simple up here, I just don't know what it is. This is the test addon's code in its entirety. --- Code: ---//Emote_Alarm.cs datablock AudioProfile(chrys_scream1Sound) { filename = "./chrys_scream1.wav"; description = AudioClosest3d; preload = false; }; datablock AudioProfile(chrys_scream2Sound : chrys_scream1Sound) { filename = "./painis_2.wav"; }; datablock AudioProfile(chrys_scream3Sound : chrys_scream1Sound) { filename = "./duckn_alert.wav"; }; datablock AudioProfile(chrys_scream4Sound : chrys_scream1Sound) { filename = "./skel_buzz_skeletonalarm.wav"; }; function serverCmdhorrortest(%client) { if(isObject(%client.player)) %pl.schedule(1,playAudio,4,chrys_scream @ getRandom(1,4) @ Sound); } --- End code --- Clearly a simple error, as the console spits this out when I try the test command. --- Quote ---Add-Ons/Script_PlayerHorrorSounds/horrorsounds.cs (0): Unable to find object: '' attempting to call function 'schedule' BackTrace: ->serverCmdhorrortest --- End quote --- And of course, it doesn't play the sound. To clarify, I did check that the sounds worked. They do... even though it took me like two days to figure out that they had to be 16-bit PCM wavs. |
| Shift Kitty:
Because you're calling a function on %pl when that variable is never declared. Replace that with %client.player.schedule In fact, does it even need to be scheduled? %client.player.playAudio(4,etc); should work fine. Some chat snips from the Blockland Content Creators should be helpful for understanding why this happened. --- Quote ---[12:42 PM] Lake: Looks like %obj isn't defined anywhere [1:09 PM] McTwist: Change %obj to %player. However, I'm unsure if the muzzle functions is defined in the player. [1:10 PM] Ze Operator: worth a shot. [1:38 PM] nul: It is [1:38 PM] Ze Operator: Technically speaking though, [1:38 PM] Ze Operator: isn't %player and %obj technically the same?(edited) [1:40 PM] nul: The thing about variables is that it doesn't matter what you call them. In onTrigger specifically, you could set it up like function Armor::onTrigger(%ass,%titty,%conan,%blocklandisdead) and %ass would be the datablock, %titty would be the player object, %conan would be the trigger, and %blocklandisdead would be the state of the trigger. [1:40 PM] nul: It's the order that matters, not the name. [1:40 PM] nul: And in this case, neither %player nor %obj would be the player, they are undefined. [1:41 PM] Ze Operator: I figured as much. [1:41 PM] nul: In your function, %obj is never defined, but %player is. [1:42 PM] Ze Operator: And, by the way you put it, torque is looking for a %obj because it was defined in function Armor. [1:42 PM] Ze Operator: It's not looking for %player.(edited) [1:42 PM] nul: When it says Unable to find object: '' That usually means the variable, in this case %obj, is completely blank. [1:46 PM] Ze Operator: ....Now that is where sensical just lost it's meaning. [1:46 PM] Ze Operator: -_- [1:47 PM] Ze Operator: Wait, hang on [1:47 PM] Ze Operator: Nope, nvm [1:48 PM] nul: Not really. Variables can't just assign themselves values out of nowhere. There is no %obj in the function header (%this, %player, %slot, %val) and there's no %obj = ##; anywhere in the function. But don't worry about %obj, just replace all instances of it in that function with %player --- End quote --- Where in this case, the first variable is the client calling the command, and any following variables are the other things they type after the command. Eg: serverCmdButts(%butt,%leftCheek,%rightCheek) /butts 2 4 %butt would be the client calling the function, %leftCheek would be 2, and %rightCheek would be 4. Edit: Also, don't playAudio on slot 4 either. Change that to a number from 0-3, if I recall, any higher than that and nothing happens. Just avoid 0 because that's used by default functions (light, pain, and death). |
| Brixmon:
--- Quote from: Shift Kitty on October 22, 2017, 11:12:49 PM ----scissors- --- End quote --- Thanks for the help, that worked. I knew from the start that this was simple, as I pretty much copied the code. I also knew that probably wouldn't work, but I didn't know what else to do. Thing is, I don't know the names of default variables or functions, nor what they do. The reference site I went to only seems to list them, not explain them. I also haven't found any references for that sort of thing anywhere, which has made figuring out basic stuff like this very difficult. But that's neither here nor there- thanks a lot for the help! |
| Kyuande:
Remember, try to learn the code before you test it, definitely will help with your experience There is a user wiki for Blockland somewhere on the functions with args and descriptions |
| Brixmon:
--- Quote from: Kyuande on October 23, 2017, 12:17:34 AM ---Remember, try to learn the code before you test it, definitely will help with your experience --- End quote --- I think that a part of the reason why I had trouble with this is that I don't know of any addons that make the player simply play sounds on command, so I had nothing to directly reference. All I could think to do was cobble something together, which I knew probably wouldn't work. One day I'll probably figure this out. I think I get how the code is structured, I feel like I moreso need to just know... specific strings. Like that client.player thing. |
| Navigation |
| Message Index |
| Next page |