Ulysses Stuff > Releases

Utime -- Show how long your players have been connected this session and total

<< < (4/84) > >>

Megiddo:
As far as I see it TehBigA, I released mine two days ago where you released yours an hour ago. ;)

TehBigA:
Sorry that I had the bug checks run for 3 days prior to release, ask president he said i should wait and guess what i found a bunch of bugs esp a rare one that cause a reinstall of the script, and now look what i get because you just had to "use mine as a template" http://forums.facepunchstudios.com/showthread.php?t=473802 thanks a bunch

MrPresident:
guys. Please..

Here is the bottom line..

We released the origonal script.
Megiddo made one from scratch when it was suggested for him to have one on his server.

We decided to improve ours, and I told Megiddo what we were doing. (which was probably a bad Idea, but I didn't think that it would lead to this.)
We did a private release on my server to test the script for bugs. JamminR can confirm this, because I invited him to my server to see teh script in action a few days after we installed it. (this was I believe before Megiddo released his version).
Megiddo Decided what we were doing was a good idea.. and decided to add it to his script as well. (though I dont believe he'd ever even seen our script in action.. let alone have access to the code. (if they are similar.. it's probably just a coincidence))
Megiddo released his script.. which prompted us to release ours.

Now people think it was us who stole ideas and code from Megiddo which is complete BS.
No one stole anything from anyone. They are two completely seperate scripts which were released at the same time. END OF STORY..

Now.. lets just drop the accusations.. and move on.

JamminR:
And, just for assurance sake, I did _not_ mention to Megiddo that Big had added color adjustment.
I actually thought it funny when I saw that he'd added them.
Geez. It's a time script. It's not the nobel prize.

Lt.Smith:
Moving on works for me, because I need a little help, please. I hate asking for other people to do stuff for me, but I can't figure out what I've done wrong...

Here's the edited code:


--- Code: ----- Written by Team Ulysses, http://ulyssesmod.net/


module( "Utime", package.seeall )
if not SERVER then return end

require( "mysql" )
 
host = "hostname"
username = "username"
password = "password"
database = "database"
port = "1234"
 
local db, error = mysql.connect(host, username, password, database, port)
if !db then print(tostring(error) .. " in connection \n") return end

function onJoin( ply )
local uid = ply:UniqueID()

totaltime, isok, error = mysql.query(db, "SELECT totaltime FROM utime WHERE player = " .. uid .. ";")
if !isok then
print(tostring(error) .. " in selecting totaltime \n");
end

lastvisit, isok, error = mysql.query(db, "SELECT lastvisit FROM utime WHERE player = " .. uid .. ";")
if !isok then
print(tostring(error) .. " in selecting lastvisit \n");
end

local time = 0

if (lastvisit) AND (totaltime) then
ULib.tsay( ply, "[UTime]Welcome back " .. ply:Nick() .. ", you last played on this server " .. os.date( "%c", lastvisit ) )
var, isok, error =  mysql.query(db, "UPDATE utime SET lastvisit = " .. os.time() .. " WHERE player = " .. uid .. ";")
if !isok then
print(tostring(error) .. " in updating lastvisit! \n")
end
time = totaltime
else
ULib.tsay( ply, "[UTime]Welcome to our server " .. ply:Nick() .. "!" )
var, isok, error = mysql.query(db, "INSERT into utime ( player, totaltime, lastvisit ) VALUES ( " .. uid .. ", 0, " .. os.time() .. " );")
if !isok then
print(tostring(error) .. "in creating profile! \n")
end
end
ply:SetUTime( time )
ply:SetUTimeStart( CurTime() )
end
hook.Add( "PlayerInitialSpawn", "UTimeInitialSpawn", onJoin )

function updatePlayer( ply )
var, isok, error = mysql.query(db, "UPDATE utime SET totaltime = " .. math.floor( ply:GetUTime() + CurTime() - ply:GetUTimeStart() ) .. " WHERE player = " .. ply:UniqueID() .. ";" )
if !isok then
print(tostring(error) .. " in updating player! \n")
end
end
hook.Add( "PlayerDisconnected", "UTimeDisconnect", updatePlayer )

function updateAll()
local players = player.GetAll()

for _, ply in ipairs( players ) do
if ply and ply:IsConnected() then
updatePlayer( ply )
end
end
end
timer.Create( "UTimeTimer", 67, 0, updateAll )
--- End code ---

I realise this is huge... but ok. I'd very much appreciate someone looking over it and pointing out my mistakes. :)

Previously the problem was that on initial spawn it always went for this part of the if statement:

--- Code: ---if row then
ULib.tsay( ply, "[UTime]Welcome back " .. ply:Nick() .. ", you last played on this server " .. os.date( "%c", lastvisit ) )
var, isok, error =  mysql.query(db, "UPDATE utime SET lastvisit = " .. os.time() .. " WHERE player = " .. uid .. ";")
if !isok then
print(tostring(error) .. " in updating lastvisit! \n")
end
time = totaltime
--- End code ---

but I changed the query into two seperate ones (lastvisit and totaltime) and now the script does, well, nothing. The counter appears clientside and all that jazz but all the gnarly bits seem to be laughing at me.

Thanks for any help,

Smith

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version