• Need help with script !
    3 replies, posted
Hello ! Yesterday i have written 2 scripts whitch should disable CARS pickup. Unfortunatelly players can physgun players now and i dont know how to fix it. If someone can please edit my scrips. [CODE]function CarNoPickup( ply, ent ) if IsValid( ent ) && ent:IsVehicle() && not ply:IsAdmin() then return false else return true end end hook.Add( "PhysgunPickup", "CarNoPickup", CarNoPickup)[/CODE] [CODE]function CarNoPickup( ply, ent ) if IsValid( ent ) && !ply:IsAdmin() && ent:IsVehicle() || ent:IsPlayer() then return false --[[ elseif IsValid( ent ) && !ply == ent:GetOwner() then return false]]-- end end hook.Add( "PhysgunPickup", "CarNoPickup", CarNoPickup) [/CODE]
Return true for what they can pick up, otherwise return false; you're allowing pretty much everything with your else return true method.. So if the entity isn't valid, return false right away. If the entity is a vehicle and the player is an admin then return true for all other cases return false -- UNLESS you have a different script which manages props, then don't return anything.
[url]http://pastebin.com/JJu9g2ip[/url] hm
When you are extending a utility / permission hook, only return values for what you're trying to achieve. By globally returning false, it won't allow them to pick up regular props. -- With that, you're returning true for many things which shouldn't even be touched by the hook requirements... [lua]hook.Add( "PhysgunPickup", "PhysgunPickup:HandleVehiclePickup", function( _p, _ent ) // We should never be able to pickup an invalid entity, so this return false is fine. if ( !IsValid( _ent ) ) then return false; end // Now, we only want admins to pick up vehicles if ( _p:IsAdmin( ) && _ent:IsVehicle( ) ) then return true; end // Leave anything else in this blank; the reason is because there may be other hook.Adds which handle player pickup, etc... end );[/lua]
Sorry, you need to Log In to post a reply to this thread.