ULX

Author Topic: Trying to learn lua a little  (Read 5624 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Trying to learn lua a little
« Reply #15 on: February 13, 2014, 11:38:40 AM »
That is WAY more complicated than it needs to be. Also it won't work at all. PlayerSpawn is serverside, and why are you looping through every player, what in the world are you doing??
This is literally all you need:
Code: [Select]
hook.Add( "PlayerSpawn", "PlayerCheck", function( ply )
local lv = ply:getDarkRPVar( "level" )
if lv > 10 then
ply:SetHealth( lv * 10 )
end
end )
« Last Edit: February 13, 2014, 11:52:18 AM by Cobalt »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Trying to learn lua a little
« Reply #16 on: February 13, 2014, 11:51:44 AM »
Indeed, you could have kept your original code, just added a bit.
There are two ways to make sure your code is on server side.
1) /autorun/cl or /sv - obvious where.
OR
2) You used part of the idea already, but then, instead of going from from point A to point be in a straight line, you circumnavigated the globe going the same direction.
Simple use your code, but add like this
Code: [Select]
if SERVER then
     ... your original code ...
end

I've not tested your code, nor do I know DarkRP to know it will work, but, one step at a time, keep it simple, get it 'running' on server only.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming