This used to work just fine until I edited it, once I edited it and I saw an error I simply reverted the changes and restarted but now it doesn't work. I get no errors or anything, it's just not working properly. This is a script to allow people (DarkRP) to physgun entities they purchase. As I said earlier, it worked just fine until I fucked it. This is the original version.
[CODE]function EOTI_PlayerPickup(ply, ent)
if (ent:GetOwner() == ply
or ent:GetNWEntity("owner") == ply)
then return true end
end
function EOTI_SetOwner(ply,tbl,ent)
if ent:GetNWEntity("owner") == "[NULL ENTITY]" then return end
ent:SetNWEntity( "owner" , ply )
end
function EOTI_SetOwnerVehicle(ply,ent)
if ent:GetNWEntity("owner") == "[NULL ENTITY]" then return end
ent:SetNWEntity( "owner" , ply )
end
hook.Add( "playerBoughtCustomEntity", "EOTI_SpawnPropOwner", EOTI_SetOwner )
hook.Add( "playerBoughtCustomVehicle", "EOTI_SpawnPropOwner", EOTI_SetOwner )
hook.Add( "playerBoughtPistol", "EOTI_SpawnPropOwner", EOTI_SetOwner )
hook.Add( "playerBoughtShipment", "EOTI_SpawnPropOwner", EOTI_SetOwner )
hook.Add( "playerBoughtAmmo", "EOTI_SpawnPropOwner", EOTI_SetOwner )
hook.Add( "playerBoughtVehicle", "EOTI_SpawnPrVehicle", EOTI_SetOwnerVehicle )
hook.Add("PhysgunPickup", "EOTI_PhysgunAllItem", EOTI_PlayerPickup )[/CODE]
If this helps, with out this installed on the server when you physgun an entity it just swoops across it like you're not touching anything however when I install it and physgun an entity it looks like the beam drags across the entity as if it's gonna grab it.
It appears you are trying to null a global value. I ran it through a lua checker and the error that came up was "input:17: attempt to index a nil value (global 'hook')"
I used [URL="http://www.lua.org/demo.html"]http://www.lua.org/demo.html[/URL] to test the code. I'd google it and look around.
[QUOTE=jmd7231;49155078]It appears you are trying to null a global value. I ran it through a lua checker and the error that came up was "input:17: attempt to index a nil value (global 'hook')"
I used [URL="http://www.lua.org/demo.html"]http://www.lua.org/demo.html[/URL] to test the code. I'd google it and look around.[/QUOTE]
The hook library doesn't exist in default Lua, but it does in gmod's lua (gLua).
Also, if that is the original version of the code before you 'fucked it up', then what does the fucked up version look like?
[CODE]function EOTI_PlayerPickup(ply, ent)
if (ent:GetOwner() == ply
or ent:GetNWEntity("owner") == ply
or ent:Getowning_ent() == ply) -- THIS LINE RIGHT HERE, that's all I edited
then return true end
end
function EOTI_SetOwner(ply,tbl,ent)
if ent:GetNWEntity("owner") == "[NULL ENTITY]" then return end
ent:SetNWEntity( "owner" , ply )
end
function EOTI_SetOwnerVehicle(ply,ent)
if ent:GetNWEntity("owner") == "[NULL ENTITY]" then return end
ent:SetNWEntity( "owner" , ply )
end
hook.Add( "playerBoughtCustomEntity", "EOTI_SpawnPropOwner", EOTI_SetOwner )
hook.Add( "playerBoughtCustomVehicle", "EOTI_SpawnPropOwner", EOTI_SetOwner )
hook.Add( "playerBoughtPistol", "EOTI_SpawnPropOwner", EOTI_SetOwner )
hook.Add( "playerBoughtShipment", "EOTI_SpawnPropOwner", EOTI_SetOwner )
hook.Add( "playerBoughtAmmo", "EOTI_SpawnPropOwner", EOTI_SetOwner )
hook.Add( "playerBoughtVehicle", "EOTI_SpawnPrVehicle", EOTI_SetOwnerVehicle )
hook.Add("PhysgunPickup", "EOTI_PhysgunAllItem", EOTI_PlayerPickup )[/CODE]
[code]
if ent:GetNWEntity("owner") == "[NULL ENTITY]" then return end[/code]
No, please no. PLEASE.
[code]if !IsValid( ent:GetNWEntity("owner") ) then return end[/code]
P L E A S E.
[QUOTE=Robotboy655;49155377][code]
if ent:GetNWEntity("owner") == "[NULL ENTITY]" then return end[/code]
No, please no. PLEASE.
[code]if !IsValid( ent:GetNWEntity("owner") ) then return end[/code]
P L E A S E.[/QUOTE]
I'll make sure to adjust it, thanks for the tip. In the mean time, any solutions?
That is the solution
[QUOTE=geferon;49155630]That is the solution[/QUOTE]
Sadly this didn't fix it, it's just another (better) way of doing what the original code does.
[QUOTE=TheTechPony;49156031]Sadly this didn't fix it, it's just another (better) way of doing what the original code does.[/QUOTE]
Did you try it though?
By the way, I have no clue what the solution is since I can't test this
[QUOTE=MPan1;49156103]Did you try it though?
By the way, I have no clue what the solution is since I can't test this[/QUOTE]
Yes I did try it. I've restarted as well just to make sure. I don't get any errors and I don't understand why it's not working. If the code checks out and everything I'll just assume it's a glitch in source mod or something because as I said earlier, it worked until I changed the code and I reverted it within 2 minutes of breaking it and now it's just dead.
[QUOTE=TheTechPony;49156114]Yes I did try it. I've restarted as well just to make sure. I don't get any errors and I don't understand why it's not working. If the code checks out and everything I'll just assume it's a glitch in source mod or something because as I said earlier, it worked until I changed the code and I reverted it within 2 minutes of breaking it and now it's just dead.[/QUOTE]
Put some prints in different parts of the code and else to see if it works.
Also, it might just be that the hooks changed
Sorry, you need to Log In to post a reply to this thread.