|
4 | 4 |
|
5 | 5 | local IsValid = IsValid |
6 | 6 |
|
7 | | - |
8 | 7 | local spawnAlert = {} |
9 | 8 | local lastJoined = NULL |
10 | 9 |
|
@@ -694,75 +693,80 @@ end |
694 | 693 | __e2setcost(5) |
695 | 694 |
|
696 | 695 | e2function number entity:ping() |
697 | | - if not IsValid(this) then return 0 end |
698 | | - if(this:IsPlayer()) then return this:Ping() else return 0 end |
| 696 | + if not IsValid(this) then return self:throw("Invalid entity!", 0) end |
| 697 | + if not this:IsPlayer() then return self:throw("Expected a Player, got Entity!", 0) end |
| 698 | + return this:Ping() |
699 | 699 | end |
700 | 700 |
|
701 | 701 | e2function number entity:timeConnected() |
702 | | - if not IsValid(this) then return 0 end |
703 | | - if(this:IsPlayer()) then return this:TimeConnected() else return 0 end |
| 702 | + if not IsValid(this) then return self:throw("Invalid entity!", 0) end |
| 703 | + if not this:IsPlayer() then return self:throw("Expected a Player, got Entity!", 0) end |
| 704 | + return this:TimeConnected() |
704 | 705 | end |
705 | 706 |
|
706 | 707 | e2function entity entity:vehicle() |
707 | | - if not IsValid(this) then return nil end |
708 | | - if not this:IsPlayer() then return nil end |
| 708 | + if not IsValid(this) then return self:throw("Invalid entity!", NULL) end |
| 709 | + if not this:IsPlayer() then return self:throw("Expected a Player, got Entity!", NULL) end |
709 | 710 | return this:GetVehicle() |
710 | 711 | end |
711 | 712 |
|
712 | 713 | e2function number entity:inVehicle() |
713 | | - if not IsValid(this) then return 0 end |
714 | | - return this:IsPlayer() and this:InVehicle() and 1 or 0 |
| 714 | + if not IsValid(this) then return self:throw("Invalid entity!", 0) end |
| 715 | + if not this:IsPlayer() then return self:throw("Expected a Player, got Entity!", 0) end |
| 716 | + return this:InVehicle() and 1 or 0 |
715 | 717 | end |
716 | 718 |
|
717 | 719 | --- Returns 1 if the player <this> is in noclip mode, 0 if not. |
718 | 720 | e2function number entity:inNoclip() |
719 | | - if not IsValid(this) or this:GetMoveType() ~= MOVETYPE_NOCLIP then return 0 end |
720 | | - return 1 |
| 721 | + if not IsValid(this) then return self:throw("Invalid entity!", 0) end |
| 722 | + return this:GetMoveType() == MOVETYPE_NOCLIP and 1 or 0 |
721 | 723 | end |
722 | 724 |
|
723 | 725 | e2function number entity:inGodMode() |
724 | | - return IsValid(this) and this:IsPlayer() and this:HasGodMode() and 1 or 0 |
| 726 | + if not IsValid(this) then return self:throw("Invalid entity!", 0) end |
| 727 | + if not this:IsPlayer() then return self:throw("Expected a Player, got Entity!", 0) end |
| 728 | + return this:HasGodMode() and 1 or 0 |
725 | 729 | end |
726 | 730 |
|
727 | 731 | -------------------------------------------------------------------------------- |
728 | 732 |
|
729 | | -local player = player |
730 | | - |
731 | 733 | __e2setcost(10) |
732 | 734 |
|
733 | 735 | e2function array players() |
734 | 736 | return player.GetAll() |
735 | 737 | end |
736 | 738 |
|
737 | 739 | e2function array playersAdmins() |
738 | | - local Admins = {} |
739 | | - for _,ply in ipairs(player.GetAll()) do |
740 | | - if (ply:IsAdmin()) then |
741 | | - table.insert(Admins,ply) |
| 740 | + local admins = {} |
| 741 | + |
| 742 | + for _, ply in ipairs(player.GetAll()) do |
| 743 | + if ply:IsAdmin() then |
| 744 | + table.insert(admins, ply) |
742 | 745 | end |
743 | 746 | end |
744 | | - return Admins |
| 747 | + |
| 748 | + return admins |
745 | 749 | end |
746 | 750 |
|
747 | 751 | e2function array playersSuperAdmins() |
748 | | - local Admins = {} |
749 | | - for _,ply in ipairs(player.GetAll()) do |
750 | | - if (ply:IsSuperAdmin()) then |
751 | | - table.insert(Admins,ply) |
| 752 | + local superadmins = {} |
| 753 | + |
| 754 | + for _, ply in ipairs(player.GetAll()) do |
| 755 | + if ply:IsSuperAdmin() then |
| 756 | + table.insert(superadmins, ply) |
752 | 757 | end |
753 | 758 | end |
754 | | - return Admins |
| 759 | + |
| 760 | + return superadmins |
755 | 761 | end |
756 | 762 |
|
757 | 763 | -------------------------------------------------------------------------------- |
758 | 764 |
|
759 | 765 | e2function entity entity:aimEntity() |
760 | | - if not IsValid(this) then return self:throw("Invalid entity!", nil) end |
761 | | - if not this:IsPlayer() then return self:throw("Expected a Player, got Entity", nil) end |
| 766 | + if not IsValid(this) then return self:throw("Invalid entity!", NULL) end |
| 767 | + if not this:IsPlayer() then return self:throw("Expected a Player, got Entity", NULL) end |
762 | 768 |
|
763 | | - local ent = this:GetEyeTraceNoCursor().Entity |
764 | | - if not ent:IsValid() then return nil end |
765 | | - return ent |
| 769 | + return this:GetEyeTraceNoCursor().Entity |
766 | 770 | end |
767 | 771 |
|
768 | 772 | e2function vector entity:aimPos() |
|
0 commit comments