Smartness

[release]Smartness

Currently in livetime development at: flaming-gummy-bear’s Server!

A recreation of Facepunch’s old Smartness module.
[/release]

Concepts:
:downs:
[ul]
[li]Decreases with misspelling[/li][li]New player methods[/li][li]Increases with each post[/li][/ul]

Developer features:
:science:

Added HUD Elements:

“CHudSmartness” - Displays your smartness in the style of a HL2 indicator, shows up next to your health or armor.

Disable using:

[lua]local function HUDShouldDraw( name )

// So we don't draw smartness on the HUD
if ( name == "CHudSmartness" ) then return false end

end[/lua]

New methods:

Player:AddSmartness( int smartness ) - Adds to a player’s smartness
Player:GetSmartness() - Retrieves the player’s current smartness
Player:RemoveSmartness( int smartness ) - Removes from a player’s smartness
Player:SetSmartness( int smartness ) - Sets a player’s smartness

Rating this dumb is ironic. Do it.


(User was autobanned for this post - ("Losing over 5000 smartness in a single post" ))

How does it go up? 1+1=2?

Yeah, I’m thinking it’ll have a manifest of words that will determine when it goes down.

Memes should lower smartness. A 0 smartness results in constant death even when you spawn.

I think on Facepunch once you hit zero, you were banned for a while, I intend on doing the same for servers. I’ll be using archive.org to reference the smartness junk from the past.

Make them have to chat their way back to life!

Haha, maybe. But a 24h ban seems more conformist to the old module.

[editline]04:52PM[/editline]

Added a link to the server, currently up testing it out.

Wow, awesome.

This system looks like it could be used as an automatic moderation system for much more then just spelling ( losing smartness for kills in serious build\rp ) . I like it! :smile:

Great idea.

Completely possible.

[lua]
local function DumbPlayerDeath( Victim, Inflictor, Killer )

if ( !string.find( GAMEMODE.Name:lower(), "rp" ) ) then return end
if ( !Killer:IsValid() ) then return end
if ( !Killer:IsPlayer() ) then return end
if ( Killer:IsAdmin() ) then return end

Killer:RemoveSmartness( 100 )

end

hook.Add( “PlayerDeath”, “DumbPlayerDeath”, DumbPlayerDeath )
[/lua]

I’ve hatched little ideas out of the methods, such as a Dumbnade, players caught within the blast of the grenade lose dumbness based on distance from the epicentre.

[editline]08:09PM[/editline]

(I wanted to use “epicentre” instead of “epicenter”, because it looks cooler.)

In place of “bullet time” you could have “dumb time” where you gain smartness for doing dumb things. :v:

While it sounds like an interesting idea, a Dumbnade would defeat the purpose of the addon. It’s supposed to determine whether or not you’re smart. An idiotic minge could take a Dumbnade and toss it into a group of intelligent builders, diligently working on their next contraption.

It’s really up to the idiotic developers.

Gimme boxes. I wanna put my penis in them.

[editline]08:17PM[/editline]

Can anyone help me with a simple MySQL query? I’ve attempted to use the same type of system used to record ratings, as this is a similar concept, however it is not working at the moment.

I really don’t want to have to result to something stupid like using .txt files to record player data.

Here’s what I have so far:

I think you’re doing a lot more than you need to. All you need is something like this:

[lua]sql.Query(“CREATE TABLE IF NOT EXISTS smartness(‘steam’ TEXT NOT NULL, ‘smarts’ INTEGER NOT NULL, PRIMARY KEY(‘steam’));”)

function SaveData(pl)
sql.Query(“UPDATE smartness SET smarts = “…pl:GetNWInt(“Smartness”)…” WHERE steam = “…sql.SQLStr(pl:SteamID())…”;”)
end

function LoadData(pl)
ply:SetNWInt(“Smartness”,tonumber(sql.QueryValue(“SELECT smarts FROM smartness WHERE steam = “…sql.SQLStr(pl:SteamID())…”;”)))
end[/lua]

Also, it would be more optimized if you saved the player’s data to the SQLite database on disconnect rather than every time they lose/gain smarts.

In all honesty, I know this sounds ridiculous, but I have OCD that manifests within my coding, and have to have it a certain way just to comfort myself…

Is this conceptually valid code?

Internal: UpdatePlayerSmartness
[lua]/---------------------------------------------------------
Name: Update the player’s networkvars based on the DB
---------------------------------------------------------
/
local function UpdatePlayerSmartness( ply )

local result = sql.QueryValue( "SELECT int FROM smartness WHERE target = "..ply:UniqueID().." " )

if ( !result ) then return end

ply:SetNetworkedInt( "Smartness", tonumber( result ) )

end[/lua]

Player.SetSmartness
[lua]function meta:SetSmartness( smartness )

if ( !sv_smartness:GetBool() ) then return end

sql.Query( "UPDATE smartness SET int = "..tonumber( smartness ).." WHERE target = "..self:UniqueID().." " )

// We changed something so update the networked vars
UpdatePlayerSmartness( self )

end[/lua]

Can I ask what font did you use to display the smartness amount?
Or if it’s not a font then what is it?

I looked for it, checked the source, but no font I could find looked like it… :frown:

You mean my replica of the HL2 HUD? I will gladly hand the code over my friend.

Here’s my mimic of the sprint styled form, in which I take up the unused sprint HUD space for my ownership module.

Here’s another mimic using exactly what you asked for, the smartness display:

These layouts are dependent on calculations from garrysmod/scripts/HudLayout.res, but do not use the actual file themselves. Rather, I took the measurement from there to replicate a clean display on the HUD.

Considering that ScreenScale isn’t mathematically proportional to the actual scale of the end-user’s screen, I wrote a correction and added it to the surface library, as to not overwrite a global function that many people already use.

Values within this file will help throw your positions in pixel perfect space.
http://code.google.com/p/gmodplus/source/browse/trunk/lua/autorun/client/gmpcl_hud_functions.lua

Thanks a lot! We need more persons like you around here!

You’re welcome. :smiley: I hope I can help out the community more in the future.