Jump to content

Pilot License Script ]


Recommended Posts

Been a hot minute since I last touched Gmod LUA code so I decided to heat up the old printing press and make a fuck tone of  net.SendToServer safety compromises and began my vehicle license script.  Pretty much amazing top 10 script idea is that if you dont have a license you literally cannot enter a flying vehicle. I plan on expanding this to incorporate  different clearances, job exeptions (for ec's) and a fucking sexy VGUI menu where you can add vehichles to certain levels and possibly jobs to full access. I have no intention of forcing this on the server I've just been itching for some LUA lovin. Feedback and ideas are plenty welcome and im a dumbass so someone hit me up with the different licenses levels for ships before I cry. Shout out to legion and storm for answering my question in Chatbox

Here's #1 day progress into my fiasco 

Spoiler

Obviously the fact that chairs count as fucking ships is dumb ill fix this tommorow with the quick all vehichle:GetPrintName. Which will sort out the good boy planes from the naughty boy chairs.

Love u all xx, 

Regards Big zuck man Nana

  • Poggers 1
  • Upvote 1
Link to post
Share on other sites
10 hours ago, Theta said:

seems cool, but how would you train to get a Pilots License and complete the practical part of the test if you can't get in anything? unless you made a training license or something.

I’ll make a training license. Cheers big man xx

4 hours ago, Eclipse said:

Open source code is always pretty cool :)

hmmmmmmmmmmmm I’ll open source the code for ya big man. I’ll try and get it up today

1 hour ago, Storm said:

Quick question what about the transport ship when people need to get em them when they don't have a PL.

I’ll look into that but I believe I can specify the code so that only the pilots seat (which is usually seat no1. Is affected)

31 minutes ago, Splonter said:

I like the idea, although would not want it on the server as I feel it limits RP opportunity.

how so would it limit RP? Like arresting ships thief’s or something

Link to post
Share on other sites
54 minutes ago, Splonter said:

I feel it limits RP opportunity.

I think a Stormtrooper Private being able to hop into literally any vehicle and being able to pilot it with any level of competency isn't RP-friendly. This includes being able to start it moving, get it off the ground/up to speed and operate its weapons systems - all would require a specific knowledge on how to do so.

Even if a method isn't added that forcefully kicks somebody out of a vehicle, I reckon a feature should be added that increases the amount of swaying in flying vehicles have in the air and a speed decrease and weapons unreliability factor while in any vehicle. This would show the lack of control someone would have over the vehicle and it make it easier to stop and apprehend them. 

Edited by SCHEFF
  • Thinking 1
  • Agree 1
Link to post
Share on other sites

[IG] You do not have the correct pilot lisence license, [Name]. Please get the correct license first at the Imperial Starfighter Corps

[IG] You do not have a pilot lisence license, [Name]. Please apply for one at the Imperial Starfighter Corps.

 

With regards to the posts from Splonter and Chef, it's considered failRP if a fresh stormtrooper jumps in a tie and goes on a rampage. This however can be amended as soon as people (I.e Security) have a way of identifying pilots in a pilot seat, disabling a ship, and forcebally getting them out of the seat, cuffed.

Edited by Mauler
Link to post
Share on other sites
1 hour ago, Eclipse said:

For your chair issue:

if not (ENTITY.LFS or  ENTITY.IsSWVehicle = true) then return end

Thank u sexy beasy saves me from gmad extracting 20 fucking files till i understand their custom function names and cat's xx

5 minutes ago, Mauler said:

[IG] You do not have the correct pilot lisence license, [Name]. Please get the correct license first at the Imperial Starfighter Corps

[IG] You do not have a pilot lisence license, [Name]. Please apply for one at the Imperial Starfighter Corps.

 

With regards to the posts from Splonter and Chef, it's considered failRP if a fresh stormtrooper jumps in a tie and goes on a rampage. This however can be amended as soon as people (I.e Security) have a way of identifying pilots in a pilot seat, disabling a ship, and forcebally getting them out of the seat, cuffed.

Ill modify the text sexy man xx

 

