Advertisement
Xeiss

Untitled

Mar 12th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.56 KB | None | 0 0
  1. /*
  2.  
  3. -------------------------------
  4. XDM - Xeiss Deathmatch
  5. This gamemode was created from scratch by Xeiss.
  6. -------------------------------
  7.  
  8.     ---------------------------
  9.     DETAILS:
  10.         Name: XDM
  11.         Version: 1.0
  12.     ---------------------------
  13.     CHANGELOG:
  14.         1.1:
  15.             Not yet.
  16.     ---------------------------
  17.     THANKS:
  18.  
  19.     ---------------------------
  20. -------------------------------
  21.  
  22. */
  23.  
  24. //--------------------------- INCLUDES ---------------------------
  25. #include <a_samp>
  26. #include <sscanf2>
  27. // YSI
  28. #define MAX_INI_ENTRY_TEXT 160
  29. #include <YSI\y_commands>
  30. #include <YSI\y_ini>
  31.  
  32. //--------------------------- DEFINES ---------------------------
  33. #define GM_VERSION "1.0"
  34. // YSI
  35. #define USER_PATH "/XDM/Users/%s.ini"
  36.  
  37. #define STARTING_MONEY 5000 // The amount of money a players gets when he creates a new account
  38.  
  39. //--------------------------- DIALOGS ---------------------------
  40. #define DIALOG_MESSAGE 0
  41. #define DIALOG_REGISTER 1
  42. #define DIALOG_LOGIN 2
  43.  
  44. //--------------------------- COLORS ---------------------------
  45. #define COLOR_GREY 0xAFAFAFAA
  46. #define COLOR_GREEN 0x00FF00AA
  47. #define COLOR_RED 0xAA3333AA
  48. #define COLOR_YELLOW 0xFFFF00AA
  49. #define COLOR_WHITE 0xFFFFFFAA
  50. #define COLOR_BLUE 0x0000BBAA
  51. #define COLOR_LIGHTBLUE 0x33CCFFAA
  52. #define COLOR_ORANGE 0xFF9900AA
  53. #define COLOR_RED 0xAA3333AA
  54. #define COLOR_LIME 0x10F441AA
  55. #define COLOR_MAGENTA 0xFF00FFFF
  56. #define COLOR_AQUA 0xF0F8FFAA
  57. #define COLOR_BROWN 0xA52A2AAA
  58. #define COLOR_GOLD 0xB8860BAA
  59.  
  60. #define DIALOG_WHITE "{FFFFFF}"
  61. #define DIALOG_RED "{F81414}"
  62. #define DIALOG_GREEN "{00FF22}"
  63. #define DIALOG_LIGHTBLUE "{00CED1}"
  64. //--------------------------- NATIVES ---------------------------
  65. native WP_Hash(buffer[], len, const str[]);
  66.  
  67. //--------------------------- ENUMS ---------------------------
  68. enum PlayerInfo
  69. {
  70.     pPass[129],
  71.     pCash,
  72.     pBankCash,
  73.     pKills,
  74.     pAdmin,
  75.     bool:pFirstReg
  76. }
  77.  
  78. //--------------------------- VARS ---------------------------
  79. new fstr[129];
  80. new buf[129];
  81. new pInfo[MAX_PLAYERS][PlayerInfo];
  82. new GetName[MAX_PLAYERS][MAX_PLAYER_NAME];
  83.  
  84. //--------------------------- STOCKS ---------------------------
  85. stock UserPath(playerid) {
  86.     new nstr[128], pName[MAX_PLAYER_NAME];
  87.     GetPlayerName(playerid, pName, sizeof(pName));
  88.     format(nstr, sizeof(nstr), USER_PATH, pName);
  89.     return nstr;
  90. }
  91.  
  92. //--------------------------- CUSTOM PUBLICS ---------------------------
  93. forward LoadUser_data(playerid, name[], value[]);
  94. public LoadUser_data(playerid,name[],value[])
  95. {
  96.     INI_String("Password", pInfo[playerid][pPass], 129);
  97.     INI_Int("Cash", pInfo[playerid][pCash]);
  98.     INI_Int("BankCash", pInfo[playerid][pBankCash]);
  99.     INI_Int("Kills", pInfo[playerid][pKills]);
  100.     INI_Int("Admin", pInfo[playerid][pAdmin]);
  101.     return 1;
  102. }
  103.  
  104. forward LoginPlayer(playerid);
  105. public LoginPlayer(playerid)
  106. {
  107.     GivePlayerMoney(playerid, pInfo[playerid][pCash]);
  108.    
  109.     return 1;
  110. }
  111.  
  112. //--------------------------- PUBLICS ---------------------------
  113. main()
  114. {
  115.     print("\n----------------------------------------------------");
  116.     print(" [XDM] Xeiss Deathmatch V" GM_VERSION " Successfully loaded.");
  117.     print("----------------------------------------------------\n");
  118.     return 1;
  119. }
  120.  
  121. public OnGameModeInit()
  122. {
  123.     SetGameModeText("XDM V" GM_VERSION);
  124.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  125.     return 1;
  126. }
  127.  
  128. public OnPlayerRequestClass(playerid, classid)
  129. {
  130.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  131.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  132.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  133.     return 1;
  134. }
  135.  
  136. public OnPlayerConnect(playerid)
  137. {
  138.     GetPlayerName(playerid, GetName[playerid], sizeof(GetName));
  139.    
  140.     pInfo[playerid][pFirstReg] = false;
  141.    
  142.     if (fexist(UserPath(playerid)))
  143.     {
  144.         INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  145.         format(fstr, sizeof(fstr), DIALOG_WHITE"Account "DIALOG_LIGHTBLUE"%s "DIALOG_WHITE"was found!\nPlease type in your password to login:", GetName[playerid]);
  146.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, DIALOG_WHITE"Login", fstr,"Login","Quit");
  147.     }
  148.     else
  149.     {
  150.         format(fstr, sizeof(fstr), DIALOG_WHITE"Accout "DIALOG_RED"%s "DIALOG_WHITE"was not found!\nPlease type in a password to create an account:", GetName[playerid]);
  151.         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, DIALOG_WHITE"Register", fstr, "Register", "Quit");
  152.     }
  153.     return 1;
  154. }
  155.  
  156. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  157. {
  158.     switch (dialogid)
  159.     {
  160.         case DIALOG_REGISTER:
  161.         {
  162.             if (!response) return Kick(playerid);
  163.             if (!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, DIALOG_WHITE"Register", DIALOG_RED"Password can't be blank!\n"DIALOG_WHITE"Please type in a password to create an account:", "Register", "Quit");
  164.  
  165.             WP_Hash(buf, sizeof(buf), inputtext);
  166.             format(pInfo[playerid][pPass], 129, "%s", buf);
  167.             pInfo[playerid][pCash] = STARTING_MONEY;
  168.             pInfo[playerid][pBankCash] = 0;
  169.             pInfo[playerid][pKills] = 0;
  170.             pInfo[playerid][pAdmin] = 0;
  171.             pInfo[playerid][pFirstReg] = true;
  172.  
  173.             new INI:File = INI_Open(UserPath(playerid));
  174.             INI_SetTag(File, "data");
  175.             INI_WriteString(File, "Password", pInfo[playerid][pPass]);
  176.             INI_WriteInt(File, "Cash", pInfo[playerid][pCash]);
  177.             INI_WriteInt(File, "BankCash", pInfo[playerid][pBankCash]);
  178.             INI_WriteInt(File, "Kills", pInfo[playerid][pKills]);
  179.             INI_WriteInt(File, "Admin", pInfo[playerid][pAdmin]);
  180.             INI_Close(File);
  181.            
  182.             ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, DIALOG_WHITE"Login", DIALOG_GREEN"You successfully registered!\n"DIALOG_WHITE"Please type in your password to login:", "Login", "Quit");
  183.         }
  184.        
  185.         case DIALOG_LOGIN:
  186.         {
  187.             if (!response) return Kick(playerid);
  188.             if (!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, DIALOG_WHITE"Login", DIALOG_RED"Password can't be blank!\n"DIALOG_WHITE"Please type in your password to login:", "Login", "Quit");
  189.             if (strcmp(inputtext, pInfo[playerid][pPass])) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, DIALOG_WHITE"Login", DIALOG_RED"The password you entered is invalid!\n"DIALOG_WHITE"Please type in your password to login:", "Login", "Quit");
  190.             if (pInfo[playerid][pFirstReg] == true)
  191.             {
  192.                 LoginPlayer(playerid);
  193.             }
  194.             else
  195.             {
  196.                 INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  197.                 LoginPlayer(playerid);
  198.             }
  199.            
  200.             format(fstr, sizeof(fstr), "Welcome, %s!", GetName[playerid]);
  201.             SendClientMessage(playerid, COLOR_GREEN, fstr);
  202.             return 1;
  203.         }
  204.     }
  205.     return 1;
  206. }
  207.  
  208. //--------------------------- COMMANDS ---------------------------
  209. YCMD:help(playerid, params[], help)
  210. {
  211.     if (help) SendClientMessage(playerid, COLOR_GREY, "Displays the gamemode commands");
  212.     if (isnull(params))
  213.     {
  214.         SendClientMessage(playerid, COLOR_LIME, "-------------------- [Help] --------------------");
  215.         SendClientMessage(playerid, COLOR_BROWN, "");
  216.         SendClientMessage(playerid, COLOR_GOLD, "This gamemode was created from scratch by Xeiss");
  217.         SendClientMessage(playerid, COLOR_LIME, "-------------------- [Help] --------------------");
  218.     }
  219.     else
  220.     {
  221.         Command_ReProcess(playerid, params, true);
  222.     }
  223.     return 1;
  224. }
  225.  
  226. //  REMOVE LATER
  227. YCMD:v(playerid, params[], help) {
  228.     if (help) SendClientMessage(playerid, COLOR_GREY, "Spawn a vechile. USAGE: /v [id]");
  229.     new vid, Float:pos[4], vcar;
  230.     if (sscanf(params, "%d", vid)) return 0;
  231.     GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  232.     GetPlayerFacingAngle(playerid, pos[3]);
  233.     vcar = CreateVehicle(vid, pos[0], pos[1], pos[2], pos[3], 0, 0, -1);
  234.     PutPlayerInVehicle(playerid, vcar, 0);
  235.     return 1;
  236. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement