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

SQL Help\code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-09-2009 , 11:43   SQL Help\code
Reply With Quote #1

I am trying to convert my VAC ban status plugin (see sig) from using nVault to SQLx. I have no experience in SQL and do not want to experiment with it on peoples servers. Is the AMX-X SQL protocol identical to that used by Windows? If so I could research it myself. The usage I need is fairly basic:

For each player, I need the following data, using the players STEAMID or IP as the lookup key:
0/1 [ban status] 12353543 [time-stamp]

What I need help with:
  • Setting up the db for fresh plugin installs
  • How to look up an entry using steamid\ip and retrieve the respective ban status and timestamp.
  • How to create an entry using items noted above
  • How to delete an entry
  • How to update an item (ie, suppose someone connects and their time-stamp has expired, instead of deleting the entry and creating a new one, just update the ban status and timestamp)

+karma to anyone who can help

Note: Yes, I have read the tutorial by hawk but that looks more geared towards people that already know SQL.
__________________
Bugsy is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 03-09-2009 , 12:06   Re: SQL Help\code
Reply With Quote #2

Well, now i see your plugin and I can help you.

Was info you need to save into db?
__________________

Last edited by AntiBots; 03-09-2009 at 12:15.
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-10-2009 , 01:00   Re: SQL Help\code
Reply With Quote #3

I need to find a ban value (0 or 1) and a timestamp for when the entry was written for a player. I want to use the players steamid or IP as the look-up key
__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-31-2009 , 23:08   Re: SQL Help\code
Reply With Quote #4

Bump
__________________
Bugsy is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 04-01-2009 , 04:45   Re: SQL Help\code
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post

For each player, I need the following data, using the players STEAMID or IP as the lookup key:
0/1 [ban status] 12353543 [time-stamp]




What I need help with:
  • Setting up the db for fresh plugin installs
  • How to look up an entry using steamid\ip and retrieve the respective ban status and timestamp.
  • How to create an entry using items noted above
  • How to delete an entry
  • How to update an item (ie, suppose someone connects and their time-stamp has expired, instead of deleting the entry and creating a new one, just update the ban status and timestamp)


the query commands are the same like php, but the handle is different. response calls a handle function not just in time (depends on db connection quality, ping)
  • send a CREATE TABLE IF NOT EXISTS query at plugin start
  • simple select query with WHERE, get response in the handle function
  • INSERT query
  • DELETE query
  • SELECT query, check timestamp in the handle function, if necessary make a UPDATE query
my english is very "well", so feel free to ask
i know, this is a very short explaination... but iīm currently @ work.
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.

Last edited by |PJ| Shorty; 04-01-2009 at 04:52.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-01-2009 , 11:23   Re: SQL Help\code
Reply With Quote #6

Quote:
Originally Posted by |PJ| Shorty View Post
the query commands are the same like php, but the handle is different. response calls a handle function not just in time (depends on db connection quality, ping)
  • send a CREATE TABLE IF NOT EXISTS query at plugin start
  • simple select query with WHERE, get response in the handle function
  • INSERT query
  • DELETE query
  • SELECT query, check timestamp in the handle function, if necessary make a UPDATE query
my english is very "well", so feel free to ask
i know, this is a very short explaination... but iīm currently @ work.
I do not know php or SQL and I do not want to experiment with this plugin that will be running on peoples servers. I'm hoping someone can contribute code.
__________________
Bugsy is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 04-02-2009 , 02:28   Re: SQL Help\code
Reply With Quote #7

some questions:

- steamid allowed more than once in the db?
- timestamp is the info when the ban expired? if expired delete the db entry?
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-03-2009 , 00:23   Re: SQL Help\code
Reply With Quote #8

Just one steam id in the db per player.

timestamp is set when the player connects for the first time (there is no entry in the db for this steamid) I want to retrieve this value on this players future connections and verify if the timestamp is expired, if so, delete entry.

My goal is to store a players VAC ban status so that a player will not keep getting re-checked every time he connects. If a VAC ban is found, the timestamp can be set to 0 or some other non-expireable value. If no VAC ban found then set a current timestamp so it can be later compared at future connections. The logic is once a player is banned then there is no possibility that he will be unbanned as VAC2 bans are permanent so no need to expire any db entries. However, if a player connects and has no VAC ban on record, there is a possibility that he can still be banned so we want to check this occasionally. To prevent the server from constantly checking the steam site for ban status I would rather store the ban status locally via the db and only check every 2 weeks or so, this is where the timestamp comes into play.
__________________

Last edited by Bugsy; 04-03-2009 at 00:28.
Bugsy is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 04-03-2009 , 15:46   Re: SQL Help\code
Reply With Quote #9

here is an example code, not tested but should work and you can see how this can be done.

select_user_db(id) search a player in the db. if exists store status and time-stamp from db to global vars, if not add the player to the db ( see line 98 )

update_user_db(id,status,timestamp) to update status and timestamp from a player in the db

delete_user_db(id) to delete a player from the db


if you need help feel free to ask
Attached Files
File Type: sma Get Plugin or Get Source (sqlx_example.sma - 775 views - 4.0 KB)
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.

Last edited by |PJ| Shorty; 04-05-2009 at 19:06. Reason: 2. plugin update
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-05-2009 , 09:27   Re: SQL Help\code
Reply With Quote #10

I added a few server_prints to the source so the error lineage may be 1 or 2 off in the source.

Code:
L 04/05/2009 - 09:25:35: [AMXX] Plugin ("sqlx_example.amxx") is setting itself as failed.
L 04/05/2009 - 09:25:35: [AMXX] Plugin says: SQL Query failed.
L 04/05/2009 - 09:25:35: [AMXX] Displaying debug trace (plugin "sqlx_example.amxx")
L 04/05/2009 - 09:25:35: [AMXX] Run time error 1: forced exit 
L 04/05/2009 - 09:25:35: [AMXX]    [0] sqlx_example.sma::SelectHandle (line 115)
__________________
Bugsy 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 23:09.


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