@@ -43,7 +43,7 @@ function GM:PlayerInitialSpawn(client)
4343
4444 -- Load and send the NutScript data for the player.
4545 client :loadNutData (function (data )
46- if (! IsValid (client )) then return end
46+ if (not IsValid (client )) then return end
4747
4848 local address = client :IPAddress ()
4949 client :setNutData (" lastIP" , address )
@@ -53,6 +53,13 @@ function GM:PlayerInitialSpawn(client)
5353 " nutDataSync" ,
5454 data , client .firstJoin , client .lastJoin
5555 )
56+
57+ for _ , v in pairs (nut .item .instances ) do
58+ if v .entity and v .invID == 0 then
59+ v :sync (client )
60+ end
61+ end
62+
5663 hook .Run (" PlayerNutDataLoaded" , client )
5764 end )
5865
@@ -71,7 +78,7 @@ function GM:PlayerUse(client, entity)
7178 if (result == false ) then
7279 return false
7380 else
74- local result = hook .Run (" PlayerUseDoor" , client , entity )
81+ result = hook .Run (" PlayerUseDoor" , client , entity )
7582 if (result ~= nil ) then
7683 return result
7784 end
@@ -107,12 +114,12 @@ function GM:CanPlayerDropItem(client, item)
107114
108115 if (inventory ) then
109116 local items = inventory :getItems ()
117+ for _ , item in pairs (items ) do
110118
111- for id , item in pairs (items ) do
112119 if (not item .ignoreEquipCheck and item :getData (" equip" ) == true ) then
113120 client :notifyLocalized (" cantDropBagHasEquipped" )
114121 return false
115- end
122+ end
116123 end
117124 end
118125 end
@@ -192,23 +199,20 @@ function GM:PlayerLoadedChar(client, character, lastChar)
192199 if (lastChar ) then
193200 local charEnts = lastChar :getVar (" charEnts" ) or {}
194201
195- for k , v in ipairs (charEnts ) do
202+ for _ , v in ipairs (charEnts ) do
196203 if (v and IsValid (v )) then
197204 v :Remove ()
198205 end
199206 end
200207
201- lastChar :setVar (" charEnts" , nil )
208+ lastChar :setVar (" charEnts" , nil )
202209 end
203210
204211 if (character ) then
205- for k , v in pairs (nut .class .list ) do
206- if (v .faction == client :Team ()) then
207- if (v .isDefault ) then
208- character :setClass (v .index )
209-
210- break
211- end
212+ for _ , v in pairs (nut .class .list ) do
213+ if (v .faction == client :Team ()) and v .isDefault then
214+ character :setClass (v .index )
215+ break
212216 end
213217 end
214218 end
246250function GM :PlayerSay (client , message )
247251 local chatType , message , anonymous = nut .chat .parse (client , message , true )
248252
249- if (chatType == " ic" ) then
250- if (nut .command .parse (client , message )) then
251- return " "
252- end
253+ if (chatType == " ic" ) and (nut .command .parse (client , message )) then
254+ return " "
253255 end
254256
255257 nut .chat .send (client , chatType , message , anonymous )
@@ -309,7 +311,7 @@ function GM:PlayerSpawnVehicle(client, model, name, data)
309311 return client :getChar ():hasFlags (" C" )
310312 end
311313 end
312-
314+
313315 return false
314316end
315317
@@ -320,7 +322,7 @@ function GM:PlayerLoadout(client)
320322
321323 return
322324 end
323-
325+
324326 client :SetWeaponColor (Vector (client :GetInfo (" cl_weaponcolor" )))
325327 client :StripWeapons ()
326328 client :setLocalVar (" blur" , nil )
@@ -335,7 +337,7 @@ function GM:PlayerLoadout(client)
335337 client :Give (" nut_hands" )
336338 client :SetWalkSpeed (nut .config .get (" walkSpeed" , 130 ))
337339 client :SetRunSpeed (nut .config .get (" runSpeed" , 235 ))
338-
340+
339341 local faction = nut .faction .indices [client :Team ()]
340342
341343 if (faction ) then
@@ -346,7 +348,7 @@ function GM:PlayerLoadout(client)
346348
347349 -- If the faction has default weapons, give them to the player.
348350 if (faction .weapons ) then
349- for k , v in ipairs (faction .weapons ) do
351+ for _ , v in ipairs (faction .weapons ) do
350352 client :Give (v )
351353 end
352354 end
@@ -361,7 +363,7 @@ function GM:PlayerLoadout(client)
361363 end
362364
363365 if (class .weapons ) then
364- for k , v in ipairs (class .weapons ) do
366+ for _ , v in ipairs (class .weapons ) do
365367 client :Give (v )
366368 end
367369 end
@@ -439,7 +441,7 @@ function GM:PlayerDisconnected(client)
439441 if (character ) then
440442 local charEnts = character :getVar (" charEnts" ) or {}
441443
442- for k , v in ipairs (charEnts ) do
444+ for _ , v in ipairs (charEnts ) do
443445 if (v and IsValid (v )) then
444446 v :Remove ()
445447 end
@@ -450,7 +452,7 @@ function GM:PlayerDisconnected(client)
450452 hook .Run (" OnCharDisconnect" , client , character )
451453 character :save ()
452454 end
453-
455+
454456 if (IsValid (client .nutRagdoll )) then
455457 client .nutRagdoll .nutNoReset = true
456458 client .nutRagdoll .nutIgnoreDelete = true
@@ -463,18 +465,18 @@ end
463465function GM :PlayerAuthed (client , steamID , uniqueID )
464466 nut .log .add (client , " playerConnected" , client , steamID )
465467end
466-
468+
467469function GM :InitPostEntity ()
468470 local doors = ents .FindByClass (" prop_door_rotating" )
469471
470- for k , v in ipairs (doors ) do
472+ for _ , v in ipairs (doors ) do
471473 local parent = v :GetOwner ()
472474
473475 if (IsValid (parent )) then
474476 v .nutPartner = parent
475477 parent .nutPartner = v
476478 else
477- for k2 , v2 in ipairs (doors ) do
479+ for _ , v2 in ipairs (doors ) do
478480 if (v2 :GetOwner () == v ) then
479481 v2 .nutPartner = v
480482 v .nutPartner = v2
@@ -505,7 +507,7 @@ function GM:ShutDown()
505507
506508 hook .Run (" SaveData" )
507509
508- for k , v in ipairs (player .GetAll ()) do
510+ for _ , v in ipairs (player .GetAll ()) do
509511 v :saveNutData ()
510512
511513 if (v :getChar ()) then
@@ -519,7 +521,7 @@ function GM:PlayerDeathSound()
519521end
520522
521523function GM :InitializedSchema ()
522- if (! nut .data .get (" date" , nil , false , true )) then
524+ if (not nut .data .get (" date" , nil , false , true )) then
523525 nut .data .set (" date" , os.time (), false , true )
524526 end
525527
@@ -534,21 +536,21 @@ end
534536
535537function GM :PlayerCanHearPlayersVoice (listener , speaker )
536538 local allowVoice = nut .config .get (" allowVoice" )
537-
538- if (! allowVoice ) then
539+
540+ if (not allowVoice ) then
539541 return false , false
540542 end
541-
543+
542544 if (listener :GetPos ():DistToSqr (speaker :GetPos ()) > nut .config .squaredVoiceDistance ) then
543545 return false , false
544546 end
545-
547+
546548 return true , true
547549end
548550
549551function GM :OnPhysgunFreeze (weapon , physObj , entity , client )
550552 -- Object is already frozen (!?)
551- if (! physObj :IsMoveable ()) then return false end
553+ if (not physObj :IsMoveable ()) then return false end
552554 if (entity :GetUnFreezable ()) then return false end
553555
554556 physObj :EnableMotion (false )
@@ -598,15 +600,16 @@ function GM:CharacterPreSave(character)
598600 if (not character :getInv ()) then
599601 return
600602 end
601- for k , v in pairs (character :getInv ():getItems ()) do
603+ for _ , v in pairs (character :getInv ():getItems ()) do
602604 if (v .onSave ) then
603605 v :call (" onSave" , client )
604606 end
605607 end
606608end
607609
608610function GM :OnServerLog (client , logType , ...)
609- for k , v in pairs (nut .util .getAdmins ()) do
611+ for _ , v in pairs (nut .util .getAdmins ()) do
612+
610613 if (hook .Run (" CanPlayerSeeLog" , v , logType ) ~= false ) then
611614 nut .log .send (v , nut .log .getString (client , logType , ... ))
612615 end
@@ -650,14 +653,14 @@ PUBLIC SERVICE ANNOUNCEMENT FOR NUTSCRIPT SERVER OWNERS
650653
651654There is a ENOURMOUS performance issue with ULX Admin mod.
652655Nutscript Development Team found ULX is the main issue
653- that make the server freeze when player count is higher
656+ that make the server freeze when player count is higher
654657than 20-30. The duration of freeze will be increased as you get
655658more players on your server.
656659
657660If you're planning to open big server with ULX/ULib, Nutscript
658661Development Team does not recommend your plan. Server Performance
659- Issues with ULX/Ulib on your server will be ignored and we're
660- going to consider that you're taking the risk of ULX/Ulib's
662+ Issues with ULX/Ulib on your server will be ignored and we're
663+ going to consider that you're taking the risk of ULX/Ulib's
661664critical performance issue.
662665
663666Nutscript 1.2 only displays this message when you have ULX or
@@ -723,10 +726,10 @@ function GM:CreateSalaryTimer(client)
723726
724727 local faction = nut .faction .indices [character :getFaction ()]
725728 local class = nut .class .list [character :getClass ()]
726-
729+
727730 local pay = hook .Run (" GetSalaryAmount" , client , faction , class ) or (class and class .pay ) or (faction and faction .pay ) or nil
728-
729- if (! pay ) then return end
731+
732+ if (not pay ) then return end
730733
731734 local timerID = " nutSalary" .. client :SteamID ()
732735 local timerFunc = timer .Exists (timerID ) and timer .Adjust or timer .Create
0 commit comments