Py. Gunning cars

Hello, my name is Lex Umbram and or Sir Joe. I work on a server are a lua developer. Now the question is how in the name of all thing do I make it so I can pick up cars?

Now I did a lot of resurrect and found this:

From:http://forum.facepunch.com/showthread.php?t=1299097
This worked, but I had problems like I can pick up doors and I only want Superadmin and up to do it. My ranks are: (user>trusted>tmod>mod>admin>headadmin>superadmin>Communitymanager>developer>co-owner>owner

I can as of now with out the code above pick up perma-props, that is fine, I just dont want to be able to pick up doors.

make an table containing the allowed groups, and check if the players rank is in the table.

Edit:
Make the same with entities you want to be able to be picked up.

Could you explain more. I am newer to ulx.

it has nothing to do with ulx at all, if you develop for an server, you should know how to do such an simple task… I’ll give you an example code.

[editline]27th September 2015[/editline]



local groups = {
	"superadmin" 	= true,
	"developer" 	= true,
	"WhiteKitty" 	= true,
	"Garry" 		= true
}

-- check if the players group is in the table(allowed)

if groups[ply:GetUserGroup()] then
	-- do your shit here
end


and the same for the entities you want to be allowed.

Should I add this to my code above? So


local function PhysgunPickup(ply, ent)
--If the player is an admin, and the entity is a door or a player,
if ply:IsAdmin() and (ent:GetClass():lower() == "func_door" or ent:GetClass():lower() == "player") then
return false -- Deny pickup
elseif ply:IsSuperAdmin() then
return true
end
end

hook.Add("PhysgunPickup", "Physgun.DenyShit", PhysgunPickup)

local groups = {
	"superadmin" 	= true,
	"developer" 	= true,
	"owner" 	= true,
	"co-owner" 		= true,
}

--check if the players group is in the table(allowed)

if groups[ply:GetUserGroup()] then
	--do your shit here
end

Sorry I mostly do jobs. This is out of my league

Oh. My. God. If you “MOSTLY” do DarkRP Jobs, then you AINT an developer AT ALL >-<
Let me spoonfeed you the code…

Mate, I am sorry if you feel that way. I never said I was any good at coding, I just said I did it.

Part of the problem is no one is willing to lend time to teach you any thing.



local function cheekycuntspickingshitup(ply, ent)
if (ent:GetClass():lower() == "func_door" or ent:GetClass():lower() == "player") and ply:IsSuperAdmin() then return true end
end

hook.Add("PhysgunPickup", "uwotm8", cheekycuntspickingshitup)


your in a hook, you only need to return true if the player is super so that they can pick stuff up, don’t return anything at all for other players as they already can’t pick up doors and players by default
you also had it before where it would only block admins from picking that stuff up but would return true for regular users



local groups = {
	"superadmin" 	= true,
	"developer" 	= true,
	"WhiteKitty" 	= true,
	"Garry" 		= true,
}

function VehiclePickupForStaff( ply, ent )
	if groups[ply:GetUserGroup()] and ent:IsVehicle() then
		return true
	end
end
hook.Add("PhysgunPickup", "Vehicle_Pickup_for_staff", VehiclePickupForStaff)


About the teaching shit, read the stickies, that helps for newbies, its not hard to learn GLua, since its an really simple language, sadly MrCosmicSeagull is gone.

[editline]27th September 2015[/editline]

god tabbing in the code tag is shit

So do I just add any v. to it I want?

Just use THIS code:



local groups = {
	"superadmin" 	= true,
	"developer" 	= true,
	"WhiteKitty" 	= true,
	"Garry" 		= true,
}

function VehiclePickupForStaff( ply, ent )
	if groups[ply:GetUserGroup()] and ent:IsVehicle() then
		return true
	end
end
hook.Add("PhysgunPickup", "Vehicle_Pickup_for_staff", VehiclePickupForStaff)


Thanks for the help.
So:


local groups = {
	"superadmin" 	= true,
	"developer" 	= true,
	"owner" 	= true,
	"co-owner" 		= true,
}
local _ents = {
	"jeep" 			= true,
	"Seat_Airboat" 	= true,
	"Chair_Office2" = true,
	"phx_seat"		= true,
	"Chair_Plastic" = true,
	"Seat_Jeep"		= true,
	"Chair_Office1"	= true,
	"Chair_Wood"	= true,
	"Airboat"		= true,
	"Pod"			= true,
	"airtugtdm"		= true,
	"porcycletdm"	= true,
}

function VehiclePickupForStaff( ply, ent )
	if groups[ply:GetUserGroup()] and _ents[ent:GetClass()] then
		return true
	end
end
hook.Add("PhysgunPickup", "Vehicle_Pickup_for_staff", VehiclePickupForStaff)

Will this work, and should I just put this in the autorun file and name it ____.lua

just use the upper code, and put it into autorun as sh_shitvehicles.lua >-<

upper code?



local groups = {
	"superadmin" 	= true,
	"developer" 	= true,
	"WhiteKitty" 	= true,
	"Garry" 		= true,
}

function VehiclePickupForStaff( ply, ent )
	if groups[ply:GetUserGroup()] and ent:IsVehicle() then
		return true
	end
end
hook.Add("PhysgunPickup", "Vehicle_Pickup_for_staff", VehiclePickupForStaff)


or this:



local groups = {
	"superadmin" 	= true,
	"developer" 	= true,
	"WhiteKitty" 	= true,
	"Garry" 		= true,
}

function VehiclePickupForStaff( ply, ent )
	if groups[ply:GetUserGroup()] and ent:IsVehicle() then
		return true
	end
end
hook.Add("PhysgunPickup", "Vehicle_Pickup_for_staff", VehiclePickupForStaff)


or that one:



local groups = {
	"superadmin" 	= true,
	"developer" 	= true,
	"WhiteKitty" 	= true,
	"Garry" 		= true,
}

function VehiclePickupForStaff( ply, ent )
	if groups[ply:GetUserGroup()] and ent:IsVehicle() then
		return true
	end
end
hook.Add("PhysgunPickup", "Vehicle_Pickup_for_staff", VehiclePickupForStaff)


Here goes nothing. And again thanks, not sure it working yet but.

[editline]27th September 2015[/editline]

Nope. Did not work.

try using prints inside the if check, to see if it works.

As you said I am a newbie. Is there a video or a idiots guide to how to do simple code?

just put print(“Hai”) above “return true”. and check your console when you try to pickup cars.

So:


local groups = {
	"superadmin" 	= true,
	"developer" 	= true,
	"WhiteKitty" 	= true,
	"Garry" 		= true,
}

function VehiclePickupForStaff( ply, ent )
	if groups[ply:GetUserGroup()] and ent:IsVehicle() then (hai)
		return true
	end
end
hook.Add("PhysgunPickup", "Vehicle_Pickup_for_staff", VehiclePickupForStaff)