Ban SWEP, car dealer and somes questions about Dark RP
16 replies, posted
Hello,
How to make a SWEP that can freez and ban target and how to ban frozen players who disconnects ? (done, [URL=https://facepunch.com/showthread.php?t=1580443&p=52738799&viewfull=1#post52738799]code below[/URL])
How to make a simple car dealer wich works with the cars on simfphys base ?
And how can I remove what is shown on the folowing picture: (I know there is an official forum for Dark RP)
[url]https://www.dropbox.com/s/nf83vssidcylyd7/Sans%20titre.png?dl=0[/url]
Sorry if my English is bad, this isn't my native language
This is no a request forum, and doesn't seems like you're really enthusiast about learning how to do that stuff
You didn't say what did you try, what do you have problems with, nothing, just do me this thing...About your second request, i recommend you gmodstore.com
[QUOTE=gonzalolog;52729379]This is no a request forum, and doesn't seems like you're really enthusiast about learning how to do that stuff
You didn't say what did you try, what do you have problems with, nothing, just do me this thing...About your second request, i recommend you gmodstore.com[/QUOTE]
I do not ask for request, I ask how to do it
Don't edit your post, you literally asked us a weapon that can freeze players, ban them if they disconnect and gives you godmode
About the cardealer, just create a derma panel, create a table with vehicles you want to sell, and do some netmessages, it's not something that easy if you don't have your feets in the ground regarding creating stores and interactions between client and server
There's no functions to create a simple car dealer, everything comes with understanding how communication between server and client works, also how do you structure your system for it
You can come here and take a look here this addon to check how does it works, but remember, there's no a function to create dealers, that's something up to you [url]https://facepunch.com/showthread.php?t=1481400[/url]
[QUOTE=Quozul;52729405]I do not ask for request, I ask how to do it[/QUOTE]
This is like saying, "It's not bribing. It's paying someone in exchange for influence..."
No one's going to spoonfeed code for you to use. Do as gonzalolog said and use [URL="gmodstore.com"]gmodstore[/URL].
Assuming you know at least something about Lua, these pages should be useful
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetEyeTrace]Player:GetEyeTrace[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Chair_Throwing_Gun]Chair Throwing Gun[/url] (Obviously don't make a chair-throwing gun, but it should be a nice start to learning SWEP's by reading it and using the parts you need)
As for doing stuff with the player they are looking at, you can surely figure it out, and, assuming you're using ULX, you can read through the ULX documentation [url=http://ulyssesmod.net/docs/]here[/url].
[QUOTE=MelonShooter;52729921]No one's going to spoonfeed code for you to use. Do as gonzalolog said and use [URL="gmodstore.com"]gmodstore[/URL].[/QUOTE]
I do not have money
[QUOTE=monkeymacman;52730094]Assuming you know at least something about Lua, these pages should be useful
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetEyeTrace]Player:GetEyeTrace[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Chair_Throwing_Gun]Chair Throwing Gun[/url] (Obviously don't make a chair-throwing gun, but it should be a nice start to learning SWEP's by reading it and using the parts you need)
As for doing stuff with the player they are looking at, you can surely figure it out, and, assuming you're using ULX, you can read through the ULX documentation [url=http://ulyssesmod.net/docs/]here[/url].[/QUOTE]
Thanks I'll take a look
On the contrary of what monkeymacman said, if you don't know lua and would like to make it yourself, start [URL="http://wiki.garrysmod.com/page/Beginner_Tutorial_Intro"]here[/URL].
[QUOTE=MelonShooter;52731516]On the contrary of what monkeymacman said, if you don't know lua and would like to make it yourself, start [URL="http://wiki.garrysmod.com/page/Beginner_Tutorial_Intro"]here[/URL].[/QUOTE]
I already do know lua basics
[QUOTE=Quozul;52731708]I already do know lua[/QUOTE]
It doesn't seem so, as you're asking for quite simple additions.
[QUOTE=monkeymacman;52730094]Assuming you know at least something about Lua, these pages should be useful
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetEyeTrace]Player:GetEyeTrace[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Chair_Throwing_Gun]Chair Throwing Gun[/url] (Obviously don't make a chair-throwing gun, but it should be a nice start to learning SWEP's by reading it and using the parts you need)
As for doing stuff with the player they are looking at, you can surely figure it out, and, assuming you're using ULX, you can read through the ULX documentation [url=http://ulyssesmod.net/docs/]here[/url].[/QUOTE]
Thanks for the help, here is the code for who wants it (you will need ulx and ulib for this code to works)
I used:
[img]http://ulyssesmod.net/favicon.ico[/img] [URL=http://ulyssesmod.net/docs/files/lua/ulib/server/bans-lua.html#ban]ban[/URL]
[img]http://ulyssesmod.net/favicon.ico[/img] [URL=http://ulyssesmod.net/docs/files/lua/ulib/server/player-lua.html#kick]kick[/URL]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [URL=http://wiki.garrysmod.com/page/Player/Freeze]Player:Freeze[/URL]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [URL=http://wiki.garrysmod.com/page/Player/IsFrozen]Player:IsFrozen[/URL]
Code of the SWEP in [U]lua/weapons[/U] :
[CODE]SWEP.PrintName = "Admin Gun"
SWEP.Author = "Quozul"
SWEP.Contact = "quozul@outlook.com"
SWEP.Instructions = "Left mouse to freez the player\nRight mouse to quick ban the player"
-- Makes the SWEP only spawnable by admin
SWEP.Spawnable = true
SWEP.AdminOnly = true
-- Makes all the ammo infinite
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.Weight = 0
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Slot = 5 -- Position of the SWEP
SWEP.SlotPos = 1 -- Position of the SWEP
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
SWEP.ViewModel = "models/weapons/v_pistol.mdl" -- Change model
SWEP.WorldModel = "models/weapons/w_pistol.mdl" -- Change world model
local ShootSound = Sound( "Metal.SawbladeStick" ) -- Set the sound
-- Left mouse: Freez
function SWEP:PrimaryAttack()
-- Wait 0.5 seconds.
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 ) -- Prevent from freez and unfreez spam
if self:GetOwner():GetEyeTrace().Entity:IsPlayer() then
if self:GetOwner():GetEyeTrace().Entity:IsFrozen() == true then
self:GetOwner():GetEyeTrace().Entity:Freeze( false )
self:GetOwner():PrintMessage( HUD_PRINTCENTER, "You unfrozen your target." ) -- Change the message when you unfreezed the targeted player here
elseif self:GetOwner():GetEyeTrace().Entity:IsFrozen() == false then
self:GetOwner():GetEyeTrace().Entity:Freeze( true )
self:GetOwner():PrintMessage( HUD_PRINTCENTER, "You frozen your target." ) -- Change the message when you freezed the targeted player here
end
self:EmitSound( ShootSound ) -- Emit sound when a player gets freezed
else
self:GetOwner():PrintMessage( HUD_PRINTCENTER, "Aim at a player." ) -- Change the message when the user does not aim at a playere here
end
end
-- Right mouse: Ban menu
function SWEP:SecondaryAttack()
if self:GetOwner():GetEyeTrace().Entity:IsPlayer() then
if AdminSWEPKick == 1 then
ULib.kick( self:GetOwner():GetEyeTrace().Entity, AdminSWEPBanMessage, self:GetOwner() ) -- Kick the player using ULX
PrintMessage( HUD_PRINTCENTER, "The player " ..self:GetOwner():GetEyeTrace().Entity:GetName().. " got kicked by an admin." ) -- Message in game for other players
elseif AdminSWEPKick == 0 then
ULib.ban( self:GetOwner():GetEyeTrace().Entity, AdminSWEPBanTime, AdminSWEPBanMessage, admin ) -- Ban the player using ULX
PrintMessage( HUD_PRINTCENTER, "The player " ..self:GetOwner():GetEyeTrace().Entity:GetName().. " got banned by an admin." ) -- Message in game for other players
end
else
self:GetOwner():PrintMessage( HUD_PRINTCENTER, "Aim at a player." ) -- Change the message when the user does not aim at a playere here
end
end[/CODE]
Ban players who disconnects while being freezed in [U]lua/autorun/server[/U] :
[CODE]local function banFrozenPlayers( ply )
if ply:IsFrozen() == true then
ULib.ban( ply, 15, "You disconnected while being frozen.", admin ) -- Ban the player using ULX for 15 minutes
PrintMessage( HUD_PRINTCENTER, "The player " ..ply.. " got banned for quitting the server while being frozen." ) -- Change the message in game here
end
end
hook.Add( "PlayerDisconnected", "PunishFrozenPlayers", banFrozenPlayers ) -- Execute the function banFrozenPlayers when a player disconnects[/CODE]
[QUOTE=Quozul;52738799]Thanks for the help, here is the code for who wants it (you will need ulx and ulib for this code to works)
Code of the SWEP in [U]lua/weapons[/U] :
[CODE]SWEP.PrintName = "Admin Gun"
SWEP.Author = "Quozul"
SWEP.Contact = "quozul@outlook.com"
SWEP.Instructions = "Left mouse to freez the player\nRight mouse to quick ban the player"
-- Makes the SWEP only spawnable by admin
SWEP.Spawnable = true
SWEP.AdminOnly = true
-- Makes all the ammo infinite
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.Weight = 0
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Slot = 5 -- Position of the SWEP
SWEP.SlotPos = 1 -- Position of the SWEP
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
SWEP.ViewModel = "models/weapons/v_pistol.mdl" -- Change model
SWEP.WorldModel = "models/weapons/w_pistol.mdl" -- Change world model
local ShootSound = Sound( "Metal.SawbladeStick" ) -- Set the sound
-- Left mouse: Freez
function SWEP:PrimaryAttack()
-- Wait 0.5 seconds.
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 ) -- Prevent from freez and unfreez spam
if Entity( 1 ):GetEyeTrace().Entity:IsPlayer() then
if Entity( 1 ):GetEyeTrace().Entity:IsFrozen() == true then
Entity( 1 ):GetEyeTrace().Entity:Freeze( false )
Entity( 1 ):PrintMessage( HUD_PRINTCENTER, "You unfrozen your target." ) -- Change the message when you unfreezed the targeted player here
elseif Entity( 1 ):GetEyeTrace().Entity:IsFrozen() == false then
Entity( 1 ):GetEyeTrace().Entity:Freeze( true )
Entity( 1 ):PrintMessage( HUD_PRINTCENTER, "You frozen your target." ) -- Change the message when you freezed the targeted player here
end
self:EmitSound( ShootSound ) -- Emit sound when a player gets freezed
else
Entity( 1 ):PrintMessage( HUD_PRINTCENTER, "Aim at a player." ) -- Change the message when the user does not aim at a playere here
end
end
-- Right mouse: Ban menu
function SWEP:SecondaryAttack()
if Entity( 1 ):GetEyeTrace().Entity:IsPlayer() then
ULib.kick( Entity( 1 ):GetEyeTrace().Entity, "An admin kicked you from the server", Entity( 1 ) ) -- Kick the targeted player from the server
PrintMessage( HUD_PRINTCENTER, "The player " ..Entity( 1 ):GetEyeTrace().Entity.. " got kicked by an admin." ) -- Change the message in game here
else
Entity( 1 ):PrintMessage( HUD_PRINTCENTER, "Aim at a player." ) -- Change the message when the user does not aim at a playere here
end
end[/CODE]
Ban players who disconnects while being freezed in [U]lua/autorun/server[/U] :
[CODE]local function banFrozenPlayers( ply )
if ply:IsFrozen() == true then
ULib.ban( ply, 15, "You disconnected while being frozen.", admin ) -- Ban the player using ULX for 15 minutes
PrintMessage( HUD_PRINTCENTER, "The player " ..ply.. " got banned for quitting the server while being frozen." ) -- Change the message in game here
end
end
hook.Add( "PlayerDisconnected", "PunishFrozenPlayers", banFrozenPlayers ) -- Execute the function banFrozenPlayers when a player disconnects[/CODE][/QUOTE]
In the GetEyeTrace you seem to be using it from Entity(1), which seems to just be the first player to join the server (and sometimes nil). Instead, you should try using self.Owner or self:GetOwner() in replace of those spots. Also, when you put the name in chat, you are just printing the player entity, which is a table, instead of getting the name of the player to put in its spot.
[QUOTE=monkeymacman;52740862]In the GetEyeTrace you seem to be using it from Entity(1), which seems to just be the first player to join the server (and sometimes nil). Instead, you should try using self.Owner or self:GetOwner() in replace of those spots. Also, when you put the name in chat, you are just printing the player entity, which is a table, instead of getting the name of the player to put in its spot.[/QUOTE]
I edited my previous post and I was wondering how to change variables value using [img]http://wiki.garrysmod.com/favicon.ico[/img] [URL=http://wiki.garrysmod.com/page/Category:DNumSlider]DNumSlider[/URL] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [URL=http://wiki.garrysmod.com/page/Category:DCheckBoxLabel]DCheckBoxLabel[/URL]
[QUOTE=Quozul;52745466]I edited my previous post and I was wondering how to change variables value using [img]http://wiki.garrysmod.com/favicon.ico[/img] [URL=http://wiki.garrysmod.com/page/Category:DNumSlider]DNumSlider[/URL] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [URL=http://wiki.garrysmod.com/page/Category:DCheckBoxLabel]DCheckBoxLabel[/URL]
[/QUOTE]
Try replacing the variables with convars, as both those elements appear to by default support being assigned to a convar.
[QUOTE=monkeymacman;52745617]Try replacing the variables with convars, as both those elements appear to by default support being assigned to a convar.[/QUOTE]
I don't understand, can you give me exemples ?
[QUOTE=Quozul;52749365]I don't understand, can you give me exemples ?[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/CreateConVar]CreateConVar[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/SetConVar]Panel:SetConVar[/url]
[QUOTE=Quozul;52749365]I don't understand, can you give me exemples ?[/QUOTE]
The examples for DNumSlider and DCheckBoxLabel have them being tied to convars, so, bind them to convars, and instead of having variables determine the length of ban/ if it bans, just check the convar values.
Also, don't forget to actually make the convars. Use the wiki in depth if you still don't understand
Sorry, you need to Log In to post a reply to this thread.