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

Database ORM (MySQL Data Wrapper) v1.1


Post New Thread Reply   
 
Thread Tools Display Modes
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-26-2014 , 11:34   Re: Database ORM (MySQL Data Wrapper) v1.0b
Reply With Quote #21

That's what the composite key is for. You cannot push entire arrays directly, but you can push several items per player IF THE COMPOSITE KEY IS DIFFERENT. -1 means that there is no composite key so there can only be one item per player.

Example: With an inventory system, you want the composite key to be the item index. You can push values such as these into the array:
player_index | item_id | amount
15815 | item_hamburger | 14
15815 | item_m4a1 | 10
15815 | item_something | 150
15815 | item_hamburger | 1 <- This won't work because the pair 15815-item_hamburger is unique.

I'll write an example on this later today.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 06-26-2014 at 12:13.
Backstabnoob is offline
Netsys
Senior Member
Join Date: Feb 2010
Old 06-26-2014 , 18:55   Re: Database ORM (MySQL Data Wrapper) v1.0b
Reply With Quote #22

I have this error with your plugin example:

With bot
L 06/26/2014 - 19:43:27: Invalid cellvector handle provided (11:0:0)
L 06/26/2014 - 19:43:27: [AMXX] Displaying debug trace (plugin "database_orm.amxx", version "1.0b")
L 06/26/2014 - 19:43:27: [AMXX] Run time error 10: native error (native "ArrayGetCell")
L 06/26/2014 - 19:43:27: [AMXX] [0] database_orm.sma::UTIL_GetPlayerClassItem (line 1579)
L 06/26/2014 - 19:43:27: [AMXX] [1] database_orm.sma::UTIL_FindInPlayerClassUniqu e (line 146
L 06/26/2014 - 19:43:27: [AMXX] [2] database_orm.sma::_CSRP_FindInPlayerClassUniq ue (line 522)
L 06/26/2014 - 19:43:27: Unhandled dynamic native error
L 06/26/2014 - 19:43:27: [AMXX] Displaying debug trace (plugin "example_orm.amxx", version "unknown")
L 06/26/2014 - 19:43:27: [AMXX] Run time error 10: native error (native "CSRP_FindInPlayerClassUnique")
L 06/26/2014 - 19:43:27: [AMXX] [0] example_orm.sma::CSRP_OnPlayerLoad (line 151)

With me
L 06/26/2014 - 20:07:26: Player 6 not connected.
L 06/26/2014 - 20:07:26: [AMXX] Displaying debug trace (plugin "example_orm.amxx", version "unknown")
L 06/26/2014 - 20:07:26: [AMXX] Run time error 10: native error (native "CSRP_FindInPlayerClassUnique")
L 06/26/2014 - 20:07:26: [AMXX] [0] example_orm.sma::CSRP_OnPlayerLoad (line 151)

Last edited by Netsys; 06-26-2014 at 19:08.
Netsys is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-26-2014 , 19:40   Re: Database ORM (MySQL Data Wrapper) v1.0b
Reply With Quote #23

I'll check it out, it seems that the player is loaded faster than it actually takes him to connect -.-
Gonna figure out a workaround and post it later, using client_putinserver instead of client_connect would probably work but eh.

Edit: Fixed, there was one more problem. Thanks for actually trying the example plugin for me, the problem was in trying to access the first element in the array when there is no data yet (CSRP_FindInPlayerClassUnique).
Also changed client_connect to client_putinserver to prevent player not connected errors until I find a better way to deal with this. Example code is fine and works great, problem was in the API.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 06-26-2014 at 20:17.
Backstabnoob is offline
Netsys
Senior Member
Join Date: Feb 2010
Old 06-26-2014 , 20:21   Re: Database ORM (MySQL Data Wrapper) v1.0b
Reply With Quote #24

Quote:
Originally Posted by Backstabnoob View Post
I'll check it out, it seems that the player is loaded faster than it actually takes him to connect -.-

Gonna figure out a workaround and post it later, using client_putinserver instead of client_connect would probably work but eh.
i changed client connect to client authorized and worked well.

I have a question, in the example plugin with this:
PHP Code:
ArraySetCellaBankAccountBank_MoneyiBankMoney iArgs 
update the player's account in the database?
Netsys is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-26-2014 , 20:26   Re: Database ORM (MySQL Data Wrapper) v1.0.1b
Reply With Quote #25

There was one more problem, please download the updated version. client_authorized is still not reliable enough as it was giving me the error too occasionally.

To answer your question, yes, that is correct. ArraySetCell on the item array is all you need.

Edit: As a cool plugin using this, I'm thinking of rewriting my private achievements system to use this and release it. It has many more features than the existing systems have, so it could get some usage.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 06-26-2014 at 20:55.
Backstabnoob is offline
Netsys
Senior Member
Join Date: Feb 2010
Old 06-26-2014 , 21:53   Re: Database ORM (MySQL Data Wrapper) v1.0.1b
Reply With Quote #26

Quote:
Originally Posted by Backstabnoob View Post
To answer your question, yes, that is correct. ArraySetCell on the item array is all you need.
mmm it's like a array reference?

And i have another question, the playerkey of my steamid is -2117842924, it's normal?

Last edited by Netsys; 06-26-2014 at 21:57.
Netsys is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-27-2014 , 04:17   Re: Database ORM (MySQL Data Wrapper) v1.0.1b
Reply With Quote #27

Pretty much, you get a direct pointer to the array. That also means using other options (like deleting an element from it or changing the type from cell to array) can potentially break the whole plugin, so be careful.

Yes, it's normal. No worries. It's negative if your Steam ID looks like this: STEAM_0:1:XXX - it takes the last number (XXX) and subtracts (1<<31) from it. -2117842924 + 2147483648 (which is 1<<31) should give you XXX.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 06-27-2014 at 07:04.
Backstabnoob is offline
ArabicMan
Veteran Member
Join Date: Feb 2014
Location: مصر
Old 06-29-2014 , 12:39   Re: Database ORM (MySQL Data Wrapper) v1.0.1b
Reply With Quote #28

Good job anyway.
ArabicMan is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 07-02-2014 , 07:45   Re: Database ORM (MySQL Data Wrapper) v1.0.1b
Reply With Quote #29

Started rewriting my achievements from scratch. Will post a new thread in a couple of days/weeks!
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 07-23-2014 , 07:36   Re: Database ORM (MySQL Data Wrapper) v1.1
Reply With Quote #30

v1.1
  • Changed my coding style
  • Fixed a variety of bugs and overally improved the code
  • CSRP_FindXXX natives now also pass the array index by reference
  • Release date: 23 Jul, 2014 (23 downloads reset)
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob 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 18:11.


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