Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.03 KB | None | 0 0
  1. // TDM
  2.  
  3. #include <a_samp>
  4. #include <Dini>
  5. #include <dudb>
  6. #include <Zcmd>
  7. #include <gvar>
  8.  
  9. main()
  10. {
  11.     print("\n----------------------------------");
  12.     print(" Blank Gamemode by your name here");
  13.     print("----------------------------------\n");
  14. }
  15.  
  16. /*______________________________________________________________________________ Color defines */
  17. #define     color_white     0xFFFFFFAA
  18. #define     color_green     0x00FF66AA
  19. #define     color_admin     0x666699AA
  20. #define     color_red       0xFF0000AA
  21. #define     color_yellow    0xFFFF00AA
  22. #define     color_blue      0x0066FFAA
  23. #define     color_grey      0x999999AA
  24. #define     color_orange    0xFF6600AA
  25. #define     color_lightblue 0xB0C4DEAA
  26. #define     color_purple    0x9370DBAA
  27. #define     admin_duty      0x5F9EA0AA
  28. #define     color_radio     0xFFFFCCAA
  29. #define     color_pink      0x9900CCAA
  30. /*____________________________________________________________________________*/
  31.  
  32.  
  33. new logged[MAX_PLAYERS];
  34.  
  35. enum pInfo
  36. {
  37.     pAdmin,     // Saves the players admin level
  38.     pMoney,     // Saves the player money
  39.     pScore,     // Saves the player score
  40.     pSkin,      // Saves the player skins
  41.     pTeam       // Saves the player team
  42. }
  43.  
  44. new PlayerInfo[MAX_PLAYERS][pInfo];
  45.  
  46. public OnGameModeInit()
  47. {
  48.     SetGameModeText("Akai's TDM");
  49.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  50.     return 1;
  51. }
  52.  
  53. public OnGameModeExit()
  54. {
  55.     return 1;
  56. }
  57.  
  58. public OnPlayerRequestClass(playerid, classid)
  59. {
  60.     TogglePlayerSpectating(playerid, 1);
  61.    
  62.     new string[128];
  63.     new name[MAX_PLAYER_NAME];
  64.     new file[128];
  65.    
  66.     GetPlayerName(playerid, name, sizeof(name));
  67.     format(file,sizeof(file),"/Users/%s.ini",name);
  68.    
  69.     if(!fexist(file))
  70.         {
  71.             format(string, 128, "You joined the server with name: ''%s''", name);
  72.             SendClientMessage(playerid, color_white, string);
  73.             SendClientMessage(playerid, color_white, "Hint: Account is not registered.");
  74.             SendClientMessage(playerid, color_yellow,"Use /register 'password' to proceed.");
  75.             logged[playerid] = 0;
  76.         }
  77.     if(fexist(file))
  78.         {
  79.             SendClientMessage(playerid, color_white, "Hint: Account already registered.");
  80.             SendClientMessage(playerid, color_yellow, "Use /login 'password' to proceed.");
  81.         }
  82.     return 1;
  83. }
  84.  
  85. COMMAND:register(playerid, params[])
  86. {
  87.     new string[128];
  88.     new file[128], pname[MAX_PLAYER_NAME];
  89.     GetPlayerName(playerid, pname, sizeof(pname));
  90.     format(file, sizeof(file), "/Accounts/%s.ini", pname);
  91. //------------------------------------------------------------------------------
  92.     if(!strlen(params)) return SendClientMessage(playerid, color_white, "[System]: /register 'password'");
  93.     if(dini_Exists(file)) return SendClientMessage(playerid, color_white, "[System]: You are already registered!");
  94.     dini_Create(file);
  95.     dini_IntSet(file, "hashPW", udb_hash(params));
  96.     dini_Set(file, "password", params);
  97.    
  98.         dini_IntSet(file, "pAdmin", 0);
  99.         dini_IntSet(file, "pMoney", 0);
  100.         dini_IntSet(file, "pScore", 0);
  101.         dini_IntSet(file, "pSkin",  127);
  102.         dini_IntSet(file, "pTeam",  0);
  103.     format(string, 128, "[SYSTEM]: You succesfully registered the account %s with password %s. You can now use /login 'password'", pname, params);
  104.     SendClientMessage(playerid, color_white, string);
  105.     printf("[User Registered] Username: %s || Password: %s", pname,  params); // For debugging purposes
  106.   return 1;
  107. }
  108.  
  109. COMMAND:login(playerid, params[])
  110. {
  111.   new file[128];
  112.   new joinmsg[128];
  113.   new string[MAX_STRING], pname[MAX_PLAYER_NAME];
  114.   GetPlayerName(playerid, pname, sizeof(pname));
  115.   format(file, sizeof(file), "/Accounts/%s.ini", pname);
  116. //------------------------------------------------------------------------------
  117.   if(!strlen(params)) return SendClientMessage(playerid, color_white, "[SYSTEM]: /login [password]");
  118.   if(!dini_Exists(file)) return SendClientMessage(playerid, color_white, "[SYSTEM]: You are not registered!");
  119.   if(logged[playerid]) return SendClientMessage(playerid, color_white, "[SYSTEM]: You are already logged in!");
  120.   new tmp;
  121.   tmp = dini_Int(file, "hashPW");
  122. //------------------------------------------------------------------------------
  123.   if(udb_hash(params) != tmp)
  124.     {
  125.         format(string, 256, "[System]: You typed the wrong password for account: %s.", pname);
  126.         SendClientMessage(playerid, color_white, string);
  127.     }
  128.   else
  129.     {
  130.         TogglePlayerSpectating(playerid, 0);
  131.  
  132.         PlayerInfo[playerid][pAdmin] = dini_Int(file, "pAdmin");
  133.         SetPlayerScore(playerid, dini_Int(file, "pScore"));
  134.         SetPlayerMoney(playerid, dini_Int(file, "pMoney"));
  135.         SetPlayerSkin(playerid, dini_Int(file, "pSkin"));
  136.         SetGVarInt("TEAM", dini_Int(file, "pTeam"), playerid);
  137.  
  138.         format(string, sizeof(string), "Welcome back %s!", pname);
  139.         SendClientMessage(playerid, color_green, string);
  140.         SendClientMessage(playerid, color_yellow, "Feel free to use /report or /helpme if you got questions. (Hint: read /help)");
  141.  
  142.         format(string, sizeof(string), "~y~Welcome back ~g~%s", pname);
  143.         GameTextForPlayer(playerid, string, 5000, 5);
  144.         printf("[User Logged in] Username: %s || Given Playerid: %i || Password: %s", pname, playerid, params); // For debugging purposes
  145.         PlayerPlaySound(playerid,1058,0.0,0.0,0.0);
  146.         PlayerPlaySound(playerid, 1186, 0.0, 0.0, 0.0);
  147.         format(joinmsg, sizeof(joinmsg), "[Connected]: %s connected and logged in.", pname);
  148.         SendAdminMessage(color_green, joinmsg);
  149.     }
  150.   return 1;
  151. }
  152.  
  153.  
  154. //==============================================================================
  155. //==============================================================================
  156. //==============================================================================
  157.  
  158.  
  159. stock SendAdminMessage(color, msg[])
  160. {
  161.     for(new i = 0; i < MAX_PLAYERS; i++)
  162.     {
  163.         if(PlayerInfo[i][pAdmin] > 1)
  164.         {
  165.         SendClientMessage(i, color, msg);
  166.         }
  167.     }
  168.     return 1;
  169. }
  170.  
  171. //==============================================================================
  172. //==============================================================================
  173. //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement