Hello everyone, with somes friends we started a prop hunt server. We are using this gamemode : [url]http://steamcommunity.com/sharedfiles/filedetails/?id=417565863[/url]
We got somes problems that we cannot solve :
-Delete the use button (E or +use) for hunters and props, make them to don't pick up items [B][U]<----SOLVED[/U][/B]
-Make the jump pack that jump normaly for props [B][U]<----SOLVED[/U][/B]
Not one who permit fly
-Set a flashlight for hunters : [B][U]<----SOLVED[/U][/B]
i've tried to add (in the init.lua in : gamemode\prop_hunt\gamemode\) :
hook.Add("PlayerInitialSpawn", "Flashlight", function(ply)
if(!ply:CanUseFlashlight())then
ply:AllowFlashlight(true)
end
end)
i've set mp_flashlight 1 , same result it didn't work
Edit: we want to win points (from pointshop addon) when props taunts [B][U]<----SOLVED[/U][/B]
and we want when hunters kill a prop they win points
I'm sorry if there is somes troubles in my sentences, i'm french =).
[URL="http://wiki.garrysmod.com/page/GM/PlayerSwitchFlashlight"]GM:PlayerSwitchFlashlight[/URL] may already be hooked in the init.lua (or another serverside file)
It may look similar to this.
[CODE]
function GM:PlayerSwitchFlashlight( ply, bool )
return false
end
[/CODE]
If it does change true to false and that should fix your issue.
[B][U]Mine was looking :[/U][/B]
[CODE]function GM:PlayerSwitchFlashlight(pl, on)
if pl:Alive() && pl:Team() == TEAM_HUNTERS then
return false
end
if pl:Alive() && pl:Team() == TEAM_PROPS then
umsg.Start("PlayerSwitchDynamicLight", pl)
umsg.End()
end
return false
end
[/CODE]
[U][B]Now it looks :[/B][/U]
[CODE]function GM:PlayerSwitchFlashlight( ply, bool )
return false
end[/CODE]
[B][U]
Same thing this is not working.
Did it need a restart server ?
The full init.lua code :[/U][/B]
[CODE]-- Enhanced by: Wolvindra-Vinzuerio and D4UNKN0WNM4N2010 --
-- Special thanks for Kowalski that merged into his github. You may check on his prop hunt workshop page. --
-- Send the required lua files to the client
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("cl_menu.lua")
AddCSLuaFile("sh_config.lua")
AddCSLuaFile("sh_init.lua")
AddCSLuaFile("sh_player.lua")
-- Include the required lua files
include("sh_init.lua")
include("sv_admin.lua")
-- Server only constants
EXPLOITABLE_DOORS = {
"func_door",
"prop_door_rotating",
"func_door_rotating"
}
USABLE_PROP_ENTITIES = {
"prop_physics",
"prop_physics_multiplayer"
}
-- We're going to get the usable prop table and send it over to the client with this network string
util.AddNetworkString("ServerUsablePropsToClient")
-- Send the required resources to the client
for _, taunt in pairs(HUNTER_TAUNTS) do resource.AddFile("sound/"..taunt) end
for _, taunt in pairs(PROP_TAUNTS) do resource.AddFile("sound/"..taunt) end
-- Called alot
function GM:CheckPlayerDeathRoundEnd()
if !GAMEMODE.RoundBased || !GAMEMODE:InRound() then
return
end
local Teams = GAMEMODE:GetTeamAliveCounts()
if table.Count(Teams) == 0 then
GAMEMODE:RoundEndWithResult(1001, "Draw, everyone loses!")
return
end
if table.Count(Teams) == 1 then
local TeamID = table.GetFirstKey(Teams)
GAMEMODE:RoundEndWithResult(TeamID, team.GetName(1).." win!")
return
end
--todo: add custom wins/lost sound on next update.
end
-- Called when an entity takes damage
function EntityTakeDamage(ent, dmginfo)
local att = dmginfo:GetAttacker()
if GAMEMODE:InRound() && ent && (ent:GetClass() != "ph_prop" && ent:GetClass() != "func_breakable" && ent:GetClass() != "prop_door_rotating" && ent:GetClass() != "prop_dynamic*") && !ent:IsPlayer() && att && att:IsPlayer() && att:Team() == TEAM_HUNTERS && att:Alive() then
att:SetHealth(att:Health() - HUNTER_FIRE_PENALTY)
if att:Health() <= 0 then
MsgAll(att:Name() .. " felt guilty for hurting so many innocent props and committed suicide\n")
att:Kill()
end
end
end
hook.Add("EntityTakeDamage", "PH_EntityTakeDamage", EntityTakeDamage)
-- Called when player tries to pickup a weapon
function GM:PlayerCanPickupWeapon(pl, ent)
if pl:Team() != TEAM_HUNTERS then
return false
end
return true
end
-- Make a variable for 4 unique combines.
-- Clean up, sorry btw.
local playerModels = {
"combine",
"combineprison",
"combineelite",
"police"
-- you may add more here.
}
function GM:PlayerSetModel(pl)
-- set antlion gib small for Prop model.
-- Do not change this into others because this might purposed as a hitbox for props.
local player_model = "models/Gibs/Antlion_gib_small_3.mdl"
-- Clean Up.
if GetConVar("ph_use_custom_plmodel"):GetBool() then
-- Use a delivered player model info from cl_playermodel ConVar.
-- This however will use a custom player selection. It'll immediately apply once it is selected.
local mdlinfo = pl:GetInfo("cl_playermodel")
local mdlname = player_manager.TranslatePlayerModel(mdlinfo)
if pl:Team() == TEAM_HUNTERS then
player_model = mdlname
end
else
-- Otherwise, Use Random one based from a table above.
local customModel = table.Random(playerModels)
local customMdlName = player_manager.TranslatePlayerModel(customModel)
if pl:Team() == TEAM_HUNTERS then
player_model = customMdlName
end
end
-- precache and Set the model.
util.PrecacheModel(player_model)
pl:SetModel(player_model)
end
-- Called when a player tries to use an object
function GM:PlayerUse(pl, ent)
if !pl:Alive() || pl:Team() == TEAM_SPECTATOR then return false end
if pl:Team() == TEAM_PROPS && pl:IsOnGround() && !pl:Crouching() && table.HasValue(USABLE_PROP_ENTITIES, ent:GetClass()) && ent:GetModel() then
if table.HasValue(BANNED_PROP_MODELS, ent:GetModel()) then
pl:ChatPrint("That prop has been banned by the server.")
elseif ent:GetPhysicsObject():IsValid() && pl.ph_prop:GetModel() != ent:GetModel() then
local ent_health = math.Clamp(ent:GetPhysicsObject():GetVolume() / 250, 1, 200)
local new_health = math.Clamp((pl.ph_prop.health / pl.ph_prop.max_health) * ent_health, 1, 200)
local per = pl.ph_prop.health / pl.ph_prop.max_health
pl.ph_prop.health = new_health
pl.ph_prop.max_health = ent_health
pl.ph_prop:SetModel(ent:GetModel())
pl.ph_prop:SetSkin(ent:GetSkin())
pl.ph_prop:SetSolid(SOLID_VPHYSICS)
pl.ph_prop:SetPos(pl:GetPos() - Vector(0, 0, ent:OBBMins().z))
pl.ph_prop:SetAngles(pl:GetAngles())
local hullxymax = math.Round(math.Max(ent:OBBMaxs().x, ent:OBBMaxs().y))
local hullxymin = hullxymax * -1
local hullz = math.Round(ent:OBBMaxs().z)
pl:SetHull(Vector(hullxymin, hullxymin, 0), Vector(hullxymax, hullxymax, hullz))
pl:SetHullDuck(Vector(hullxymin, hullxymin, 0), Vector(hullxymax, hullxymax, hullz))
pl:SetHealth(new_health)
umsg.Start("SetHull", pl)
umsg.Long(hullxymax)
umsg.Long(hullz)
umsg.Short(new_health)
umsg.End()
end
end
-- Prevent the door exploit
if table.HasValue(EXPLOITABLE_DOORS, ent:GetClass()) && pl.last_door_time && pl.last_door_time + 1 > CurTime() then
return false
end
pl.last_door_time = CurTime()
return true
end
-- Called when player presses [F3]. Plays a taunt for their team
function GM:ShowSpare1(pl)
if GAMEMODE:InRound() && pl:Alive() && (pl:Team() == TEAM_HUNTERS || pl:Team() == TEAM_PROPS) && pl.last_taunt_time + TAUNT_DELAY <= CurTime() && #PROP_TAUNTS > 1 && #HUNTER_TAUNTS > 1 then
repeat
if pl:Team() == TEAM_HUNTERS then
rand_taunt = table.Random(HUNTER_TAUNTS)
else
rand_taunt = table.Random(PROP_TAUNTS)
end
until rand_taunt != pl.last_taunt
pl.last_taunt_time = CurTime()
pl.last_taunt = rand_taunt
pl:EmitSound(rand_taunt, 100)
end
end
-- Called when a player leaves
function PlayerDisconnected(pl)
pl:RemoveProp()
end
hook.Add("PlayerDisconnected", "PH_PlayerDisconnected", PlayerDisconnected)
-- Called when the players spawns
function PlayerSpawn(pl)
pl:SetNWBool("PlayerLockedRotation", false)
pl:SetNWBool("InFreezeCam", false)
pl:SetNWEntity("PlayerKilledByPlayerEntity", nil)
pl:Blind(false)
pl:RemoveProp()
pl:RemoveClientProp()
pl:SetColor( Color(255, 255, 255, 255))
pl:SetRenderMode( RENDERMODE_TRANSALPHA )
pl:UnLock()
pl:ResetHull()
pl.last_taunt_time = 0
umsg.Start("ResetHull", pl)
umsg.End()
umsg.Start("DisableDynamicLight", pl)
umsg.End()
pl:SetCollisionGroup(COLLISION_GROUP_PASSABLE_DOOR)
end
hook.Add("PlayerSpawn", "PH_PlayerSpawn", PlayerSpawn)
-- Called when round ends
function RoundEnd()
for _, pl in pairs(team.GetPlayers(TEAM_HUNTERS)) do
pl:Blind(false)
pl:UnLock()
end
end
hook.Add("RoundEnd", "PH_RoundEnd", RoundEnd)
-- This is called when the round time ends (props win)
function GM:RoundTimerEnd()
if !GAMEMODE:InRound() then
return
end
GAMEMODE:RoundEndWithResult(TEAM_PROPS, "Props win!")
end
-- Called before start of round
function GM:OnPreRoundStart(num)
game.CleanUpMap()
if GetGlobalInt("RoundNumber") != 1 && (SWAP_TEAMS_EVERY_ROUND == 1 || ((team.GetScore(TEAM_PROPS) + team.GetScore(TEAM_HUNTERS)) > 0 || SWAP_TEAMS_POINTS_ZERO==1)) then
for _, pl in pairs(player.GetAll()) do
if pl:Team() == TEAM_PROPS || pl:Team() == TEAM_HUNTERS then
if pl:Team() == TEAM_PROPS then
pl:SetTeam(TEAM_HUNTERS)
else
pl:
Oh god, please use [CODE] tags. No one is going to read all of that.
Thanks i wasn't finding what it was
[QUOTE=Darkouille81;50561491][B][U]Mine was looking :[/U][/B]
[CODE]function GM:PlayerSwitchFlashlight(pl, on)
if pl:Alive() && pl:Team() == TEAM_HUNTERS then
return false
end
if pl:Alive() && pl:Team() == TEAM_PROPS then
umsg.Start("PlayerSwitchDynamicLight", pl)
umsg.End()
end
return false
end
[/CODE]
[U][B]Now it looks :[/B][/U]
[CODE]function GM:PlayerSwitchFlashlight( ply, bool )
return false
end[/CODE]
Same thing this is not working.
Did it need a restart server ?
[/QUOTE]
You seem to have not read what he advised (Note what he says at the bottom):
[QUOTE=Moku;50561447][URL="http://wiki.garrysmod.com/page/GM/PlayerSwitchFlashlight"]GM:PlayerSwitchFlashlight[/URL] may already be hooked in the init.lua (or another serverside file)
It may look similar to this.
[CODE]
function GM:PlayerSwitchFlashlight( ply, bool )
return false
end
[/CODE]
[B][U]If it does change true to false and that should fix your issue[/U][/B].[/QUOTE]
I've tried to do :
[CODE]function GM:PlayerSwitchFlashlight( ply, bool )
return true <----- false to true
end[/CODE]
And it didn't work.
[QUOTE=Darkouille81;50561890]I've tried to do :
[CODE]function GM:PlayerSwitchFlashlight( ply, bool )
return true <----- false to true
end[/CODE]
And it didn't work.[/QUOTE]
It may be worth removing the chunk of code as it may cause the behaviour to return to default.
Well i've added a weapon who makes similar light (Minecraft Torch) <---- [U][B]SEE BELOW I'VE FOUND ANOTHER WAY[/B][/U]
Up for others problems
Edit : For points while taunting (i've only found this one working) : putted in addons/pointshopmaster/lua/autorun
[CODE]local KeyToHook = {
F1 = "ShowHelp",
F2 = "ShowTeam",
F3 = "ShowSpare1",
F4 = "ShowSpare2",
None = "ThisHookDoesNotExist"
}
hook.Add(KeyToHook['F3'], "PS_Taunt", function(ply)
if GAMEMODE:InRound() && ply:Alive() && (ply:Team() == TEAM_HUNTERS || ply:Team() == TEAM_PROPS) && ply.last_taunt_time + 5 <= CurTime() then -- make sure the CurTime matches the permitted taunt delay time.
if ply:Team() == TEAM_HUNTERS then
ply:PS_Notify("Nice taunt!")
else
ply:PS_GivePoints(5) -- how many points for taunting? Default: 5
ply:PS_Notify("You've been given 5 ", PS.Config.PointsName, " for taunting!") -- this is the message the player gets.
end
end
end)[/CODE]
I've tryed to : On kill give points for hunters : put in lua/autorun/server
[CODE]local amount = 0;
hook.Add( "PlayerDeath", "KillPoints", function( victim, weapon, killer)
if( IsValid( killer ) and IsValid( victim ) ) then
if( killer:IsPlayer() and victim:IsPlayer() ) then
if ( killer:Team() == TEAM_HUNTERS and victim:Team() == TEAM_PROPS ) then
killer:PS_GivePoints( 5 );
killer:PS_Notify("Tu a gagné 5 points pour avoir tué un prop !"); -- Yea it's a french server
end;
end;
end;
end )[/CODE]
But it didn't work
I've found the normal jump pack for props :
[CODE]ITEM.Name = 'Jump Pack'
ITEM.Price = 1000
ITEM.Model = 'models/xqm/jetengine.mdl'
ITEM.Bone = 'ValveBiped.Bip01_Spine2'
function ITEM:OnBuy( player )
player:SetJumpPower( 255 )
end
function ITEM:OnHolster( player )
player:SetJumpPower( 200 )
end
function ITEM:OnEquip( player )
player:SetJumpPower( 255 )
end[/CODE]
Wow so much corrections, i've found how to disable pickup items for hunters and props :
In server.cfg (in garrysmod/cfg) add : sv_playerpickupallowed 0
ANNOTHER CORRECTION : for the flashlight, make sure in server.cfg you have mp_flashlight 1
then in garrysmod/gamemodes/prop_hunt/gamemode in the init.lua you shoud replace like this :
[CODE]-- Flashlight toggling
function GM:PlayerSwitchFlashlight(pl, on)
if pl:Alive() && pl:Team() == TEAM_HUNTERS then
return true -- <-- I've changed false to true
end
if pl:Alive() && pl:Team() == TEAM_PROPS then
umsg.Start("PlayerSwitchDynamicLight", pl)
umsg.End()
end
return true -- <-- I've changed false to true
end[/CODE]
Sorry, you need to Log In to post a reply to this thread.