• Noclip Console Error but Script works
    2 replies, posted
Hey dear readers, i use a automatic cloak feature when player is in noclip he gets cloaked the script works but on my server console i got a error. here the script: local function NoclipThink() for k,v in ipairs(player.GetAll()) do local oldstate = v:GetMoveType() local CamIsOn = v:GetNWBool("CamoEnabled") local wep = v:GetActiveWeapon() if CamIsOn then return end if oldstate == MOVETYPE_NOCLIP and not v:InVehicle()then v:DrawShadow( false ) v:SetMaterial( "models/effects/vol_light001" ) wep:SetMaterial("models/effects/vol_light001") wep:SetColor( Color( 0, 0, 0, 0 ) ) --v:SetNoDraw(true) wep:DrawShadow( false ) v:SetRenderMode( RENDERMODE_TRANSALPHA ) wep:SetRenderMode( RENDERMODE_TRANSALPHA ) v:SetColor( Color( 0, 0, 0, 0 ) ) v:GetTable().invis = { vis=visibility, wep=v:GetActiveWeapon() } else v:DrawShadow( true ) v:SetMaterial( "" ) if wep then wep:SetMaterial( "" ) end v:SetRenderMode( RENDERMODE_NORMAL ) wep:SetRenderMode( RENDERMODE_NORMAL ) v:SetColor( Color( 255, 255, 255, 255 ) ) wep:DrawShadow( true ) wep:SetColor( Color( 255, 255, 255, 255 ) ) v:GetTable().invis = nil --v:SetNoDraw(false) end end end hook.Add( "Think", "NoClipThinkHook", NoclipThink ) (Im not using SetNoDraw cuz when i call it in the think hook i got to ragdoll models if a player use /sleep or !ragdoll) here the error: [ERROR] addons/special_scripts/lua/autorun/server/noclip.lua:28: Tried to use a NULL entity! 1. SetMaterial - [C]:-1 2. fn - addons/special_scripts/lua/autorun/server/noclip.lua:28 3. unknown - addons/ulib-master/lua/ulib/shared/hook.lua:109 sometimes this error appears other times not. (Line 28 is the wep:SetMaterial) I guess it appears when i dont have a weapon in the hand without a model... how i need to modify this that he return false the wep when it dont have a weapon model thanks alot
Try checking if the wep is valid, might help fix it. if IsValid( wep ) then wep:SetMaterial( "" ) end
Looks great i need to add it in the upper part of the code, too otherwise i dont get cloaked when i dont have weapons^^ like !strip ^ thank you
Sorry, you need to Log In to post a reply to this thread.