AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with SQL querry (https://forums.alliedmods.net/showthread.php?t=84868)

IT_Prof 02-02-2009 06:04

Help with SQL querry
 
Sorry for my bad English.

In my game servers admins in the AMXBans database identified by SteamID. In the Nickname field identifies the real nicknames of admins.
When an admin ban player in the database is stored admin nick from game, not a real nickname. I need to admin real nickname taken from a database.

From cmdban.inl ->
Quote:

public cmd_ban_(failstate, Handle:query, error[], errnum, data[], size)
new admin_nick[100], admin_steamid[50], admin_ip[20]
get_user_name(id, admin_nick, 99)
get_user_ip(id, admin_ip, 19, 1)
I need:
Quote:

new admin_nick[100], admin_steamid[50], admin_ip[20]
get_user_name(id, admin_nick, 99)

get_user_authid(id, admin_steamid, 49)
new query[1024]
format(query,1023,"SELECT amx_amxadmins.nickname FROM amx_amxadmins WHERE amx_amxadmins.username = '%admin_steamid'", admin_nick)
.................................
How to make correctly request in database?

Hawk552 02-02-2009 09:14

Re: Help with SQL querry
 
I think you want something like this:

Code:
format(query,1023,"SELECT nickname FROM amx_amxadmins WHERE username='%s'",admin_nick)



or this:

Code:
format(query,1023,"SELECT nickname FROM amx_amxadmins WHERE authid='%s'",admin_steamid)

Also, make sure you escape the player's name before formatting or you could end up with a nasty injection exploit.

IT_Prof 02-02-2009 12:16

Re: Help with SQL querry
 
Quote:

Originally Posted by Hawk552 (Post 754307)
I think you want something like this:

Code:
format(query,1023,"SELECT nickname FROM amx_amxadmins WHERE authid='%s'",admin_steamid)

Yes, this is right string!
But this command does not perform query to the database, it only formats (preparing) the request.

How do the query?

Hawk552 02-02-2009 12:28

Re: Help with SQL querry
 
Read this:
http://forums.alliedmods.net/showthread.php?t=46779

Styles 02-02-2009 13:20

Re: Help with SQL querry
 
HAWK HAI!!

And hawk, hai:D

and you shouldn't need blah.field it should be assumed...

IT_Prof 02-03-2009 04:35

Re: Help with SQL querry
 
Quote:

Originally Posted by Hawk552 (Post 754402)

Thank you very much! That's exactly what I need!


All times are GMT -4. The time now is 01:48.

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