Update on development

Spoiler

	local Pod = ((vehicle:GetParent()):GetDriverSeat())
	if (player:IsSuperAdmin()) and (vehicle == Pod) then

Side note I've changed the code so that it only affects pilot seats.  Note IsSuperAdmin is a place holder for license levels and GetDriverSeat is the big brain custom function of the LFS system. BTW for people who want to know i hate most SWRP entities with a raging passion because they dont use any fucking vehicle functions so theyre technically not a 'vehicle' in code which means ive gotta spend a hot minute looking for their big ol custom function.  So pretty much ily LFS dev xx

 

 

 

Link to post
Share on other sites
7 minutes ago, Nana_ said:

Thank u sexy beasy saves me from gmad extracting 20 fucking files till i understand their custom function names and cat's xx

Ill modify the text sexy man xx

 

Update on development

  Hide contents




	local Pod = ((vehicle:GetParent()):GetDriverSeat())
	if (player:IsSuperAdmin()) and (vehicle == Pod) then

Side note I've changed the code so that it only affects pilot seats.  Note IsSuperAdmin is a place holder for license levels and GetDriverSeat is the big brain custom function of the LFS system. BTW for people who want to know i hate most SWRP entities with a raging passion because they dont use any fucking vehicle functions so theyre technically not a 'vehicle' in code which means ive gotta spend a hot minute looking for their big ol custom function.  So pretty much ily LFS dev xx

 

 

 

Vehicles are actually wack in Gmod. They're still entities, and their vehicle parts are only used after they're created, but before their spawn.

Spoiler

local function MakeVehicle( ply, Pos, Ang, model, Class, VName, VTable, data )

	-- We don''t support this command from dedicated server console
	if ( !IsValid( ply ) ) then return end

	if ( !gamemode.Call( "PlayerSpawnVehicle", ply, model, VName, VTable ) ) then return end

	local Ent = ents.Create( Class )
	if ( !IsValid( Ent ) ) then return NULL end

	duplicator.DoGeneric( Ent, data )

	Ent:SetModel( model )

	-- Fallback vehiclescripts for HL2 maps ( dupe support )
	if ( model == "models/buggy.mdl" ) then Ent:SetKeyValue( "vehiclescript", "scripts/vehicles/jeep_test.txt" ) end
	if ( model == "models/vehicle.mdl" ) then Ent:SetKeyValue( "vehiclescript", "scripts/vehicles/jalopy.txt" ) end

	-- Fill in the keyvalues if we have them
	if ( VTable && VTable.KeyValues ) then
		for k, v in pairs( VTable.KeyValues ) do

			local kLower = string.lower( k )

			if ( kLower == "vehiclescript" or
				 kLower == "limitview"     or
				 kLower == "vehiclelocked" or
				 kLower == "cargovisible"  or
				 kLower == "enablegun" )
			then
				Ent:SetKeyValue( k, v )
			end

		end
	end

	Ent:SetAngles( Ang )
	Ent:SetPos( Pos )

	DoPropSpawnedEffect( Ent )

	Ent:Spawn()
	Ent:Activate()

	if ( Ent.SetVehicleClass && VName ) then Ent:SetVehicleClass( VName ) end
	Ent.VehicleName = VName
	Ent.VehicleTable = VTable

	-- We need to override the class in the case of the Jeep, because it
	-- actually uses a different class than is reported by GetClass
	Ent.ClassOverride = Class

	if ( IsValid( ply ) ) then
		gamemode.Call( "PlayerSpawnedVehicle", ply, Ent )
	end

	return Ent

end

 

A useful website for you would be workshopdownloader.io way better than using Gmad to extract addons.

Edited by Eclipse
Link to post
Share on other sites

Finished doing the allow chair thingo. I've learnt that simpfys dev's and the LFS devs are the same people and thats why the use identical function names that conflicted for me small pea brain. Anyways you can now sit in chairs. :O

