Welcome, Guest. Please login or register.
Did you miss your activation email?
November 23, 2024, 07:21:13 AM
Home Help Login Register
News: Zombie Master 2 discussion

Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Need help on a karma code for my self
Pages: [1]
Author Topic: Need help on a karma code for my self  (Read 6240 times)
simmerdown
Poster

Posts: 70

www.ms3dguns.com


« on: August 30, 2010, 04:02:53 PM »

Ok what i need to achief is ( im gonne put it in karma.lua in gamemodes terrortown ):

when player gets karma 700  player gets a fake achiefment style message that their karma is to low and they should watch out,

my idea is like this but it would not work ofcourse bcus im not a lua scripter but then you get an idea of how i kinda want it, i just need a profesional lua coder to help me out to get a working way to do this.. ( using evolve as well or anyhow u could make it to work for me i just show u it how i kinda want it but again im not a lua coder so it WONT logically i know why it wont work bcus the codes are unreal.


this is what i want, im not sure how to , and what the commands in lua are but ill just tell u the basic what i want:

if karma = <700 then
blahblah warn player text colour_red ( visible to all on server) "Warning ( playername) " Colour_Gold "Low karma:  colour_red( current karma level ) Colour_gold  Be Carefull AutoKick is at: Colour_red  ( The karma ammount when kick is enabled)!! "



Warning (playername) Low Karma: (ammount of karma) Be Carefull Autokick is at: (low karma autokick ammount number)


something like that

thank you for your help
« Last Edit: August 30, 2010, 04:08:57 PM by simmerdown »
Sam
Poster

Posts: 22



« Reply #1 on: August 30, 2010, 06:41:12 PM »

I haven't tested, but this should work.
//karma.lua - at the end of the KARMA.ApplyKarma function
if ply:GetBaseKarma() <= 700 then
umsg.Start( "LowKarmaWarning", ply )
umsg.Entity( ply )
umsg.End()
end

//cl_init.lua - at the end of the script
local function WarningReceived( data )

local ply = data:ReadEntity()
if !IsValid( ply ) then return end

local color_red = Color(255,0,0)
local color_gold = Color(255,165,0)

chat.AddText(
color_red, "Warning", ply:Nick(),
color_gold, " Low Karma: ",
color_red, ply:GetBaseKarma(),
color_gold, " Be Careful Autokick is at ",
color_red, GetConVarString( "ttt_karma_low_amount" ) )
end
usermessage.Hook( "LowKarmaWarning", WarningReceived )

Add the code to the files and location specified.

If you get an error, post the exact error message you receive.
« Last Edit: August 30, 2010, 10:09:56 PM by Sam »

http://www.steamcommunity.com/id/samm5506
simmerdown
Poster

Posts: 70

www.ms3dguns.com


« Reply #2 on: August 30, 2010, 08:03:55 PM »

ok i need 3 players to test it so it will have to wait, i did it like this did you mean it like this:

init:( lot of more lines abouve this )
                                                                 gui.EnableScreenClicker(false)
                                                              end)
        gui.EnableScreenClicker(true)
      elseif CurTime() > (idle.t + (idle_limit / 2)) then
        -- will repeat
        MSTACK:AddMessage("WARNING: YOU APPEAR TO BE IDLE/AFK, AND WILL BE MADE TO SPECTATE UNLESS YOU SHOW ACTIVITY!")
      end
  end
  local function WarningReceived( data )
local color_red = Color(255,0,0)
local color_gold = Color(255,165,0)

chat.AddText(
color_red, "Warning", LocalPlayer():Nick(),
color_gold, " Low Karma: ",
color_red, data:ReadString(),
color_gold, "Be Careful Autokick is at",
color_red, data:ReadString() )
end
usermessage.Hook( "LowKarmaWarning", WarningReceived )
end




karma lua:
function KARMA.ApplyKarma(ply)
  local df = 1

  -- any karma at 1000 or over guarantees a df of 1, only when it's lower do we
  -- need the penalty curve
  if ply:GetBaseKarma() < 1000 then
      df = 1 + -0.0000025 * ((ply:GetBaseKarma() - 1000)^2)
  end

  ply:SetDamageFactor(math.Clamp(df, 0.1, 1.0))

  if IsDebug() then
      print(Format("%s has karma %f and gets df %f", ply:Nick(), ply:GetBaseKarma(), df))
  end
 
  if ply:GetBaseKarma() < 700 then
umsg.Start( "LowKarmaWarning", ply )
umsg.String( ply:GetBaseKarma() )
umsg.String( GetConVarString("ttt_karma_low_amount") )
umsg.End()
end

end
Sam
Poster

Posts: 22



« Reply #3 on: August 30, 2010, 08:06:03 PM »

Put the section in init.lua at the very bottom of the script, not inside any functions. It should be in it's own section.

http://www.steamcommunity.com/id/samm5506
simmerdown
Poster

