Advertisement
Rolandas_L

Untitled

Nov 19th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.03 KB | None | 0 0
  1. #include "../Gamemodes/Files/Dialogs.txt"
  2. enum Users{
  3.     Name[MAX_PLAYER_NAME],
  4.     Password[24],
  5.  
  6.     Float:Pos[3],
  7.  
  8.     State,
  9.     ID,
  10.  
  11.     ORM:ORMID
  12. };
  13. new uInfo[MAX_PLAYERS][Users];
  14. forward USERS_OnPlayerConnect(playerid);
  15. public USERS_OnPlayerConnect(playerid){
  16.     GetPlayerName(playerid, uInfo[playerid][Name], 24);
  17.     uInfo[playerid][ORMID] = orm_create("Users");
  18.  
  19.     orm_addvar_string(uInfo[playerid][ORMID],uInfo[playerid][Name],24,"UserName");
  20.     orm_addvar_string(uInfo[playerid][ORMID],uInfo[playerid][Password],24,"Password");
  21.  
  22.     orm_addvar_int(uInfo[playerid][ORMID],uInfo[playerid][ID],"ID");
  23.  
  24.     orm_addvar_float(uInfo[playerid][ORMID],uInfo[playerid][Pos][0],"Pos_X");
  25.     orm_addvar_float(uInfo[playerid][ORMID],uInfo[playerid][Pos][1],"Pos_Y");
  26.     orm_addvar_float(uInfo[playerid][ORMID],uInfo[playerid][Pos][2],"Pos_Z");
  27.  
  28.     orm_setkey(uInfo[playerid][ORMID],"UserName");
  29.  
  30.     orm_load(uInfo[playerid][ORMID],"OnPlayerDataLoaded","i",playerid);
  31.     return 1;
  32. }
  33. forward OnPlayerDataLoaded(playerid);
  34. public OnPlayerDataLoaded(playerid){
  35.     if(orm_errno(uInfo[playerid][ORMID]) == ERROR_OK){
  36.         ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_PASSWORD, "Prisijungimas", "Bla,bla,bla", "Prisijungti", "Išeiti");
  37.     }
  38.     else{
  39.         ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_PASSWORD, "Registracija", "Bla,bla,bla", "Registruotis", "Išeiti");
  40.     }
  41.     return 1;
  42. }
  43. forward OnPlayerLoggedIn(playerid,int);
  44. public OnPlayerLoggedIn(playerid,int){
  45.     switch(int){
  46.         case 0:{
  47.             SpawnPlayer(playerid);
  48.             SetPlayerPos(playerid, uInfo[playerid][Pos][0], uInfo[playerid][Pos][1], uInfo[playerid][Pos][2]);
  49.             SendClientMessage(playerid, -1, "Sveikas sugrįžęs");
  50.             uInfo[playerid][State] = 1;
  51.         }
  52.         case 1:{
  53.             SpawnPlayer(playerid);
  54.             uInfo[playerid][State] = 1;
  55.         }
  56.     }
  57. }
  58. forward USERS_OnPlayerDissconect(playerid);
  59. public USERS_OnPlayerDissconect(playerid){
  60.     if(uInfo[playerid][State] == 1){
  61.         GetPlayerPos(playerid, uInfo[playerid][Pos][0], uInfo[playerid][Pos][1], uInfo[playerid][Pos][2]);
  62.         orm_update(uInfo[playerid][ORMID]);
  63.     }
  64.     return 1;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement