Advertisement
Guest User

Untitled

a guest
Apr 27th, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1. dofile("classes/user.nut");
  2. local player = User();
  3.  
  4. local handler               = mysql_connect("localhost", "root", "", "gothic");
  5. local SERVER_NAME           = "Sequel RolePlay";
  6.  
  7.  
  8. function onInit()
  9. {
  10.  
  11. }
  12.  
  13.  
  14. function onJoin(pid)
  15. {
  16.     print("player: " + getPlayerName(pid));
  17.     print("isLogged: " + player.isLogged);
  18.  
  19.     if(!player.isLogged)
  20.     {
  21.  
  22.         for(local i = 0; i < getMaxSlots(); ++i)
  23.         {
  24.             sendMessage(i, 225, 225, 225, "Игрок " + getPlayerName(pid) + " подключился к игре.");
  25.         }
  26.  
  27.         local string = format("SELECT * FROM player_stats WHERE login = '%s'", getPlayerName(pid));
  28.         local row = mysql_fetch_row(mysql_query(handler, string));
  29.  
  30.         sendMessage(pid, 225, 225, 225, "* Добро пожаловать на игровой сервер Gothic Online");
  31.  
  32.         if(!row)
  33.         {
  34.             sendMessage(pid, 225, 225, 225, "* Ваш игровой аккаунт не зарегистрирован.");
  35.             sendMessage(pid, 225, 225, 225, "* Для регистрации воспользуйтесь: /reg <пароль> <пароль>");
  36.         }
  37.         else
  38.         {
  39.             sendMessage(pid, 225, 225, 225, "* Для авторизации воспользуйтесь: /log <пароль>")
  40.         }
  41.     }
  42.     else
  43.     {
  44.         sendMessage(pid, 225, 225, 225, "* Ваш игровой аккаунт был поврежден.");
  45.         kick(pid);
  46.     }
  47. }
  48.  
  49. function onDisconnect(pid, reason)
  50. {
  51.     player.saveAccount(pid);
  52.     player.clearPlayerStats(pid);
  53. }
  54.  
  55. function onDie(pid, kid)
  56. {
  57.  
  58. }
  59.  
  60. function onCommand(pid, cmd, params)
  61. {
  62.     switch(cmd)
  63.     {
  64.         case "reg":
  65.         {
  66.             player.regAccount(pid, params);
  67.             break;
  68.         }
  69.  
  70.         case "log":
  71.         {
  72.             player.logAccount(pid, params);
  73.             break;
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement