Setting ply job and pos on spawn if level <= somelevel
8 replies, posted
So i'm trying to make player job and spawn pos changed when player joined to a server and his level is lower then 5 but i can't make, i tried to create PlayerInitialSpawn hook but it not working.
Post what you wrote
I think it'd be a lot more work but easier to use... if you could somehow create a table and create names for the spawn points instead of doing setPos for every single one. Then all you would have to do is
if ply Level == >=5 then team.SetSpawnPoint
team.SetSpawnPoint
serverside file:
if SERVER then
util.AddNetworkString("drawspawnmenu")
util.AddNetworkString("menupressedspawn")
util.AddNetworkString("menupressedquit")
util.AddNetworkString("sendnudes")
util.AddNetworkString("spawnnoob")
util.AddNetworkString("spawnasselo")
hook.Add("PlayerInitialSpawn", "InitialMenuOpen", function(ply)
net.Start("drawspawnmenu")
net.Send(ply)
local level = ply:getDarkRPVar('level') or 1
net.Start("sendnudes")
net.WriteString(level)
net.Send(ply)
end)
net.Receive("spawnnoob", function(len, ply)
ply:SetTeam(TEAM_NEWBIE)
ply:SetPos(Vector(-7893.958496 + math.Rand(1, 10),13327.409180 + math.Rand(1,15),-115.968750))
end)
net.Receive("spawnasselo", function(len, ply)
ply:SetTeam(TEAM_SELO)
end)
end
clientside file:
local function drawBlur(x, y, w, h, layers, density, alpha)
local blur = Material("pp/blurscreen")
surface.SetDrawColor(255, 255, 255, alpha)
surface.SetMaterial(blur)
for i = 1, layers do
blur:SetFloat("$blur", (i / layers) * density)
blur:Recompute()
render.UpdateScreenEffectTexture()
render.SetScissorRect(x, y, x + w, y + h, true)
surface.DrawTexturedRect(0, 0, ScrW(), ScrH())
render.SetScissorRect(0, 0, 0, 0, false)
end
end
local w = ScrW()
local h = ScrH()
local function drawspawnframe()
local overlay = vgui.Create("DFrame")
overlay:SetPos(0,0)
overlay:SetSize(w,h)
overlay:ShowCloseButton(false)
overlay:MakePopup()
overlay:SetDraggable(false)
overlay.Paint = function(s, w, h)
drawBlur(0,0,w,h,3,3,210)
end
local frame = vgui.Create("DFrame")
frame:SetSize(300,400)
frame:Center()
frame:MakePopup()
local spawnbtn = vgui.Create("DButton", frame)
spawnbtn:SetSize(150,60)
spawnbtn:SetPos(200,250)
spawnbtn:SetText("Вступить в игру")
spawnbtn.DoClick = function()
net.Receive("sendnudes", function(len)
local lvl = net.ReadString()
if lvl < "5" then
net.Start("spawnasselo")
net.SendToServer()
elseif lvl == "0" then
net.Start("spawnnoob")
net.SendToServer()
else
return
end
end)
frame:Close()
overlay:Close()
end
end
net.Receive("drawspawnmenu", drawspawnframe)
by creating timer?
Why do you register a new net.Receive every time the button is clicked?
i used but it returned a nil value
By not comparing strings like they're integers.
You don't have to make a timer you can just get the current time: Delays and Cooldowns
Sorry, you need to Log In to post a reply to this thread.