Advertisement
Guest User

Untitled

a guest
Mar 10th, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <sourcemod>
  2.  
  3. public OnClientPutInServer(client)
  4. {
  5. decl String:SteamID[25];
  6. if (GetClientAuthId(client, AuthId_Steam2, SteamID, sizeof(SteamID))) PrintToChatAll("connected: %s", SteamID);
  7.  
  8. new String:error[255]
  9. new Handle:db = SQL_DefConnect(error, sizeof(error))
  10.  
  11. if (db == INVALID_HANDLE)
  12. {
  13. PrintToChatAll("Could not connect: %s", error)
  14. }
  15. else
  16. {
  17.  
  18.  
  19. new Handle:hQuery
  20. new String:query[100]
  21.  
  22. /* Create enough space to make sure our string is quoted properly */
  23. new buffer_len = strlen(SteamID) * 2 + 1
  24. new String:new_name[buffer_len]
  25.  
  26. /* Ask the SQL driver to make sure our string is safely quoted */
  27. SQL_QuoteString(db, SteamID, new_name, buffer_len)
  28.  
  29. /* Build the query */
  30. Format(query, sizeof(query), "SELECT userid FROM vb_user WHERE username = '%s'", new_name)
  31.  
  32. /* Execute the query */
  33. if ((hQuery = SQL_Query(db,query)) == INVALID_HANDLE)
  34. {
  35. return 0;
  36. }
  37.  
  38. /* Get some info here
  39. */
  40.  
  41. CloseHandle(hQuery)
  42.  
  43.  
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement