Raised This Month: $ Target: $400
 0% 

Check for date from sql connection


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zenyai
Junior Member
Join Date: Dec 2007
Old 10-01-2009 , 21:16   Check for date from sql connection
Reply With Quote #1

Can anyone help me with this ?

I'm making a client program for updating the value in mysql If the player close the client the value didn't update

I'm completing my first amxx script and I want to get a time value from sql table ( In form of Hour Minute Second Example : 081534) and I want it to compare it with server's current time. I don't know how to compare and how to use amxx to get server's current time.

If players current time from sql differential is higher than 25 seconds, player will get kicked.

I really don't know how to start

Last edited by Zenyai; 10-01-2009 at 21:43.
Zenyai is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-01-2009 , 21:20   Re: Check for date from sql connection
Reply With Quote #2

If you don't know what you're doing it will be alot easier for you to use nvault.
__________________
Bugsy is offline
Zenyai
Junior Member
Join Date: Dec 2007
Old 10-01-2009 , 21:34   Re: Check for date from sql connection
Reply With Quote #3

Ah for more info about what I making

This is my plugin right now

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
new Handle:g_SqlTuple
new g_Error[512]
public 
plugin_init()
{
register_plugin("Zenyai Plugin","1.0","Zenyai")
 
// we tell the API that this is the information we want to connect to,
// just not yet. basically it's like storing it in global variables
g_SqlTuple SQL_MakeDbTuple("127.0.0.1","user","pass","db")
}
public 
client_connect(id)

// ok, we're ready to connect
new ErrorCode,Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
if(
g_SqlTuple == Empty_Handle)
// stop the plugin with an error message
set_fail_state(g_Error)
 
// run a random query
new userid[32]
get_user_name(id,userid,31)
new 
Handle:Query SQL_PrepareQuery(SqlConnection,"SELECT * FROM shotlog WHERE Name='%s'"userid)
 
if(!
SQL_Execute(Query))
{
// if there were any problems
SQL_QueryError(Query,g_Error,511)
set_fail_state(g_Error)
}
else if (!
SQL_NumResults(Query)) {
server_cmd("kick #%d ^"%L^""get_user_userid(id), id"NOT_FOUND")

else
{
 
}
 
 
// of course, free the handle
SQL_FreeHandle(Query)
 
// and of course, free the connection
SQL_FreeHandle(SqlConnection)

I making a client that will update the value of time in sql for every 25 seconds and I want the script to check every 25 second for the difference of time .If the difference of time between the sql and server time more than 25 sec. The player get kick out.

If this not too hard please write the code for me. That would be nice but if it take alot of time please show me the way

Sorry for my bad english (English is not my main lang)

Last edited by Zenyai; 10-01-2009 at 21:38.
Zenyai is offline
Old 10-01-2009, 21:35
Zenyai
This message has been deleted by Zenyai.
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-01-2009 , 21:39   Re: Check for date from sql connection
Reply With Quote #4

What's the point of using a database for this? Couldn't you just store the time value in a variable and check it there?
__________________
Bugsy is offline
Zenyai
Junior Member
Join Date: Dec 2007
Old 10-01-2009 , 21:40   Re: Check for date from sql connection
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
What's the point of using a database for this? Couldn't you just store the time value in a variable and check it there?
I'm making a client program for updating the value in mysql If the player close the client the value didn't update
Zenyai is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 10-02-2009 , 05:27   Re: Check for date from sql connection
Reply With Quote #6

Quote:
new Handle:Query = SQL_PrepareQuery(SqlConnection,"SELECT * FROM shotlog WHERE Name='%s'", userid)
use steamid instead of the name. name is not unique and will cause a lot of other problems
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.

Last edited by |PJ| Shorty; 10-02-2009 at 05:29.
|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
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 22:41.


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