Posts: 70

www.ms3dguns.com


« Reply #4 on: August 30, 2010, 08:16:11 PM »

Put the section in init.lua at the very bottom of the script, not inside any functions. It should be in it's own section.


like this:

          -- will repeat
        MSTACK:AddMessage("WARNING: YOU APPEAR TO BE IDLE/AFK, AND WILL BE MADE TO SPECTATE UNLESS YOU SHOW ACTIVITY!")
      end
  end
end

local function WarningReceived( data )
local color_red = Color(255,0,0)
local color_gold = Color(255,165,0)

chat.AddText(
color_red, "Warning", LocalPlayer():Nick(),
color_gold, " Low Karma: ",
color_red, data:ReadString(),
color_gold, " Be Careful Autokick is at ",
color_red, data:ReadString() )
end
usermessage.Hook( "LowKarmaWarning", WarningReceived )

Sam
Poster

Posts: 22



« Reply #5 on: August 30, 2010, 08:17:50 PM »

Yes.

http://www.steamcommunity.com/id/samm5506
Manmax75
Poster

Posts: 254


Programming Guy


« Reply #6 on: August 30, 2010, 08:21:05 PM »

yes, also make sure its cl_init not just init

Ride Forward and Thrust Your Pelvis In The Dark Void. The One Induced By Pleasure Yet Cast By The Bigger Picture.
simmerdown
Poster

Posts: 70

www.ms3dguns.com


« Reply #7 on: August 30, 2010, 08:23:52 PM »

yes, also make sure its cl_init not just init



yes, cl_init.lua i know,




do i have to close the usermessagehook command with end as well?
Sam
Poster

Posts: 22



« Reply #8 on: August 30, 2010, 08:32:58 PM »

do i have to close the usermessagehook command with end as well?

Why not just test it out and not tamper with the code I wrote for you? Don't you think I would complete the code for you before I posted it?

http://www.steamcommunity.com/id/samm5506
simmerdown
Poster

Posts: 70

www.ms3dguns.com


« Reply #9 on: August 30, 2010, 08:37:35 PM »

k ok im soryr i just foudn it weird that on each function there is a end exept for this, sorry for asking.
Sam
Poster

Posts: 22



« Reply #10 on: August 30, 2010, 08:43:58 PM »

Why not just test it out and not tamper with the code I wrote for you? Don't you think I would complete the code for you before I posted it?

If you're curious, why not look it up on the GMod Lua wiki? http://wiki.garrysmod.com/?title=Usermessage.Hook

Not everything in Lua has the "function Name() <code> end" format.

EDIT: Fixed the code, if you had errors they may be fixed now.
//karma.lua - at the end of the KARMA.ApplyKarma function
if ply:GetBaseKarma() <= 700 then
umsg.Start( "LowKarmaWarning", ply )
umsg.Entity( ply )
umsg.End()
end

//cl_init.lua - at the end of the script
local function WarningReceived( data )

local ply = data:ReadEntity()
if !IsValid( ply ) then return end

local color_red = Color(255,0,0)
local color_gold = Color(255,165,0)

chat.AddText(
color_red, "Warning", ply:Nick(),
color_gold, " Low Karma: ",
color_red, ply:GetBaseKarma(),
color_gold, " Be Careful Autokick is at ",
color_red, GetConVarString( "ttt_karma_low_amount" ) )
end
usermessage.Hook( "LowKarmaWarning", WarningReceived )
« Last Edit: August 30, 2010, 10:11:02 PM by Sam »

http://www.steamcommunity.com/id/samm5506
simmerdown
Poster

Posts: 70

www.ms3dguns.com


« Reply #11 on: August 31, 2010, 03:37:01 PM »

hey sam thank you for an update, im still not able to test it,
if you want please add my steam  Dueagleseye if you ever have time to join up in the server maybe you can give some suggestions as well
Sam
Poster

Posts: 22



« Reply #12 on: August 31, 2010, 03:43:39 PM »

hey sam thank you for an update, im still not able to test it,
if you want please add my steam  Dueagleseye if you ever have time to join up in the server maybe you can give some suggestions as well

You should be able to test it by yourself. Just type in console bot a couple of times and get your karma low. Also, I will not be able to test with you as I am busy coding my own edit of TTT.

http://www.steamcommunity.com/id/samm5506
simmerdown
Poster

Posts: 70

www.ms3dguns.com


« Reply #13 on: August 31, 2010, 05:27:43 PM »

only : color_gold, " Be Careful Autokick is at ",


is shown, the ammount isnt shown after it, and for some reason i deleted my whole config file wtf:S i dont know how i did that so i be fixing this i need to find all settings which i had -,- stupit i dont even know why it did this.
Pages: [1]
Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Need help on a karma code for my self « previous next »
Jump to:  


Login with username, password and session length

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
Page created in 0.012 seconds with 18 queries.