• Print

Author Topic: Multiplayer Error ( Lua )  (Read 5599 times)

0 Members and 1 Guest are viewing this topic.

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Multiplayer Error ( Lua )
« on: August 24, 2012, 08:27:46 pm »
hello guys , a few days ago i finally finish the SQLite Level system :D , its working pretty cool ( In Single Player )

but a few minutes ago ... i click on MultiPlayer and everything  crash ... the error ?

ERROR: GAMEMODE:'HUDPaint' Failed: [Umbrella\gamemode\client\hud.lua:270] attempt to index field 'RP_SQL' (a nil value)
E

( well i call the RP_SQL in a shared file ... here:

RP_SQL = {}

but i really don't know how to fix that :( who know how i can fix this error ?

Thanks Ulysses Team !

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Multiplayer Error ( Lua )
« Reply #1 on: August 24, 2012, 09:46:20 pm »
What is line 270 in your code?

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Multiplayer Error ( Lua )
« Reply #2 on: August 24, 2012, 10:21:44 pm »
Hello Mr.President , sorry for the delay :/

Code: Lua
  1. 263     local x12 = ((ScrW() *0.85902777)) -- Primer Palo Blanco ( Izquierda - Derecha )
  2. 264     local y12 = ((ScrH() * 0.04444444))      -- Segundo Palo Blanco ( Izquierda - Derecha )  
  3. 265    
  4. 266             local ply = LocalPlayer()
  5. 267     surface.SetTextColor (255,255,255,200)
  6. 268     surface.SetTextPos(x12,y12)
  7. 269     surface.SetFont("font")
  8. 270     surface.DrawText("Level: "..ply.RP_SQL["GeneralLvl"], Color(255,0,0,255))
  9.  

works in singleplayer but in multiplayer breaks :S i really don't know why. u.u

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Multiplayer Error ( Lua )
« Reply #3 on: August 24, 2012, 11:38:41 pm »
2 things


ply.RP_SQL = {}

and

RP_SQL = {}

are not the same thing. So if you set RP_SQL = {} in your shared.lua you will not be able to call   ply.RP_SQL = {}

Show me in your code where you set the value for ply.RP_SQL["GeneralLvl"]

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Multiplayer Error ( Lua )
« Reply #4 on: August 25, 2012, 10:24:15 am »
i send you via PM my code :)

sorry hehe , its really important for me ... and i trust you 200%

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Multiplayer Error ( Lua )
« Reply #5 on: August 25, 2012, 12:41:53 pm »
a friend told me to use usermessages.
( but i don't know how usermessages work )

He gave me 2 examples:

Clark: usermessages to send the data
Clark: and the server querys for the data
Clark: http://garryforum.googlecode.com/svn/trunk/gForum/lua/autorun/server/sv_meta.lua
Clark: http://garryforum.googlecode.com/svn/trunk/gForum/lua/autorun/client/cl_init.lua
Clark:

Code: Lua
  1. usermessage.Hook("cl_setinfo", function( um )
  2. umsg.Start("cl_setinfo", self)
  3. umsg.String(Args[1][2] ..";" .. group ..";" .. Args[1][4])
  4. umsg.End()
  5.  

Clark: 1st one client
Clark: 2nd server
Clark: server sending info to client
Clark: client getting info

Thanks Mr.President , Thanks UlyssesMod Team

Offline Schiaffino

  • Jr. Member
  • **
  • Posts: 88
  • Karma: 1
Re: Multiplayer Error ( Lua )
« Reply #6 on: August 25, 2012, 04:53:54 pm »
i fix the error with:

Adding this lua lines in all the areas that appear RP_SQL and some skill

   local ply = LocalPlayer()
   
   if !ply:Alive() then return end
   if(ply:GetActiveWeapon() == "Camera") then return end
   if(ply.RP_SQL == nil) then return end
   if not force and not self:IsVisible() then return end

example the scoreboard:

      if(ply.RP_SQL["GeneralLvl"] != nil) then
   self.lblLevel:SetText(self.Player.RP_SQL["GeneralLvl"])
   end

the problem ?

there's just 1 way to see this ... and its updating the GeneralLvl that's mean you need to level up to see the GeneralLvl :S any idea of how i can edit this code to get the GeneraLvl without leveling up ?

thanks !

  • Print