• Print

Author Topic: ULX Coding Problem  (Read 5291 times)

0 Members and 1 Guest are viewing this topic.

Offline josephhabib

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
ULX Coding Problem
« on: January 29, 2016, 08:59:36 am »
My friend coded 1 custom command for ULX that works properly. I copied and pasted the files and changed the .wavs + everything inside them and it worked properly. I did the same thing again but this time it does not work. It is supposed to play a sound and then kill the person with another .wav sound playing after the other sound ended to make it seem like the target got blown up. Apparently it refused to work properly and started targeting a sound to play from the second custom command. I compared code and made sure everything was fine and it was. There aren't many files so it didn't take long to check the original command, second command, and third to see if there's a problem. Eventually I tried to change the names of the .wavs and then just choose new ones. The problem is that the first sound does not go off and the last one is super low volume.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: ULX Coding Problem
« Reply #1 on: January 29, 2016, 10:23:45 am »
It would help to actually see some code; we can't fix what we don't have. :P
bw81@ulysses-forums ~ % whoami
Homepage

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: ULX Coding Problem
« Reply #2 on: January 29, 2016, 12:35:04 pm »
It would help to actually see some code; we can't fix what we don't have. :P

Just use your code-mind-reading abilities.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: ULX Coding Problem
« Reply #3 on: January 29, 2016, 04:27:05 pm »
Just use your code-mind-reading abilities.
Code: Lua
  1. function herp(derp)
  2.     pleasePlayMusicKThxbb(derp) -- <3
  3. end
Did I do good?
bw81@ulysses-forums ~ % whoami
Homepage

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: ULX Coding Problem
« Reply #4 on: January 29, 2016, 06:20:23 pm »
Code: Lua
  1. function herp(derp)
  2.     pleasePlayMusicKThxbb(derp) -- <3
  3. end
Did I do good?

I give it an A+
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX Coding Problem
« Reply #5 on: January 29, 2016, 09:21:29 pm »
Josephhabib, the others are right, we'll need to see code and errors if any.
We could guess all day.

* JamminR puts a Li-ion battery in the compartment of his mind-code-reading skillz, hoping it doesn't explode.
My educated guess, without seeing your code -
Regarding your various sound doesn't play when it should, you likely don't have unique function names, or unique hook names, for one or more of the functions or hooks you copied.
Example, say you have one working function.
Code: [Select]
function death_sound1_one ( player )
  ... code that plays sound ...
end
concommand.Add ( "run_func1", death_sound1_one )
To run that, in console, you'd type "run_func1"

But then you copy and paste it.
Look below at the two spots I've commented with -- .. those spots must be different for the second function, or the first function would get called.
Code: [Select]
function death_sound1_one ( player )
  ... code that plays sound ...
end
concommand.Add ( "run_func1", death_sound1_one )

function death_sound2_two ( player ) -- You'd have to change the function name!!
  ... code that plays sound ...
end
concommand.Add ( "run_func2", death_sound2_two ) -- You'd have to change both the command and the function.
Hooks are the same way, if your command is using player say hooks
hook.add( PlayerSay , UNIQUE_name_1, "death_sound1_one" )
hook.add( PlayerSay, UNIQUE_name_2, "death_sound2_two" )

Make sure you are using unique command, function and hook names, or any could overwrite or call the other.
« Last Edit: January 29, 2016, 09:23:41 pm by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print