Ulysses
Home
Help
Ulysses
»
General
»
Developers Corner
»
end map dilemma
« previous next »
Print
Pages: [
1
]
Go Down
Author
Topic: end map dilemma (Read 4783 times)
0 Members and 1 Guest are viewing this topic.
talmera
Newbie
Posts: 36
Karma: 4
end map dilemma
«
on:
February 26, 2014, 08:58:11 pm »
Hi, I've been coding a cross server experience system for my community and I have it mostly ready for public testing but I'm having trouble figuring out how to get it to save the exp when the map is getting changed I have it saving fine on player disconnect.
I was wondering what would be the best approach to do this?
Logged
It's not a sin if it can't make me cry
He's not the devil unless there's fire in his eyes
It ain't the ghost if it don't speak in tongue
It's not a victory 'till the battles been won
Eccid
Full Member
Posts: 115
Karma: 11
Hey, come on... We just met...
Re: end map dilemma
«
Reply #1 on:
February 26, 2014, 09:06:24 pm »
Try using the
Shutdown Hook
and making it save then.
Logged
talmera
Newbie
Posts: 36
Karma: 4
Re: end map dilemma
«
Reply #2 on:
February 26, 2014, 09:15:30 pm »
oh cool I completely missed that hook when looking for a solution XD thanks I'll give it a go.
Logged
It's not a sin if it can't make me cry
He's not the devil unless there's fire in his eyes
It ain't the ghost if it don't speak in tongue
It's not a victory 'till the battles been won
talmera
Newbie
Posts: 36
Karma: 4
Re: end map dilemma
«
Reply #3 on:
February 27, 2014, 03:30:11 am »
Hmmm so I set up this function for use on the Shutdown hook you suggested but it's not called on map change like I was hoping?
Code: Lua
function
saveAll
(
)
for
k
,
v
in
pairs
(
player
.
GetAll
(
)
)
do
local
PlyFormat
=
string
.
Replace
(
v
:
SteamID
(
)
,
":"
,
""
)
local
PlySteam
=
v
:
SteamID
(
)
local
saver
=
Database
:
query
(
"UPDATE exp_storage SET `exp_total`='"
..
tec_PlyExp
[
PlySteam
]
..
"' WHERE `steam_id`='"
..
PlyFormat
..
"'"
)
saver
.
onSuccess
=
function
(
)
print
(
"[TGEXP] User saved to database"
)
end
saver
.
onError
=
function
(
)
print
(
"[TGEXP] save failed on leave"
)
end
saver
:
start
(
)
end
end
hook
.
Add
(
"ShutDown"
,
"savingAll"
,
saveAll
)
*Notes*
I am using the MySQLoo "addon" to update a database with the new values a player has for exp and I'm attempting to save all players on map change/server shutdown.
*Update*
after some tinkering it appears to be working now.
«
Last Edit: February 27, 2014, 07:50:45 am by talmera
»
Logged
It's not a sin if it can't make me cry
He's not the devil unless there's fire in his eyes
It ain't the ghost if it don't speak in tongue
It's not a victory 'till the battles been won
Megiddo
Ulysses Team Member
Hero Member
Posts: 6214
Karma: 394
Project Lead
Re: end map dilemma
«
Reply #4 on:
March 01, 2014, 02:44:14 pm »
Gmod crashes a lot, I'd recommend saving in intervals you're comfortable losing. E.g., if you only want to lose up to 30 seconds of data, save every 30 seconds.
Logged
Experiencing God's grace one day at a time.
Print
Pages: [
1
]
Go Up
« previous next »
Ulysses
»
General
»
Developers Corner
»
end map dilemma