hook.Add( "CanPlayerEnterVehicle", "vehicleperm", function( player, vehicle, role )
	local ENT = vehicle:GetParent()
	if (ENT.LFS) then
		local Pod = (ENT:GetDriverSeat())
		if (player:IsSuperAdmin()) and (vehicle == Pod) then
	      net.Start("NoPermission")
	      net.Send(player)
	      return false
	  end
	end
	if (ENT.IsSWVehicle) then
		if (player:IsSuperAdmin()) then
				net.Start("NoPermission")
				net.Send(player)
				return false
		end
	end
end)

I had to create two different functions cos the SW vehicle addon is the biggest ballsack in the history of my brain and theyre ghetto driving system will be implemented later. 

 

So right now we have: A system wich stops people from entering any LFS vehicles and some SW vehicles while letting you be still be in seats and passengers on such vehicles.  

Edited by Nana_
Link to post
Share on other sites
12 minutes ago, hypo said:

Why do you use a netstring at all for this?

Am i like not seeing the source code or somethin?

Yea thats a snippit of the code here is where it looks like rn its a bit messy still though. (server side)

util.AddNetworkString("NoPermission")

LICENSE = LICENSE or {}
LICENSE.Levels = LICENSE.Levels or {}

concommand.Add("license_add", function(ply, cmd, args)
	PrintTable(args)
end)

hook.Add( "CanPlayerEnterVehicle", "vehicleperm", function( player, vehicle, role )
	local ENT = vehicle:GetParent()
	if (ENT.LFS) then
		local Pod = (ENT:GetDriverSeat())
		if (player:IsSuperAdmin()) and (vehicle == Pod) then
	      net.Start("NoPermission")
	      net.Send(player)
	      return false
	  end
	end
	if (ENT.IsSWVehicle) then
		if (player:IsSuperAdmin()) then
				print(ENT)
				net.Start("NoPermission")
				net.Send(player)
				return false
		end
	end
end )

local lastmessage = 0
hook.Add( "PlayerUse", "SWVehicle?", function( ply, ent )
	if ent.IsSWVehicle then
		if CurTime() >= lastmessage then
			net.Start("NoPermission")
			net.Send(ply)
			lastmessage = CurTime() + 1
		end
		return false
	end
end )

and im using only serverside net code so client can get that sexy coloured text. the License table stuff ignore thats just place holding for the eventual json shit.  Finally got the SW vehichles to fucking work had to straight up disable the entity use because it doesnt actually put you into a vehicle it makes you a ghost and some weird shit dont ask me. 

Edited by Nana_
Link to post
Share on other sites
23 hours ago, Nana_ said:

Yea thats a snippit of the code here is where it looks like rn its a bit messy still though. (server side)


util.AddNetworkString("NoPermission")

LICENSE = LICENSE or {}
LICENSE.Levels = LICENSE.Levels or {}

concommand.Add("license_add", function(ply, cmd, args)
	PrintTable(args)
end)

hook.Add( "CanPlayerEnterVehicle", "vehicleperm", function( player, vehicle, role )
	local ENT = vehicle:GetParent()
	if (ENT.LFS) then
		local Pod = (ENT:GetDriverSeat())
		if (player:IsSuperAdmin()) and (vehicle == Pod) then
	      net.Start("NoPermission")
	      net.Send(player)
	      return false
	  end
	end
	if (ENT.IsSWVehicle) then
		if (player:IsSuperAdmin()) then
				print(ENT)
				net.Start("NoPermission")
				net.Send(player)
				return false
		end
	end
end )

local lastmessage = 0
hook.Add( "PlayerUse", "SWVehicle?", function( ply, ent )
	if ent.IsSWVehicle then
		if CurTime() >= lastmessage then
			net.Start("NoPermission")
			net.Send(ply)
			lastmessage = CurTime() + 1
		end
		return false
	end
end )

and im using only serverside net code so client can get that sexy coloured text. the License table stuff ignore thats just place holding for the eventual json shit.  Finally got the SW vehichles to fucking work had to straight up disable the entity use because it doesnt actually put you into a vehicle it makes you a ghost and some weird shit dont ask me. 

lastmessage should be depending on the player.

