karma dispenser

Would it be possible to write a script that would allow admins to set karma for other people?

Because no one answered you, Yes you can allow admins to set karma, however; I will not just give you the code. If you would like to figure it out yourself, you can go through the TTT code and check “karma.lua” in “gamemodes/terrortown/gamemode/” If you find what your looking for, but get stuck on your coding you can post what you have and we/I can help you.

Thanks panda =D

[editline]27th November 2012[/editline]

I dont seem to have the file “Gamemode” in my terrortown folder

That’s because it is included in the gcf (assuming you are running a listen server), just recreate the folders it should be in.

you could also go to ttt.badking.net and download it, it is under the release tab

The only thing that I found that seems like it might help at all are karma.givereward but that reward is only given if a traitor is killed. Maybe set live karma?

Since no one else seems willing, the function to set karma is player:SetLiveKarma and use :SetBaseKarma if you want it to update on the scoreboard.

Since no one is willing, there is a feature i personally tend to use to select a player…

if not p:IsValid() or p:IsAdmin() then
local d = string.lower(a[1] or “”)
local kam = a[2] or 1000
for k,v in pairs(player.GetAll()) do if string.find(string.lower(v:Nick()),d) then

Player Joined hook:
Player.Karma = 0

Player Check Karma function:
if Player.Karma then
return Player.Karma
return 0

Player Set Karma function:
Player.Karma = (Amount)

Then just make sure if you have a console command that sets karma, check if the player running it is an admin.

If you are new to lua and would like to try, I would suggest using Entity:GetNetworkedInt( Name )
This will allow you to call it to show on a scoreboards as well.

More info on here.

Thank you all even if you weren’t willing xD You were all a big help and I appreciate it!

Shouldn’t you use tonumber?

So what would be the code then?

concommand.Add(“ttt_setkarma”, function(client, command, arguments)
if ( IsValid(client) and client:IsAdmin() ) then
if (!arguments[1]) then
client:ChatPrint(“Missing name!”);

	elseif (!arguments[2]) then
		client:ChatPrint("Missing amount!");


	local name = string.lower(arguments[1]);
	local amount = tonumber(arguments[2]) or 1000;

	for k, v in pairs( player.GetAll() ) do
		if ( string.find(string.lower( v:Name() ), name) ) then


and would there be a client hook?

No, the SetLiveKarma function already networks it.

So say I wanted to set the karma for a player named Joe to 1000.

I would type:
ttt_setkarma Joe 1000


Thanks guys =3

[editline]28th November 2012[/editline]

map is it with a ! or a /

[editline]28th November 2012[/editline]

o.0 i think im doing something wrong its not working

[editline]28th November 2012[/editline]

It goes in the server folder right? It’s like it wont recognize the command or something

[editline]28th November 2012[/editline]

Nevermind!!! ILY guys!!