Fixed Save & Load Functions for Level System

Useless Stuffs, Spam ... etc
Post Reply
User avatar
TheWhitesmith
Member
Member
Morocco
Posts: 33
Joined: 6 years ago
Location: Temara/Rabat
Contact:

Fixed Save & Load Functions for Level System

#1

Post by TheWhitesmith » 6 years ago

Well, this is a temporary (if not permanent, as I never lost data) solution to the reset of Levels & Coins.
This is the procedure (This one is for Levels System, same can be applied to Coins System)
Can't provide the whole source because I've modified alot in the code which may affect your gameplay or trigger errors on your server. That's very enough to fix the original one.


Code: Select all

public LoadData(id)
{
	new szData[256], szDataXp[256], szName[32], key[64], key_xp[64]

	get_user_name(id, szName, charsmax(szName)) // In my server I save data for Names, Edit this if you use AuthID
	
	format(key, 63, "%s-/", szName) 
     
	format(key_xp, 63, "%s-/", szName) 
	
	nvault_get(g_szVaultLevel, key, szData, 255) 
	nvault_get(g_szVaultXP, key_xp, szDataXp, 255)
	
	replace_all(szData, 255, "#", " ") 
	replace_all(szDataXp, 255, "#", " ")
	
	new givelevel[32], give_exp[32] 
	parse(szData, givelevel, 31) 
	parse(szDataXp, give_exp, 31)
	
	g_iLevel[id] = str_to_num(givelevel) 
	g_iXP[id] = str_to_num(give_exp) 
	
	return PLUGIN_CONTINUE
}

public SaveData(id)
{
	new szAuthID[32]
	get_user_name(id, szAuthID, charsmax(szAuthID)) // In my server I save data for Names, Edit this if you use AuthID
	
	new szData[256], szDataXp[256], key[64], key_xp[64]
	
	format(key, 63, "%s-/", szAuthID) 
	format(szData, 255, "%i#", g_iLevel[id]) 
     
	format(key_xp, 63, "%s-/", szAuthID) 
	format(szDataXp, 255, "%i#", g_iXP[id])
	
	nvault_set(g_szVaultLevel, key, szData) 
	nvault_set(g_szVaultXP, key_xp, szDataXp)
	
	return PLUGIN_CONTINUE; 
}
[SYA] CSGO-Mod for CS 1.6 [ Cases/Keys/Rank ][/size]
IP: 149.202.251.74:27016

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#2

Post by Night Fury » 6 years ago

If you could do the same with levels' source file and upload it on its topic, we will be very greatfull to you.
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

User avatar
TheWhitesmith
Member
Member
Morocco
Posts: 33
Joined: 6 years ago
Location: Temara/Rabat
Contact:

#3

Post by TheWhitesmith » 6 years ago

That's the Levels, you mean Escape Coins? Maybe I didnt understand your request.
[SYA] CSGO-Mod for CS 1.6 [ Cases/Keys/Rank ][/size]
IP: 149.202.251.74:27016

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#4

Post by Raheem » 6 years ago

I'll test it soon when get time but i see the code, You seems not saving Max-XP for the current level player in so you resolve this with level ok good point i'll try to apply in the original code. But i see The code for saving anyway is same so this may not fix much. The reset problem related to variable values in PAWN it was like when saving i logged the value of this variable: g_iEscapeCoins[id] for this player it was = 0 that's the whole problem although it's current escape coins not 0. So basically the problem related to saving not loading. Furthermore i made Temp. Solution i don't need to post right now but will think when get time.
He who fails to plan is planning to fail

User avatar
TheWhitesmith
Member
Member
Morocco
Posts: 33
Joined: 6 years ago
Location: Temara/Rabat
Contact:

#5

Post by TheWhitesmith » 6 years ago

I actually used the same syntax a known FFA server used to save XP/Level for its users. It's been more than a Year (even more) and I still have my own level. So I requested the plugin in .amxx format and I decompiled it successfully.
[SYA] CSGO-Mod for CS 1.6 [ Cases/Keys/Rank ][/size]
IP: 149.202.251.74:27016

User avatar
TheWhitesmith
Member
Member
Morocco
Posts: 33
Joined: 6 years ago
Location: Temara/Rabat
Contact:

#6

Post by TheWhitesmith » 6 years ago

Also I've been using this syntax for every plugin I've made (basically JailBreak Shop) and I've never found Problems using it! But If you could find a better way to save I'll definitely start using it.
[SYA] CSGO-Mod for CS 1.6 [ Cases/Keys/Rank ][/size]
IP: 149.202.251.74:27016

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#7

Post by Raheem » 6 years ago

What i mean there is no difference between your code and ours. You can say what differ?
He who fails to plan is planning to fail

User avatar
TheWhitesmith
Member
Member
Morocco
Posts: 33
Joined: 6 years ago
Location: Temara/Rabat
Contact:

#8

Post by TheWhitesmith » 6 years ago

First of all, I'm not saving Max XP. I'm also saving in 2 different vaults.

Code: Select all

g_szVaultLevel = nvault_open("Level_Vault") 
g_szVaultXP = nvault_open("XP_Vault")
I dont know why this works very well, but it does.
[SYA] CSGO-Mod for CS 1.6 [ Cases/Keys/Rank ][/size]
IP: 149.202.251.74:27016

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#9

Post by Night Fury » 6 years ago

TheWhitesmith wrote: 6 years ago First of all, I'm not saving Max XP. I'm also saving in 2 different vaults.

Code: Select all

g_szVaultLevel = nvault_open("Level_Vault") 
g_szVaultXP = nvault_open("XP_Vault")
I dont know why this works very well, but it does.
Do you save levels in a file & XP in anther file?
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

User avatar
TheWhitesmith
Member
Member
Morocco
Posts: 33
Joined: 6 years ago
Location: Temara/Rabat
Contact:

#10

Post by TheWhitesmith » 6 years ago

Jack GamePlay wrote: 6 years ago Do you save levels in a file & XP in anther file?
Yeah I do, I've seen many advanced coders use it and I'm convinced it makes things more stable.
[SYA] CSGO-Mod for CS 1.6 [ Cases/Keys/Rank ][/size]
IP: 149.202.251.74:27016

User avatar
sam_bhosale4
Mod Tester
Mod Tester
India
Posts: 109
Joined: 7 years ago
Location: INDIA
Contact:

#11

Post by sam_bhosale4 » 6 years ago

TheWhitesmith wrote: 6 years ago
Jack GamePlay wrote: 6 years ago Do you save levels in a file & XP in anther file?
Yeah I do, I've seen many advanced coders use it and I'm convinced it makes things more stable.
yeah indeed.. Its really good to use different files for level and coins.. you did good..
-=SeRious-GaminG|Zombie Escape[Alien vs. Predator]|Asia=-
206.189.132.169:40000
Image

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#12

Post by Raheem » 5 years ago

Already fixed in v1.3, Trashed.
He who fails to plan is planning to fail

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 2 guests