Need help with buying a door script

I used this and it gives me the error to my console http://wiki.garrysmod.com/?title=Entity.SetNetworkedEntity
[lua]
includes\util.lua:168: attempt to call method ‘IsValid’ (a nil value)[/lua]

Yes i have got an hud for the door ect just need help fixing this…

may help if you tell us what line 168 is

You do know util.lua is already in garrysmod by default… so its called from that lua it self… the one i posted a link to!

Note: If anyone can fix this ill make a Climb Gamemode like sassilization, and Release it…

  1. We don’t need another climb gamemode
  2. You’re not passing an entity into SetNetworkedEntity

If you know what you are talking about give me an example, because i am pretty sure i know what i’m doing…

Just because people like you don’t want another climb gamemode because you can’t code doesn’t mean others don’t want a climb gamemode.

We can’t help you if you post the line from YOUR script. So obviously you didn’t know what you were doing.

[lua]function OwnDoor(ply, cmd, args)
local trace = ply:GetEyeTrace() – define a name for where the player is aiming
if ( trace.Entity:IsValid() and trace.Entity:GetClass() == “prop_door_rotating” ) then – This line is the error for you idiots if you didn’t know…
if !ValidEntity( trace.Entity:GetNetworkedEntity( “owner” ) ) then – check if the entitys NWEntity has been Set already…
trace.Entity:SetNWString( “owner”, ply ) – Set the NWEntity to ply
if( ply:GetNWInt(“money”) >= 50 ) then – Check weather or not the player can afford to pay for this door.
ply:SetNWInt(“money”, ply:GetNWInt( “money” ) - 50 ) – Deduct the money from the player if he/she can afford it…
end
end
end
end
concommand.Add(“ownthisdoor”, OwnDoor )
[/lua]

Self explanatory look there next time…

I’m not joking, whatever you’re giving SetNetworkedEntity, it’s obviously not a valid entity, or IsValid would be in its metatable.

I didn’t make this code so give an example if you know lua…

Fixed, i am using a different way.

Lock this thread please mod

Gbps Sorry you don’t know lua, stop being unhelpful to people.

You do know you fucked up the line that was giving you issues? it’s not a problem with the util.lua file.



    if ( trace.Entity:IsValid() and trace.Entity:GetClass() == "prop_door_rotating" ) then
        // do stuff
    end


You still check the class of the entity, regardless of if it’s valid or not (this will give an error if the entity is not valid). It should be:



if ( trace.Entity:IsValid() ) then
        if ( trace.Entity:GetClass() == "prop_door_rotating" ) then
                // do stuff
        end
end


No offence, but your code made me want to kill myself Octogon.

Not only are you failing epically at tabbing, but you set a NWString as an entity.

Agreed… You should have used GetViewEntity as well, because it’s much more efficient than running a trace.

Retard, it wasn’t my code… you make me want to kill my self i said lock so i wouldn’t get flamed by a stupid twat like you.

I have coded it a different way now… Should’ve put you both on my ignore/troll list ages ago

|FlapJack| you are the biggest faggot in the world, who likes to piss people off constantly, hey you should act your age and ignore FIXED threads, and Help other people not FUCKING FLAME YOU TWAT enough said.


(User was permabanned for this post ("Flaming" - grea$emonkey))

Hi Cube.

I helped you by telling you your coding style needs improving. No need to wear your ovaries on the outside.

<Insert bannable meme related to value here>

Flaming the community that you’re asking help from isn’t a very bright idea.

Wait, I don’t know Lua? But I think I do… Does that mean that if I don’t know Lua but I really do, it will create a rip in space and engulf the entire universe until it’s the size of a 1cm x 1cm x 1cm block of carbon? Then what?

I apologize, boredom overrides logical thinking processes.

Lol, flapjack and everyone sent him to the edge.

Cooooombo ban to come lol.

no one sent him to the edge he was here to troll from day one