ply.ShipMessageCooldown = ply.ShipMessageCooldown or 0
if ply.ShipMessageCooldown < CurTime() then
	-- Gamer message code here
	net.Start("NoPermission")
	net.Send(ply)
	ply.ShipMessageCooldown = CurTime() + 5
end

 

Link to post
Share on other sites

Can you make it turn off under 20 players? I think some of the people who do the early morning messing around would be disappointed if they couldn't have their liteRP fun anymore

[EDIT] in the theoretical situation this was implemented, ofc

Edited by Tonberry
Link to post
Share on other sites
3 hours ago, Eclipse said:

lastmessage should be depending on the player.




ply.ShipMessageCooldown = ply.ShipMessageCooldown or 0
if ply.ShipMessageCooldown < CurTime() then
	-- Gamer message code here
	net.Start("NoPermission")
	net.Send(ply)
	ply.ShipMessageCooldown = CurTime() + 5
end

 

Thankyou sexy man completely passed my mind.

 

2 hours ago, Tonberry said:

Can you make it turn off under 20 players? I think some of the people who do the early morning messing around would be disappointed if they couldn't have their liteRP fun anymore

[EDIT] in the theoretical situation this was implemented, ofc

I’ll be adding a command to disable to licensing stuff and might add that as an extra disabled by default feature sexy man. 
 

As for an update my fucking dumb retard brain spent 4 hours figuring out how the hell tables work in Lua and getting it to save to a file. So pretty much the whitelist itself is like 60-70% done

Link to post
Share on other sites
11 minutes ago, Nana_ said:

Thankyou sexy man completely passed my mind.

 

I’ll be adding a command to disable to licensing stuff and might add that as an extra disabled by default feature sexy man. 
 

As for an update my fucking dumb retard brain spent 4 hours figuring out how the hell tables work in Lua and getting it to save to a file. So pretty much the whitelist itself is like 60-70% done

Why are you saving stuff to a file tho

Link to post
Share on other sites
7 minutes ago, Eclipse said:

Why are you saving stuff to a file tho

I’m saving the table which includes license groups: players in that group: vehicles that can be used by group. Its in the usual custom directory in data. And obviously if the group and people in the group aren’t being saved then there’s no whitelist. It also makes it easier to add new groups and add player to those groups and vehicles too.

Edited by Nana_
Link to post
Share on other sites
18 minutes ago, Nana_ said:

I’m saving the table which includes license groups: players in that group: vehicles that can be used by group. Its in the usual custom directory in data. And obviously if the group and people in the group aren’t being saved then there’s no whitelist. It also makes it easier to add new groups and add player to those groups and vehicles too.

I'm confused. Why not just have a table in a config file either referencing what ships a license can fly or what license are needed for a ship

license = {
	["NPL"] = {
		["ENTITYCLASSHERE"] = true
	},
	["BPL"] = {
		["ENTITYCLASSHERE"] = true
	}
}

-- or

license = {
	["ENTITYCLASSHERE"] = {
		["NPL"] = true,
		["BPL"] = true
	}
}

The reason we do ["THINGHERE"] = true is to make it more effiecent, instead of looping through a table to see if there is a value, we just index that table.

 

If you know big O notation:

Indexing a table has a big O notation of O(1) IIRC and  table.HasValue has an big O value of O(n)

Edited by Eclipse
Link to post
Share on other sites
3 hours ago, Eclipse said:

I'm confused. Why not just have a table in a config file either referencing what ships a license can fly or what license are needed for a ship



license = {
	["NPL"] = {
		["ENTITYCLASSHERE"] = true
	},
	["BPL"] = {
		["ENTITYCLASSHERE"] = true
	}
}

-- or

license = {
	["ENTITYCLASSHERE"] = {
		["NPL"] = true,
		["BPL"] = true
	}
}

The reason we do ["THINGHERE"] = true is to make it more effiecent, instead of looping through a table to see if there is a value, we just index that table.

 

If you know big O notation:

Indexing a table has a big O notation of O(1) IIRC and  table.HasValue has an big O value of O(n)

