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

[Tut] MySql - Save/Load/Usefull Things (Xp Mod)


Post New Thread Reply   
 
Thread Tools Display Modes
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 08-20-2010 , 11:41   Re: [Tut] MySql - Save/Load/Usefull Things (Xp Mod)
Reply With Quote #31

Quote:
Originally Posted by katna View Post
why should i use my sql instead of nvault, is it better?
As far as i know is more faster than nvault and others files systems... and also you can combine mysql with others systems like with forum or others.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 08-22-2010 , 13:05   Re: [Tut] MySql - Save/Load/Usefull Things (Xp Mod)
Reply With Quote #32

The only thing nvault could be usefull for is a few data to save. nVault is slower and when u get to much data in, ur server will lag. Mysql doesnt cause lag ( when its done good ). Can handle much more data and can be used for websites ( online top 15 or w/e ).
__________________
I am out of order!
grimvh2 is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 08-23-2010 , 16:55   Re: [Tut] MySql - Save/Load/Usefull Things (Xp Mod)
Reply With Quote #33

The MySQL data storing and retrieving functions are much more powerful than those of nVault. For basic data storing this does not make that much of a difference, though. That's why MySQL tutorials are sometimes problematic. MySQL is so powerful that you can not cover all of it. If someone plans to use MySQL he will often have to find more sources and really learn the syntax of MySQL queries. Imho it would be much more helpful to provide a set of stocks that would make MySQL as easy to use as nVault.

A huge difference is that a real MySQL database (not SQLite) is entirely seperate from the server itself. Handling huge data structures can cause problems with nVault while MySQL, especially when you use threaded querying, will not use any resources of the server.

Another nice thing is, that you can often make your plugin compatible with MySQL and SQLite at the same time. That way the user can use an external database, necessary for integration into actual websites, but also fall back to local server-storage if no MySQL database is at hand.


Suggestions for the tutorial:
- I believe that the tuple variable is not updated by SQL_Connect so you don't need to check it everytime but should after the SQL_MakeDbTuple call instead.
- You can remove most SQL_Connect calls anyway. This is not necessary for threaded querying.
- In the save function you don't use the name of the user. You should remove the variable and the get_user_name call.
- However, if you plan to use the name, you should cover string escaping aswell.
- Use formatex where applicable (read: everywhere in this tutorial).
- Think about statics and a global query buffer.
- Any reason to delay MySQL_Init for that long?

That's all I can see right now.
__________________
In Flames we trust!
Nextra is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 09-03-2010 , 05:10   Re: [Tut] MySql - Save/Load/Usefull Things (Xp Mod)
Reply With Quote #34

Quote:
Originally Posted by Nextra View Post
The MySQL data storing and retrieving functions are much more powerful than those of nVault. For basic data storing this does not make that much of a difference, though. That's why MySQL tutorials are sometimes problematic. MySQL is so powerful that you can not cover all of it. If someone plans to use MySQL he will often have to find more sources and really learn the syntax of MySQL queries. Imho it would be much more helpful to provide a set of stocks that would make MySQL as easy to use as nVault.

A huge difference is that a real MySQL database (not SQLite) is entirely seperate from the server itself. Handling huge data structures can cause problems with nVault while MySQL, especially when you use threaded querying, will not use any resources of the server.

Another nice thing is, that you can often make your plugin compatible with MySQL and SQLite at the same time. That way the user can use an external database, necessary for integration into actual websites, but also fall back to local server-storage if no MySQL database is at hand.


Suggestions for the tutorial:
- I believe that the tuple variable is not updated by SQL_Connect so you don't need to check it everytime but should after the SQL_MakeDbTuple call instead.
- You can remove most SQL_Connect calls anyway. This is not necessary for threaded querying.
- In the save function you don't use the name of the user. You should remove the variable and the get_user_name call.
- However, if you plan to use the name, you should cover string escaping aswell.
- Use formatex where applicable (read: everywhere in this tutorial).
- Think about statics and a global query buffer.
- Any reason to delay MySQL_Init for that long?

That's all I can see right now.
Thx for the advice.

What do you mean with a global query buffer?
__________________
I am out of order!
grimvh2 is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 09-03-2010 , 06:05   Re: [Tut] MySql - Save/Load/Usefull Things (Xp Mod)
Reply With Quote #35

Just like you use a global variable to store errors you can use a global variable to store the queries you are formatting. There's no reason to create a new 512 variable everytime you need to make a query.
__________________
In Flames we trust!

Last edited by Nextra; 09-03-2010 at 20:40.
Nextra is offline
GuessWhat
Junior Member
Join Date: Oct 2010
Old 10-31-2010 , 01:41   Re: [Tut] MySql - Save/Load/Usefull Things (Xp Mod)
Reply With Quote #36

how do i get an sql server? what is hostname, pass ,db ? cause i got a plugin fail to load
GuessWhat is offline
FEELiFE
Member
Join Date: Jul 2010
Old 10-31-2010 , 02:28   Re: [Tut] MySql - Save/Load/Usefull Things (Xp Mod)
Reply With Quote #37

How can I get the XP of a player and add a prefix before the player's name based on the XP? (prefix in chat messages)
FEELiFE is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-31-2010 , 12:59   Re: [Tut] MySql - Save/Load/Usefull Things (Xp Mod)
Reply With Quote #38

Quote:
Originally Posted by GuessWhat View Post
how do i get an sql server? what is hostname, pass ,db ? cause i got a plugin fail to load
You have to get one with web hosting. Find a website that has free SQL databases or rent web hosting that has one.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
GuessWhat
Junior Member
Join Date: Oct 2010
Old 11-02-2010 , 01:43   Re: [Tut] MySql - Save/Load/Usefull Things (Xp Mod)
Reply With Quote #39

how i can update many field at the same time?
i have a database which contain steamid, goals, exp, points, exp, level, rank and so on. how can i update them all at once?
Code:
new goals[33]
new iExp[33]
new points[33]
new level[33]
new rank[33]
...
...
...
  format(szTemp,charsmax(szTemp),"UPDATE `tutorial` SET `exp` = '%i' WHERE `tutorial`.`steamid` = '%s';",iExp[id], szSteamId)
GuessWhat is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 11-02-2010 , 13:45   Re: [Tut] MySql - Save/Load/Usefull Things (Xp Mod)
Reply With Quote #40

PHP Code:
 format(szTemp,charsmax(szTemp),"UPDATE `tutorial` SET `exp` = '%i', `otherthing` = '%i', `astring` = '%s' WHERE `tutorial`.`steamid` = '%s';",iExp[id], otherthing[id], string[idszSteamId
Get it?
__________________
I am out of order!
grimvh2 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 09:46.


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