ply:IsUserGroup

When I use this command it literally kills my join team variables and everything I do not know why, would a listen server be doing this? Is there away around this, and yes I have a custom group for them that is not Admin or SuperAdmin.

Post code

I posted it before but once again:

[lua]AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “shared.lua” )
include( “shared.lua” )

function GM:PlayerInitialSpawn( ply )
if not ply:IsUserGroup( “vip” ) or not ply:IsSuperAdmin() or not ply:IsAdmin() then
ply:Kick(“You are not a ECGamers.com VIP”)
else
ply:PrintMessage(HUD_PRINTTALK, “Hello “…ply:Nick()…” Welcome to the server”)
if ply:IsUserGroup( “vip” ) then
ply:ConCommand("team_1
")
elseif ply:IsSuperAdmin() or ply:IsAdmin() then
ply:ConCommand("team_1
")
end
end
end

function GM:PlayerLoadout( ply )

ply:StripWeapons()

if ply:Team() == 1 then
	if ply:IsUserGroup( "vip" ) then
		ply:Give( "weapon_stunstick" )
	end
end

end

function SetTeam1( ply, cmd, args )
ply:SetTeam( 1 )
ply:Spawn()
end

concommand.Add( “team_1”, SetTeam1 )[/lua]

BUUUT This works:

[lua]AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “shared.lua” )
include( “shared.lua” )

function GM:PlayerInitialSpawn( ply )
if not ply:IsSuperAdmin() or not ply:IsAdmin() then
ply:Kick(“You are not a ECGamers.com VIP”)
else
ply:PrintMessage(HUD_PRINTTALK, “Hello “…ply:Nick()…” Welcome to the server”)
if ply:IsSuperAdmin() or ply:IsAdmin() then
ply:ConCommand("team_1
")
end
end
end

function GM:PlayerLoadout( ply )

ply:StripWeapons()

if ply:Team() == 1 then
	ply:Give( "weapon_stunstick" )
	end
end

end

function SetTeam1( ply, cmd, args )
ply:SetTeam( 1 )
ply:Spawn()
end

concommand.Add( “team_1”, SetTeam1 )[/lua]

It’s like ply:IsUserGroup( “Anything here” ) kills my teams and weapons and code… :confused:

-snip-

dumb :confused:

[editline]15:41[/editline]
Try this one



AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )

function GM:PlayerInitialSpawn( ply )
	if not ply:IsUserGroup( "vip" ) or not ply:IsSuperAdmin() or not ply:IsAdmin() then
		ply:Kick("You are not a ECGamers.com VIP")
	else
		ply:PrintMessage(HUD_PRINTTALK, "Hello "..ply:Nick().." Welcome to the server")
		ply:ConCommand("team_1
")
		end
	end

function GM:PlayerLoadout( ply )

	ply:StripWeapons()
	
	if ply:Team() == 1 then
		if ply:IsUserGroup( "vip" ) then
			ply:Give( "weapon_stunstick" )
		end
	end
end

function SetTeam1( ply, cmd, args )
	ply:SetTeam( 1 )
	ply:Spawn()
end

concommand.Add( "team_1", SetTeam1)


[lua]function SetTeam1( ply, cmd, args )
ply:SetTeam( 1 )
ply:Spawn()
end [/lua]

Yea, right after I posted that, I realised it was in there already :doh:

Hahaha so yeah I just don’t get why it’s not working D=

did you try the code I posted?

Yes and it is still not working, is there a chance that my listen server just doesn’t like me and wants to jump over all this stuff because I’m the rcon or something? Even though it should automatically join me to the team anyhow.

Do you use ASSMod or something?

Cause you havent asked if the player is usergroup “Owner”.

And where did you add the uhm, UserGroup?

I do not have ANY Admin Mods of any sort.

I added the usergroup to the Users.txt in the garrysmod/settings

Wouldnt it just be…?


ply:Isvip()

[editline]lol[/editline]

possible with meta, aye?

Well then I will check this out.

ERROR: GAMEMODE:‘PlayerInitialSpawn’ Failed: vip/gamemode/init.lua:6: attempt to call method ‘Isvip’ (a nil value)

It is of course a custom group and it says in the users.txt use
pl:IsUserGroup( “namehere” )

Of course pl turns into an error so I tried player.IsUserGroup( “vip” ) Once again again an error

Then I tried ply:… which just made it so the code didn’t work.

Im blank then

The reason it doesn’t work is here.
The usergroup is set in PlayerSpawn hook, and your code is called before that. A solution might be adding a timer for couple seconds that checks the usergroup.

:colbert:

If you are the host of a listen server you are always a super admin. Have you made a group called “vip” and what error message are you getting?

users.txt

You’ll have to add the vip group there…

Read the thread.

As I’ve said a few times in the post, there is no error message and I have added myself as a “vip” in the users.txt

How would I go about doing this?