Author Topic: question about fool proofing?  (Read 2029 times)

0 Members and 1 Guest are viewing this topic.

Offline talmera

  • Newbie
  • *
  • Posts: 36
  • Karma: 4
    • Tectonic-Gaming
question about fool proofing?
« on: August 09, 2013, 01:12:28 AM »
Is there a hook or something that allows me to check if an addon (in this case ULX/Ulib) is loaded on the server, I want to check to see if it is loaded and then run a ulx function in a script I'm tinkering with. I've tried checking facepunch and here but failed to find anything that would shed some light on this.
It's not a sin if it can't make me cry
He's not the devil unless there's fire in his eyes
It ain't the ghost if it don't speak in tongue
It's not a victory 'till the battles been won

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: question about fool proofing?
« Reply #1 on: August 09, 2013, 05:45:03 AM »
There isn't a hook, but you can return the ULX table to check if it's been loaded yet.

Code: [Select]
if ulx then
    run code here
end

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: question about fool proofing?
« Reply #2 on: August 09, 2013, 02:07:34 PM »
If your full addon requires ULX be loaded (not just some small function of it), you could also place your addon file in  <your_addon>/lua/ulx/modules</cl|/sv|/sh/&|>/file.lua.
Then it would like when ULX loads.

That gets tricky though if your full addon doesn't require it; but only that small command - then it becomes a 'which loads first, my code or ULX'. Luck of the draw at that point.
You wouldn't want the function to run as  ULX is loading if your other code hadn't loaded first.
« Last Edit: August 09, 2013, 02:10:23 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: question about fool proofing?
« Reply #3 on: August 09, 2013, 06:56:11 PM »
Also, that assumes his addon (assuming it is an addon) is only one file and has no other dependencies.

Offline talmera

  • Newbie
  • *
  • Posts: 36
  • Karma: 4
    • Tectonic-Gaming
Re: question about fool proofing?
« Reply #4 on: September 20, 2013, 07:57:43 PM »
Also, that assumes his addon (assuming it is an addon) is only one file and has no other dependencies.

sorry for the late reply, I was making it so it was compatible with multiple admin packages, thank you for the answer MrPresident.
It's not a sin if it can't make me cry
He's not the devil unless there's fire in his eyes
It ain't the ghost if it don't speak in tongue
It's not a victory 'till the battles been won