Learner Lua


SUBMITTED BY: Guest

DATE: Aug. 21, 2013, 12:13 p.m.

FORMAT: Text only

SIZE: 2.1 kB

HITS: 1366

  1. local MyGamemode = MyGamemode or {}
  2. --Create An Overall Table For Our Gamemode
  3. --Set The Value Of The Table To Itself
  4. --Or
  5. --If It Has No Value Set The Value To An Empty Table
  6. --Make A Custom Function In Our Table
  7. function MyGamemode.PlayerInitialSpawn( Ply )
  8. --Add A Variable To Our Player Entity
  9. Ply.SpawnEquipment = {}
  10. Ply.SpawnEquipment.Weapons = {}
  11. --Insert A Custom Value To The Table
  12. table.insert( Ply.SpawnEquipment.Weapons, "weapon_crowbar" )
  13. --Example Of Clearing The Table And Adding New Weapons
  14. table.Empty( Ply.SpawnEquipment.Weapons )
  15. --Insert A Different Weapon
  16. table.insert( Ply.SpawnEquiment.Weapons, "weapon_ar2" )
  17. --And Another
  18. table.insert( Ply.SpawnEquiment.Weapons, "weapon_pistol" )
  19. end
  20. --Hook Into The GM:PlayerInitialSpawn()
  21. hook.Add( "PlayerInitialSpawn", "MyCustomInitalspawnFunction", MyGamemode.PlayerInitialSpawn )
  22. --Give The Player Their Spawn Equipment
  23. --Override The PlayerLoadout Function So ONLY Our Equipment Is Given
  24. function GM:PlayerLoadout( Ply )
  25. local Equipment = Ply.SpawnEquipment
  26. --Make Sure Equipment Is Not nil
  27. if ( Equipment != nil ) Then
  28. local Weapons = Equipment.Weapons
  29. --Make Sure Weapons Is Not nil
  30. if ( Weapons != nil ) then
  31. --Loop Through Our Weapons Table
  32. --k == Table Key, 1,2,3,4,5..
  33. --v == Table Value
  34. for k,v in pairs(Weapons) do
  35. --Give The player Each Weapon In The Equipment Table
  36. Ply:Give( v )
  37. end
  38. end
  39. end
  40. end

comments powered by Disqus