Raised This Month: $12 Target: $400
 3% 

How to save player data?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-04-2020 , 21:37   How to save player data?
Reply With Quote #1

Hey, so I want to make a plugin for this dude on this post and I started making it. And after a while I was wondering how to save data from players. So here is the concept.

I want to make a plugin that when you hit level 10 (OciXCrom XP Plugin), you will have classes and you can choose your class, every class has different "abilities". Now what I did is simple checking for player current level and making menus.

And the way it is now, its quite simple, but when you have more classes , how do you remember which class did that player choose, how do I store which class did that player have, and store his "id".
supertrio17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-04-2020 , 21:47   Re: How to save player data?
Reply With Quote #2

If you're looking to save multiple pieces of data for each player, I would use nVault Array or SQL. I would create an enumerator for all data components and size the array with that, and use steam id as the key.

PHP Code:
enum PlayerData
{
    
szName33 ],
    
XPLevel,
    
szFavoriteIceCream16 ]
}
new 
pdDataMAX_PLAYERS ][ PlayerData ]; 
__________________

Last edited by Bugsy; 06-04-2020 at 21:49.
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-04-2020 , 22:01   Re: How to save player data?
Reply With Quote #3

So that would save data for each player, if this works how I think it is, this is awesome. I'm sorry if this question is kinda dumb, I started coding like 7-8 days ago
supertrio17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-04-2020 , 22:05   Re: How to save player data?
Reply With Quote #4

Yea, but you still need to know what you're doing to make it work correctly. This may be too big of a job at your experience level, but give it a try.
__________________
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-04-2020 , 22:17   Re: How to save player data?
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
Yea, but you still need to know what you're doing to make it work correctly. This may be too big of a job at your experience level, but give it a try.
I had experience in coding before, and this is preatty easy, for some reason I'm addicted to pawning now.

There is something in helping people that makes you feel better about yourself. I learned pawning for myself, but I have nothing to do with it now so I can at least help others.
supertrio17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-04-2020 , 22:26   Re: How to save player data?
Reply With Quote #6

Yeah if you have background in other languages, like C or something similar, you should pick it up pretty easy..at least for syntax.

The way the game/plugins work you may need some help with.
__________________
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-04-2020 , 22:34   Re: How to save player data?
Reply With Quote #7

So I got a quick look at this and if I got it correctly, you can store your arrays, strings and what not, and than just pull it from PlayerData, than I can just see if there is a player who isn't stored in PlayerData?

Edit: I could even do read_data() right?

Last edited by supertrio17; 06-04-2020 at 22:36.
supertrio17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-04-2020 , 22:40   Re: How to save player data?
Reply With Quote #8

Using what I posted above, you would set data to the player array like this:

PHP Code:
pdDataid ][ XPLevel ] = 55;
get_user_nameid pdDataid ][ szName] , charsmaxpdData[][ szName ] ) ); 
When it comes time to load and save the data, you would store/save using pdData[ id ]. This would include all data defined in the enum, since the enum was used to size the array.

Not sure what you mean with read_data(). This is used to read a parameter of a game event, like the killer or victim ID in a DeathMsg.

This is a good reference: http://www.amxmodx.org/api/
__________________

Last edited by Bugsy; 06-04-2020 at 22:41.
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-04-2020 , 22:41   Re: How to save player data?
Reply With Quote #9

I think I get it, thanks for replying so quickly
supertrio17 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode