Hey guys,
I am personally not a huge fan of the PERP gamemode, but I am trying to at least get the god_stick working for sandbox,
I am having issues with it, I think due to the fact it still may be coded for the old GMOD.
Here's a link to a zip with the folder for the weapon, if you guys could have a look at it and help me out with code, would be greatly appreciated.
[url]http://www.mediafire.com/?6zm1t7ck1laf2ya[/url]
Can't you just post the code here? Unless there's a huge amount of files of cause.
[LUA]//Dont Tuch anything or you destroy it!
if( SERVER ) then
AddCSLuaFile( "shared.lua" )
end
if( CLIENT ) then
SWEP.PrintName = "GOD STICK"
SWEP.Slot = 0
SWEP.SlotPos = 5
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
end
//Variables that are used on both client and server
SWEP.Author = "?"
SWEP.Instructions = "Left click to fire, right click to change"
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.AnimPrefix = "stunstick"
SWEP.Spawnable = false
SWEP.AdminSpawnable = true
SWEP.NextStrike = 0
SWEP.ViewModel = Model( "models/weapons/v_stunstick.mdl" )
SWEP.WorldModel = Model( "models/weapons/w_physics.mdl" )
SWEP.Sound = Sound( "weapons/physcannon/physcannon_dryfire.wav" )
SWEP.Sound1 = Sound( "npc/metropolice/vo/moveit.wav" )
SWEP.Sound2 = Sound( "npc/metropolice/vo/movealong.wav" )
SWEP.Primary.ClipSize = -1 //Size of a clip
SWEP.Primary.DefaultClip = 0 //Default number of bullets in a clip
SWEP.Primary.Automatic = false //Automatic/Semi Auto
SWEP.Primary.Ammo = ""
SWEP.Secondary.ClipSize = -1 //Size of a clip
SWEP.Secondary.DefaultClip = 0 //Default number of bullets in a clip
SWEP.Secondary.Automatic = false //Automatic/Semi Auto
SWEP.Secondary.Ammo = ""
/*---------------------------------------------------------
Name: SWEP:Initialize()
Desc: Called when the weapon is first loaded
---------------------------------------------------------*/
function SWEP:Initialize()
if SERVER then
self.Gear = 1
end
self:SetWeaponHoldType( "physgun" )
end
local SLAP_SOUNDS = {
"physics/body/body_medium_impact_hard1.wav",
"physics/body/body_medium_impact_hard2.wav",
"physics/body/body_medium_impact_hard3.wav",
"physics/body/body_medium_impact_hard5.wav",
"physics/body/body_medium_impact_hard6.wav",
"physics/body/body_medium_impact_soft5.wav",
"physics/body/body_medium_impact_soft6.wav",
"physics/body/body_medium_impact_soft7.wav"
}
/*---------------------------------------------------------
Name: SWEP:Precache()
Desc: Use this function to precache stuff
---------------------------------------------------------*/
function SWEP:Precache()
end
function SWEP:DoFlash( ply )
--umsg.Start( "StunStickFlash", ply ); umsg.End()
end
function SWEP:DrawHUD()
surface.SetDrawColor(Color(0, 255, 0, 200))
surface.DrawLine(ScrW() * 0.5 - 5, ScrH() * 0.5, ScrW() * 0.5 + 6, ScrH() * 0.5)
surface.DrawLine(ScrW() * 0.5, ScrH() * 0.5 - 5, ScrW() * 0.5, ScrH() * 0.5 + 6)
end
local Gears = {}
/*---------------------------------------------------------
Name: SWEP:PrimaryAttack()
Desc: +attack1 has been pressed
---------------------------------------------------------*/
function SWEP:PrimaryAttack()
if( CurTime() < self.NextStrike ) then return; end
if !self.Owner:IsAdmin() then
self.Owner:StripWeapon(self.Weapon:GetClass())
return false
end
self.Owner:SetAnimation( PLAYER_ATTACK1 )
local r, g, b, a = self.Owner:GetColor()
if a != 0 then
self.Weapon:EmitSound( self.Sound )
end
self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
self.NextStrike = ( CurTime() + .3 )
if( CLIENT ) then return; end
local trace = self.Owner:GetEyeTrace()
local Gear = self.Owner:GetTable().CurGear or 1
if Gears[Gear][3] and !self.Owner:IsSuperAdmin() then
self.Owner:Notify("This gear requires Super Admin status.")
return false
end
Gears[Gear][4](self.Owner, trace)
end
local function AddGear ( Title, Desc, SA, Func )
table.insert(Gears, {Title, Desc, SA, Func})
end
AddGear("Lern Player sum English!", "Aim at a player to learn him some english.", false,
function ( Player, Trace )
if IsValid(Trace.Entity) and Trace.Entity:IsPlayer() then
if Trace.Entity:IsPlayer() and (Trace.Entity:IsOwner() or (Trace.Entity:IsSuperAdmin() and not Player:IsOwner()) or (Trace.Entity:IsAdmin() and not Player:IsSuperAdmin())) then
Player:PrintMessage(HUD_PRINTTALK, "This player has the same or a better rank than you, you can't do this.")
return
end
Trace.Entity:EmitSound("learnenglish.mp3")
Player:PrintMessage(HUD_PRINTTALK, "Lernt playar to speek englisch.")
end
end
)
AddGear("Kill Player", "Aim at a player to slay him.", false,
function ( Player, Trace )
if IsValid(Trace.Entity) and Trace.Entity:IsPlayer() then
if Trace.Entity:IsPlayer() and (Trace.Entity:IsOwner() or (Trace.Entity:IsSuperAdmin() and not Player:IsOwner()) or (Trace.Entity:IsAdmin() and not Player:IsSuperAdmin())) then
Player:PrintMessage(HUD_PRINTTALK, "This player has the same or a better rank than you, you can't do this.")
return
end
Trace.Entity:Kill()
Player:PrintMessage(HUD_PRINTTALK, "Player killed.")
end
end
)
AddGear("Slap Player", "Aim at an entity to slap him.", false,
function ( Player, Trace )
if !Trace.Entity:IsPlayer() then
local RandomVelocity = Vector( math.random(5000) - 2500, math.random(5000) - 2500, math.random(5000) - (5000 / 4 ) )
local RandomSound = SLAP_SOUNDS[ math.random(#SLAP_SOUNDS) ]
Trace.Entity:EmitSound( RandomSound )
Trace.Entity:GetPhysicsObject():SetVelocity( RandomVelocity )
Player:PrintMessage(HUD_PRINTTALK, "Entity slapped.")
else
if Trace.Entity:IsPlayer() and (Trace.Entity:IsOwner() or (Trace.Entity:IsSuperAdmin() and not Player:IsOwner()) or (Trace.Entity:IsAdmin() and not Player:IsSuperAdmin())) then
Player:PrintMessage(HUD_PRINTTALK, "This player has the same or a better rank than you, you can't do this.")
return
end
local RandomVelocity = Vector( math.random(500) - 250, math.random(500) - 250, math.random(500) - (500 / 4 ) )
local RandomSound = SLAP_SOUNDS[ math.random(#SLAP_SOUNDS) ]
Trace.Entity:EmitSound( RandomSound )
Trace.Entity:SetVelocity( RandomVelocity )
Player:PrintMessage(HUD_PRINTTALK, "Player slapped.")
end
end
)
AddGear("Super Slap Player", "Aim at an entity to super slap him.", false,
function ( Player, Trace )
if IsValid(Trace.Entity) then
if !Trace.Entity:IsPlayer() then
local RandomVelocity = Vector( math.random(50000) - 25000, math.random(50000) - 25000, math.random(50000) - (50000 / 4 ) )
local RandomSound = SLAP_SOUNDS[ math.random(#SLAP_SOUNDS) ]
Trace.Entity:EmitSound( RandomSound )
Trace.Entity:GetPhysicsObject():SetVelocity( RandomVelocity )
Player:PrintMessage(HUD_PRINTTALK, "Entity super slapped.")
else
if Trace.Entity:IsPlayer() and (Trace.Entity:IsOwner() or (Trace.Entity:IsSuperAdmin() and not Player:IsOwner()) or (Trace.Entity:IsAdmin() and not Player:IsSuperAdmin())) then
Player:PrintMessage(HUD_PRINTTALK, "This player has the same or a better rank than you, you can't do this.")
return
end
local RandomVelocity = Vector( math.random(5000) - 2500, math.random(5000) - 2500, math.random(5000) - (5000 / 4 ) )
local RandomSound = SLAP_SOUNDS[ math.random(#SLAP_SOUNDS) ]
Trace.Entity:EmitSound( RandomSound )
Trace.Entity:SetVelocity( RandomVelocity )
Player:PrintMessage(HUD_PRINTTALK, "Player super slapped.")
end
end
end
)
AddGear("Warn Player", "Aim at a player to warn him.", false,
function ( Player, Trace )
if IsValid(Trace.Entity) and Trace.Entity:IsPlayer() then
if Trace.Entity:IsPlayer() and (Trace.Entity:IsOwner() or (Trace.Entity:IsSuperAdmin() and not Player:IsOwner()) or (Trace.Entity:IsAdmin() and not Player:IsSuperAdmin())) then
Player:PrintMessage(HUD_PRINTTALK, "This player has the same or a better rank than you, you can't do this.")
return
end
Trace.Entity:Notify(
[lua] tags.
Edit your post instead of reposting the code.
Persious, that helped.
But now I'm getting this:
[ERROR] bad argument #2 to '?' (number expected, got no value)
1. unknown - [C]:-1
Timer Failed! [Simple][@gamemodes/sandbox/entities/weapons/god_stick/shared.lua (line 729)]
[ERROR] bad argument #2 to '?' (number expected, got no value)
1. unknown - [C]:-1
Timer Failed! [Simple][@gamemodes/sandbox/entities/weapons/god_stick/shared.lua (line 729)]
[ERROR] bad argument #2 to '?' (number expected, got no value)
1. unknown - [C]:-1
Timer Failed! [Simple][@gamemodes/sandbox/entities/weapons/god_stick/shared.lua (line 729)]Disconnect: "Too many Lua Errors! Sorry!".
D
Replace line 729 with
[lua]
timer.Simple( 0, function() gui.SetMousePos(110, 110) end)
[/lua]
Ok, now it's erroring when calling "IsOwner" when I try to run commands on it.
any idea what to replace with?
Replace line 143, 157, 178, 203, 221, 234, 246, 292, 306, 346, 424, 444, 472, 555 with
[lua]
if Trace.Entity:IsPlayer() and ((Trace.Entity():IsSuperAdmin() and not Player:IsOwner()) or (Trace.Entity:IsAdmin() and not Player:IsSuperAdmin())) then
[/lua]
That got rid of that, and now erroring when calling 'Entity'
Line?
it isn't referencing a line, just saying entity
Sorry, you need to Log In to post a reply to this thread.