Extra Credits & Extra Prop Push For Specific Ranks?

So I own a TTT server & I wanted to add a little bit more for donators. (Instead of skins) & I found this code from a old post but it didn’t seem to work for the credits. As I am not too good with lua Im simply asking for help to make this work. If you don’t want to help so be it just please leave your negative thoughts to yourself.


 -- Modify these as you want, the groupname on the left and the amount of credits they should be given on the right, follow the format
local addCredits = {
	["superadmin"] = 3
	["admin"] = 2
	["VIP"] = 1
}

hook.Add( "TTTBeginRound", "AddCredits", function()

	for k, v in pairs( player.GetAll() ) do
		
		if ( v:GetTraitor() or v:GetDetective() ) and addCredits[v:GetNWString( "usergroup" )] then
			
			v:AddCredits( addCredits[v:GetNWString( "usergroup" )] )

		end

	end

end )

Where are you using this code?

From what I read I was supposed to put it in lua/autorun/server

heres the op.
http://www.facepunch.com/showthread.php?t=1373955

Bump?

Are you sure the hook is actually being called? Just put print(‘Hook Called’) or whatever text you want inside the hook. If you get the message in your server console, it is being called. Also, any particular reason he didn’t just use player:GetUserGroup? I believe the string is ‘UserGroup’. Replace v:GetNWString(‘usergroup’) with v:GetUserGroup().

Edit:Edited for clarity on what I said when I told him to ‘test it out.’

Ill try out what you’ve said & then get back to you :slight_smile:

I updated my original post so you can understand what I meant. I meant to test out replacing the v:GetNWString(“usergroup”) with v:GetUserGroup().

So if we look at the code I posted earlier you’re saying do this?


 -- Modify these as you want, the groupname on the left and the amount of credits they should be given on the right, follow the format
local addCredits = {
	["superadmin"] = 3
	["admin"] = 2
	["VIP"] = 1
}

hook.Add( "TTTBeginRound", "AddCredits", function()

	for k, v in pairs( player.GetAll() ) do
		
		if ( v:GetTraitor() or v:GetDetective() ) and addCredits[v:GetUserGroup()] then
			
			v:AddCredits( addCredits[v:GetUserGroup()] )

		end

	end

end )

Correct?

Yes, and insert [[ print(‘texthere’) ]] to make sure that the hook is actually called. This is to make sure that there is not something wrong with another hook that may be preventing this one from running (i.e. returning non-nil).



 -- Modify these as you want, the groupname on the left and the amount of credits they should be given on the right, follow the format
local addCredits = {
	["superadmin"] = 3
	["admin"] = 2
	["VIP"] = 1
}

hook.Add( "TTTBeginRound", "AddCredits", function()

	print('This hook was called (or some other shit).')

	for k, v in pairs( player.GetAll() ) do
		
		if ( v:GetTraitor() or v:GetDetective() ) and addCredits[v:GetUserGroup()] then
			
			v:AddCredits( addCredits[v:GetUserGroup()] )

		end

	end

end )


Is there a way I could force run the script? Like thought the console? (Just so I could see if the hook will be printed?)

Use can use lua_openscript to open a lua file, relative to the base /lua/ folder.

1st off… I can’t with your profile picture (Its funny as hell!) xD & 2nd would I do lua_openscript lua/autorun/server/(luafile?)

Hooks are being called properly, if you do anything right.
Do this:



 -- Modify these as you want, the groupname on the left and the amount of credits they should be given on the right, follow the format
local addCredits = {
	["superadmin"] = 3
	["admin"] = 2
	["VIP"] = 1
}

hook.Add( "TTTBeginRound", "AddCredits", function()

	for k, v in pairs( player.GetAll() ) do
		v:ChatPrint("The hook was called properly.")
		--if ( v:GetTraitor() or v:GetDetective() ) and addCredits[v:GetUserGroup()] then
			
		--	v:AddCredits( addCredits[v:GetUserGroup()] )

	--	end

	end

end )


Every player should see a “The hook was called properly” in his chat. The hook was called properly.
The round starts, nothing happens. You did something wrong.

I’ll be sure to try this out later today :slight_smile: Thanks!

Didn’t seem to work… & I copied exactly what you put .-. So I guess the hook isn’t being called :frowning:

Make sure that you put the lua-file into /lua/autorun.
Weird, that it doesn’t work :confused:

I’ll try that tomorrow. :slight_smile: Maybe it was because like in the OP I put it in /lua/autorun/server.

Sorry for the REALLY late reply… But it’s still not working… I put it in /garrysmod/lua/autorun :confused:

Bump?