Ok this makes a lot more sense but because I have a small pea brain I’ve never considered it until now. Correct me if I’m wrong o(1) is better then O(n) for efficiency and that and by table.HasValue you mean doing the whole fucking loop through all the values.

Edit: Wait no what I was doing was fine because when I say add vehichles too the license I dont mean by going into the actual code to change it I mean like having a command in game to add a vehicle to a license and it doesnt seem like i can add a variable to the list and have it save on server stopages. 

Edited by Nana_
Link to post
Share on other sites
7 hours ago, Nana_ said:

Ok this makes a lot more sense but because I have a small pea brain I’ve never considered it until now. Correct me if I’m wrong o(1) is better then O(n) for efficiency and that and by table.HasValue you mean doing the whole fucking loop through all the values.

Edit: Wait no what I was doing was fine because when I say add vehichles too the license I dont mean by going into the actual code to change it I mean like having a command in game to add a vehicle to a license and it doesnt seem like i can add a variable to the list and have it save on server stopages. 

I meant hard coding it because it wouldn't change often, having 9t hard stores 9m a table is the most effecient way. 

but if you want to store it somewhere and are up for a bit of challange you should look onto SQLite

https://wiki.facepunch.com/gmod/sql

Link to post
Share on other sites

i dont care for code im not a nerd xD, but i would like to know how this would be implemented considering the wide range of vehicles and ISC in general. Unlike the rest of the server ISC have a different PL system im happy to DM you it if you would like. + not to mention ISC-CMD use the TIE/D and TIE/DE with an EPL that is the problem, unlike most Maj Gens ISC-CMD has access to ALL vehicles whereas generals dont.... Same with general ISC we have a large range of vehicles we can use even cadets (Again i can send the doc). Just 1 last thing... what about ppl trying out for ISC? they have no pl sometimes (majority) and due to this code wouldnt be able to unless given e.g an NPL theta brought it up with our PL tests as well we test the ppl on vehicles they dont have the license for so idk man. Either way GL i do like this 

Edited by Angus
Link to post
Share on other sites
5 hours ago, Eclipse said:

I meant hard coding it because it wouldn't change often, having 9t hard stores 9m a table is the most effecient way. 

but if you want to store it somewhere and are up for a bit of challange you should look onto SQLite

https://wiki.facepunch.com/gmod/sql

It’s true it wouldn’t change much I just want to setup a changeable system is all so that invade something really needs to happen or in some rare case an em or whoever can just do a command and then they’re all good to add or remove vehicles and their players. 
I was looking at another whitelist script on GitHub that used fixed storage and then SQLite to update the table but at the moment it’s a bit out of my league cos I’m just getting back in aswell as last time I touched sql I fucking wanted to die. I’ll look at the details for it though as I’m sure it’ll help out. All gmod servers also run a SQLite server with it dont they?

31 minutes ago, Angus said:

i dont care for code im not a nerd xD, but i would like to know how this would be implemented considering the wide range of vehicles and ISC in general. Unlike the rest of the server ISC have a different PL system im happy to DM you it if you would like. + not to mention ISC-CMD use the TIE/D and TIE/DE with an EPL that is the problem, unlike most Maj Gens ISC-CMD has access to ALL vehicles whereas generals dont.... Same with general ISC we have a large range of vehicles we can use even cadets (Again i can send the doc). Just 1 last thing... what about ppl trying out for ISC? they have no pl sometimes (majority) and due to this code wouldnt be able to unless given e.g an NPL theta brought it up with our PL tests as well we test the ppl on vehicles they dont have the license for so idk man. Either way GL i do like this 

So the script will have a menu for staff or people who are allowed too to add license types and add vehicles allowed to those license types. So with how the server is setup with the tones of different groups they’re probably be like 3 different licenses for ISC, a training license, general use license and then whatever other groups there are. So pretty much admins or whatever permitted people will be able to create license groups and set what vehicles those license groups can use and set people to those license groups. I will be adding a training license and if you want to send through that structure please do big man.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...