• karma dispenser
    17 replies, posted
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... concommand.Add("ttt_setkarma",function(p,c,a) 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 v:SetLiveKarma(kam) v:SetBaseKarma(kam) end end end end)
Player Joined hook: Player.Karma = 0 Player Check Karma function: if Player.Karma then return Player.Karma else return 0 end 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 [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8f6d.html"]Entity:GetNetworkedInt( Name )[/URL] This will allow you to call it to show on a scoreboards as well. More info on here. [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8f6d.html[/url]
Thank you all even if you weren't willing xD You were all a big help and I appreciate it!
[QUOTE=Chrik;38622503]Since no one is willing, there is a feature i personally tend to use to select a player... concommand.Add("ttt_setkarma",function(p,c,a) 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 v:SetLiveKarma(kam) v:SetBaseKarma(kam) end end end end)[/QUOTE] Shouldn't you use tonumber?
So what would be the code then?
[lua] concommand.Add("ttt_setkarma", function(client, command, arguments) if ( IsValid(client) and client:IsAdmin() ) then if (!arguments[1]) then client:ChatPrint("Missing name!"); return; elseif (!arguments[2]) then client:ChatPrint("Missing amount!"); return; end; 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 v:SetLiveKarma(amount); v:SetBaseKarma(amount); end; end; end; end);[/lua]
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
Ya
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!!
Sorry, you need to Log In to post a reply to this thread.