AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Check for date from sql connection (https://forums.alliedmods.net/showthread.php?t=105161)

Zenyai 10-01-2009 21:16

Check for date from sql connection
 
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

Bugsy 10-01-2009 21:20

Re: Check for date from sql connection
 
If you don't know what you're doing it will be alot easier for you to use nvault.

Zenyai 10-01-2009 21:34

Re: Check for date from sql connection
 
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 :shock:

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

Bugsy 10-01-2009 21:39

Re: Check for date from sql connection
 
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?

Zenyai 10-01-2009 21:40

Re: Check for date from sql connection
 
Quote:

Originally Posted by Bugsy (Post 949664)
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

|PJ| Shorty 10-02-2009 05:27

Re: Check for date from sql connection
 
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


All times are GMT -4. The time now is 22:41.

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