Guest User

Untitled

a guest
Jan 21st, 2012
973
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 44.86 KB | None | 0 0
  1. #include <a_samp>
  2. #include <y_ini>
  3. #include <progress>
  4.  
  5. enum PLAYER_DATA
  6. {
  7.     PLAYER_PASS[129],
  8.     PLAYER_CASH,
  9.     PLAYER_SCORE,
  10.     PLAYER_LEVEL,
  11.     PLAYER_EXP,
  12.     PLAYER_TOTALEXP,
  13.     /*PLAYER_WEAP1TYPE,
  14.     PLAYER_WEAP2TYPE,
  15.     PLAYER_WEAP3TYPE,
  16.     PLAYER_WEAP1SPEC,
  17.     PLAYER_WEAP2SPEC,
  18.     PLAYER_WEAP3SPEC,
  19.     PLAYER_WEAP1LVL,
  20.     PLAYER_WEAP2LVL,
  21.     PLAYER_WEAP3LVL,*/ //Not used yet.
  22.     PLAYER_POINTS,
  23.     PLAYER_STRENGTH,
  24.     PLAYER_DEFENCE,
  25.     PLAYER_CURWEAP,
  26.     WEAPPOINTS,
  27.     SAWNOFF,
  28.     SILENCED,
  29.     DEAGLE,
  30.     SHOTGUN,
  31.     SPAS12,
  32.     MICRO_UZI,
  33.     MP5,
  34.     AK47,
  35.     M4,
  36.     SNIPERRIFLE
  37. }
  38. new Text:ExpText[MAX_PLAYERS];
  39. new Text:LevelText[MAX_PLAYERS];
  40. new Bar:bar[MAX_PLAYERS], Bar:HPBar[MAX_PLAYERS], Text:HPText[MAX_PLAYERS], Bar:OpponentHPBar[MAX_PLAYERS], Text:OpponentHPText[MAX_PLAYERS], Text:OpponentHPImg, Text:OpponentHPImgFull, Text:OpponentName[MAX_PLAYERS];
  41. new Text3D:HP3DText[MAX_PLAYERS];
  42. new Text3D:LevelLabel[MAX_PLAYERS];
  43. new Text3D:NameTag[MAX_PLAYERS];
  44. new OpponentHPHide[MAX_PLAYERS];
  45. new PlayerInfo[MAX_PLAYERS][PLAYER_DATA];
  46.  
  47. //You can change these values.
  48. #define ExpForLevel 500 //How much exp you need to pass a level. The Exp gets multiplied by the level. If you've got 1000 total exp then for lvl 2 it will be 2000
  49. #define MaxLevel 99 //The maximum level a player can achieve.
  50. #define UseProgBar // Define wheater to use the progress bar or not. Comment the line if you don't want a progress bar and leave like that if you do want a progress bar.
  51. #define ProgBarColor 0x0000FFFF //The experience bar's color.
  52. #define TextLabelColor 0x00FFFFFF // The textlabel's color.
  53. #define CashForLevelUp 300 //This is the cash you get for levelling up. It gets multiplied by the level you achieved and one more time by a number you define.
  54. #define CashMultiplier 1 //This multiplies the Cash * Level achieved by the number you want.
  55. #define GameTextStyle 4 //This defines the GameText's style used for the GivePlayerExp function.
  56. #define GameTextTime 3000 //This defines the time for which the GameText for the GivePlayerExp function will be visible
  57. //#define StaticNums //This defines that the numbers stay in one place with a couple of zeroes in front of them. Comment to remove the zeroes.
  58.  
  59. //Don't change these values.
  60. #define mustlogin
  61. #define autologin
  62.  
  63. //Declaring New
  64. new logged_in[MAX_PLAYERS];
  65. new Retries[MAX_PLAYERS];
  66.  
  67. stock GivePlayerExp(playerid, exp, reason[])
  68. {
  69.     new pfile[100], pname[MAX_PLAYER_NAME], string2[126], string3[126], string4[126], string5[64];
  70.     GetPlayerName(playerid, pname, sizeof(pname));
  71.     format(pfile, sizeof(pfile), "HAccounts/%s.ini",pname);
  72.     PlayerInfo[playerid][PLAYER_EXP] += exp;
  73.     if (PlayerInfo[playerid][PLAYER_EXP] >= PlayerInfo[playerid][PLAYER_TOTALEXP])
  74.     {
  75.         if (PlayerInfo[playerid][PLAYER_LEVEL] < MaxLevel)
  76.         {
  77.             while (PlayerInfo[playerid][PLAYER_EXP] >= PlayerInfo[playerid][PLAYER_TOTALEXP])
  78.             {
  79.                 PlayerInfo[playerid][PLAYER_EXP] -= PlayerInfo[playerid][PLAYER_TOTALEXP];
  80.                 PlayerInfo[playerid][PLAYER_LEVEL] += 1;
  81.                 PlayerInfo[playerid][PLAYER_TOTALEXP] = PlayerInfo[playerid][PLAYER_LEVEL] * ExpForLevel;
  82.                 #if defined StaticNums
  83.                 format(string3, sizeof(string3), "Level: %02d", PlayerInfo[playerid][PLAYER_LEVEL]);
  84.                 #else
  85.                 format(string3, sizeof(string3), "Level: %d", PlayerInfo[playerid][PLAYER_LEVEL]);
  86.                 #endif
  87.                 TextDrawSetString(LevelText[playerid], string3);
  88.                 GivePlayerMoney(playerid, CashForLevelUp * PlayerInfo[playerid][PLAYER_LEVEL] * CashMultiplier);
  89.                 format(string4, sizeof(string4), "~p~You got %d Exp for ~n~%s !~n~~g~Level up!~n~~b~+1 Point.", exp, reason);
  90.                 SetProgressBarMaxValue(HPBar[playerid], (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  91.                 SetProgressBarValue(HPBar[playerid], (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  92.                 UpdateProgressBar(HPBar[playerid], playerid);
  93.                 format(string5, sizeof(string5), "%d/%d",(PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2, (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  94.                 TextDrawSetString(HPText[playerid], string5);
  95.                 UpdateBar(playerid);
  96.                 PlayerInfo[playerid][PLAYER_POINTS]++;
  97.                 PlayerInfo[playerid][WEAPPOINTS]++;
  98.             }
  99.         }
  100.         else
  101.         {
  102.             GameTextForPlayer(playerid, "~g~Max Level Reached!", GameTextTime, GameTextStyle);
  103.             PlayerInfo[playerid][PLAYER_EXP] = PlayerInfo[playerid][PLAYER_TOTALEXP];
  104.         }
  105.     }
  106.     else
  107.     {
  108.         format(string4, sizeof(string4), "~p~You got %d Exp for ~n~%s !", exp, reason);
  109.     }
  110.     #if defined StaticNums
  111.     format(string2, sizeof(string2), "Exp: %05d/%05d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  112.     format(string3, sizeof(string3), "Level: %02d",PlayerInfo[playerid][PLAYER_LEVEL]);
  113.     #else
  114.     format(string2, sizeof(string2), "Exp: %d/%d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  115.     format(string3, sizeof(string3), "Level: %d",PlayerInfo[playerid][PLAYER_LEVEL]);
  116.     #endif
  117.     TextDrawSetString(ExpText[playerid], string2);
  118.     #if defined UseProgBar
  119.     SetProgressBarValue(bar[playerid], PlayerInfo[playerid][PLAYER_EXP]);
  120.     SetProgressBarMaxValue(bar[playerid], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  121.     UpdateProgressBar(bar[playerid], playerid);
  122.     #endif
  123.     GameTextForPlayer(playerid, string4, GameTextTime, GameTextStyle);
  124.     Update3DTextLabelText(LevelLabel[playerid], TextLabelColor, string3);
  125. }
  126.  
  127. stock ResetPlayerExp(playerid)
  128. {
  129.     new string[64];
  130.     PlayerInfo[playerid][PLAYER_EXP] = 0;
  131.     #if defined StaticNums
  132.     format(string, sizeof(string), "Exp: %05d/%05d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  133.     #else
  134.     format(string, sizeof(string), "Exp: %d/%d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  135.     #endif
  136.     TextDrawSetString(ExpText[playerid], string);
  137. }
  138.  
  139. stock ResetPlayerExpLevel(playerid)
  140. {
  141.     new string[64], string2[64];
  142.     PlayerInfo[playerid][PLAYER_LEVEL] = 1;
  143.     PlayerInfo[playerid][PLAYER_TOTALEXP] = ExpForLevel * PlayerInfo[playerid][PLAYER_EXPLEVEL];
  144.     PlayerInfo[playerid][PLAYER_EXP] = 0;
  145.     #if defined StaticNums
  146.     format(string, sizeof(string), "Level: %02d",PlayerInfo[playerid][PLAYER_LEVEL]);
  147.     format(string2, sizeof(string2), "Exp: %05d/%05d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  148.     #else
  149.     format(string, sizeof(string), "Level: %d",PlayerInfo[playerid][PLAYER_LEVEL]);
  150.     format(string2, sizeof(string2), "Exp: %d/%d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  151.     #endif
  152.     TextDrawSetString(LevelText[playerid], string);
  153.     TextDrawSetString(ExpText[playerid], string2);
  154. }
  155.  
  156. stock SetPlayerExpLevel(playerid, level)
  157. {
  158.     new string[64], string3[64];
  159.     PlayerInfo[playerid][PLAYER_LEVEL] = level;
  160.     PlayerInfo[playerid][PLAYER_TOTALEXP] = ExpForLevel * level;
  161.     PlayerInfo[playerid][PLAYER_EXP] = 0;
  162.     #if defined StaticNums
  163.     format(string3, sizeof(string3), "Level: %02d",PlayerInfo[playerid][PLAYER_LEVEL]);
  164.     format(string, sizeof(string), "Exp: %05d/%05d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  165.     #else
  166.     format(string3, sizeof(string3), "Level: %d",PlayerInfo[playerid][PLAYER_LEVEL]);
  167.     format(string, sizeof(string), "Exp: %d/%d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  168.     #endif
  169.     TextDrawSetString(LevelText[playerid], string3);
  170.     TextDrawSetString(ExpText[playerid], string);
  171. }
  172.  
  173. stock SetPlayerExp(playerid, exp)
  174. {
  175.     new string[64];
  176.     PlayerInfo[playerid][PLAYER_EXP] = exp;
  177.     #if defined StaticNums
  178.     format(string, sizeof(string), "Exp: %05d/%05d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  179.     #else
  180.     format(string, sizeof(string), "Exp: %d/%d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  181.     #endif
  182.     TextDrawSetString(ExpText[playerid], string);
  183. }
  184.  
  185. //The function to get a player's level. Usage: GetPlayerLevel(playerid)
  186. stock GetPlayerExpLevel(playerid)
  187. {
  188.     new Plevel;
  189.     Plevel = PlayerInfo[playerid][PLAYER_LEVEL];
  190.     return Plevel;
  191. }
  192.  
  193. //The function to get a player's experience. Usage: GetPlayerExp(playerid)
  194. stock GetPlayerExp(playerid)
  195. {
  196.     new PExp;
  197.     PExp = PlayerInfo[playerid][PLAYER_EXP];
  198.     return PExp;
  199. }
  200.  
  201. //The function to get a player's experience needed to lvl up. Usage: GetPlayerTotalExp(playerid)
  202. stock GetPlayerTotalExp(playerid)
  203. {
  204.     new PTotalExp;
  205.     PTotalExp = PlayerInfo[playerid][PLAYER_TOTALEXP];
  206.     return PTotalExp;
  207. }
  208.  
  209. stock UpdateBar(playerid)
  210. {
  211.     new str[30];
  212.     if(GetProgressBarValue(HPBar[playerid]) == (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2)     format(str,sizeof(str),"{00ff00}••••••••••");
  213.     else if(GetProgressBarValue(HPBar[playerid]) >= 0.10 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2) && GetProgressBarValue(HPBar[playerid]) <= 0.20 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2))   format(str,sizeof(str),"{ff2400}•{ffffff}•••••••••");
  214.     else if(GetProgressBarValue(HPBar[playerid]) >= 0.20 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2) && GetProgressBarValue(HPBar[playerid]) <= 0.30 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2))   format(str,sizeof(str),"{ff2400}••{ffffff}••••••••");
  215.     else if(GetProgressBarValue(HPBar[playerid]) >= 0.30 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2) && GetProgressBarValue(HPBar[playerid]) <= 0.40 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2))   format(str,sizeof(str),"{e4650e}•••{ffffff}•••••••");
  216.     else if(GetProgressBarValue(HPBar[playerid]) >= 0.40 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2) && GetProgressBarValue(HPBar[playerid]) <= 0.50 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2))   format(str,sizeof(str),"{e49b0f}••••{ffffff}••••••");
  217.     else if(GetProgressBarValue(HPBar[playerid]) >= 0.50 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2) && GetProgressBarValue(HPBar[playerid]) <= 0.60 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2))   format(str,sizeof(str),"{f4c430}•••••{ffffff}•••••");
  218.     else if(GetProgressBarValue(HPBar[playerid]) >= 0.60 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2) && GetProgressBarValue(HPBar[playerid]) <= 0.70 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2))   format(str,sizeof(str),"{f7f21a}••••••{ffffff}••••");
  219.     else if(GetProgressBarValue(HPBar[playerid]) >= 0.70 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2) && GetProgressBarValue(HPBar[playerid]) <= 0.80 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2))   format(str,sizeof(str),"{ccff00}•••••••{ffffff}•••");
  220.     else if(GetProgressBarValue(HPBar[playerid]) >= 0.80 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2) && GetProgressBarValue(HPBar[playerid]) <= 0.90 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2))   format(str,sizeof(str),"{7fff00}••••••••{ffffff}••");
  221.     else if(GetProgressBarValue(HPBar[playerid]) >= 0.90 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2) && GetProgressBarValue(HPBar[playerid]) <= 0.99 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2))   format(str,sizeof(str),"{66ff00}•••••••••{ffffff}•");
  222.     else if(GetProgressBarValue(HPBar[playerid]) >= 0.99 * ((PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2)) format(str,sizeof(str),"{ff2400}•••••••••{ffffff}•");
  223.     //UpdatePlayer3DTextLabelText(playerid, HP3DText[playerid], -1, str);
  224.     Update3DTextLabelText(HP3DText[playerid], -1, str);
  225.     return 1;
  226. }
  227.  
  228. forward yini(playerid, name[], value[]);
  229.  
  230. public yini(playerid, name[], value[])
  231. {
  232.     INI_Int("password", PlayerInfo[playerid][PLAYER_PASS]);
  233.     INI_Int("cash", PlayerInfo[playerid][PLAYER_CASH]);
  234.     INI_Int("score", PlayerInfo[playerid][PLAYER_SCORE]);
  235.     INI_Int("level", PlayerInfo[playerid][PLAYER_LEVEL]);
  236.     INI_Int("exp", PlayerInfo[playerid][PLAYER_EXP]);
  237.     INI_Int("totalexp", PlayerInfo[playerid][PLAYER_TOTALEXP]);
  238.     /*INI_Int("weap1type", PlayerInfo[playerid][PLAYER_WEAP1TYPE]);
  239.     INI_Int("weap2type", PlayerInfo[playerid][PLAYER_WEAP2TYPE]);
  240.     INI_Int("weap3type", PlayerInfo[playerid][PLAYER_WEAP3TYPE]);
  241.     INI_Int("weap1spec", PlayerInfo[playerid][PLAYER_WEAP1SPEC]);
  242.     INI_Int("weap2spec", PlayerInfo[playerid][PLAYER_WEAP2SPEC]);
  243.     INI_Int("weap3spec", PlayerInfo[playerid][PLAYER_WEAP3SPEC]);
  244.     INI_Int("weap1lvl", PlayerInfo[playerid][PLAYER_WEAP1LVL]);
  245.     INI_Int("weap2lvl", PlayerInfo[playerid][PLAYER_WEAP2LVL]);
  246.     INI_Int("weap3lvl", PlayerInfo[playerid][PLAYER_WEAP3LVL]);*/
  247.     INI_Int("points", PlayerInfo[playerid][PLAYER_POINTS]);
  248.     INI_Int("strength", PlayerInfo[playerid][PLAYER_STRENGTH]);
  249.     INI_Int("defence", PlayerInfo[playerid][PLAYER_DEFENCE]);
  250.     INI_Int("weappoints", PlayerInfo[playerid][WEAPPOINTS]);
  251.     INI_Int("sawnoff", PlayerInfo[playerid][SAWNOFF]);
  252.     INI_Int("silenced", PlayerInfo[playerid][SILENCED]);
  253.     INI_Int("deagle", PlayerInfo[playerid][DEAGLE]);
  254.     INI_Int("shotgun", PlayerInfo[playerid][SHOTGUN]);
  255.     INI_Int("spas12", PlayerInfo[playerid][SPAS12]);
  256.     INI_Int("micro_uzi", PlayerInfo[playerid][MICRO_UZI]);
  257.     INI_Int("mp5", PlayerInfo[playerid][MP5]);
  258.     INI_Int("ak47", PlayerInfo[playerid][AK47]);
  259.     INI_Int("m4", PlayerInfo[playerid][M4]);
  260.     INI_Int("sniperrifle", PlayerInfo[playerid][SNIPERRIFLE]);
  261.     return 1;
  262. }
  263.  
  264. stock YINI_SAVE(playerid)
  265. {
  266.     new playerName[MAX_PLAYER_NAME];
  267.     GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
  268.     new userFile[32];
  269.     format(userFile, sizeof (userFile), "HAccounts/%s.ini", playerName);
  270.     new INI:file = INI_Open(userFile);
  271.     INI_WriteInt(file, "cash", GetPlayerMoney(playerid));
  272.     INI_WriteInt(file, "score", GetPlayerScore(playerid));
  273.     INI_WriteInt(file, "level", PlayerInfo[playerid][PLAYER_LEVEL]);
  274.     INI_WriteInt(file, "exp", PlayerInfo[playerid][PLAYER_EXP]);
  275.     INI_WriteInt(file, "totalexp", ExpForLevel * PlayerInfo[playerid][PLAYER_LEVEL]);
  276.     /*INI_WriteInt(file, "weap1type", PlayerInfo[playerid][PLAYER_WEAP1TYPE]);
  277.     INI_WriteInt(file, "weap2type", PlayerInfo[playerid][PLAYER_WEAP2TYPE]);
  278.     INI_WriteInt(file, "weap3type", PlayerInfo[playerid][PLAYER_WEAP3TYPE]);
  279.     INI_WriteInt(file, "weap1spec", PlayerInfo[playerid][PLAYER_WEAP1SPEC]);
  280.     INI_WriteInt(file, "weap2spec", PlayerInfo[playerid][PLAYER_WEAP2SPEC]);
  281.     INI_WriteInt(file, "weap3spec", PlayerInfo[playerid][PLAYER_WEAP3SPEC]);
  282.     INI_WriteInt(file, "weap1lvl", PlayerInfo[playerid][PLAYER_WEAP1LVL]);
  283.     INI_WriteInt(file, "weap2lvl", PlayerInfo[playerid][PLAYER_WEAP2LVL]);
  284.     INI_WriteInt(file, "weap3lvl", PlayerInfo[playerid][PLAYER_WEAP3LVL]);*/
  285.     INI_WriteInt(file, "points", PlayerInfo[playerid][PLAYER_POINTS]);
  286.     INI_WriteInt(file, "strength", PlayerInfo[playerid][PLAYER_STRENGTH]);
  287.     INI_WriteInt(file, "defence", PlayerInfo[playerid][PLAYER_DEFENCE]);
  288.     INI_WriteInt(file, "weappoints", PlayerInfo[playerid][WEAPPOINTS]);
  289.     INI_WriteInt(file, "sawnoff", PlayerInfo[playerid][SAWNOFF]);
  290.     INI_WriteInt(file, "silenced", PlayerInfo[playerid][SILENCED]);
  291.     INI_WriteInt(file, "deagle", PlayerInfo[playerid][DEAGLE]);
  292.     INI_WriteInt(file, "shotgun", PlayerInfo[playerid][SHOTGUN]);
  293.     INI_WriteInt(file, "spas12", PlayerInfo[playerid][SPAS12]);
  294.     INI_WriteInt(file, "micro_uzi", PlayerInfo[playerid][MICRO_UZI]);
  295.     INI_WriteInt(file, "mp5", PlayerInfo[playerid][MP5]);
  296.     INI_WriteInt(file, "ak47", PlayerInfo[playerid][AK47]);
  297.     INI_WriteInt(file, "m4", PlayerInfo[playerid][M4]);
  298.     INI_WriteInt(file, "sniperrifle", PlayerInfo[playerid][SNIPERRIFLE]);
  299.     INI_Close(file);
  300. }
  301.  
  302. stock RegisterPlayer(playerid, password[])
  303. {
  304.     new playerName[MAX_PLAYER_NAME], playerip[20];
  305.     GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
  306.     GetPlayerIp(playerid, playerip, sizeof(playerip));
  307.     new userFile[32];
  308.     format(userFile, sizeof (userFile), "HAccounts/%s.ini", playerName);
  309.     new INI:file = INI_Open(userFile);
  310.     INI_WriteString(file, "IP", playerip);
  311.     INI_WriteInt(file, "password", udb_hash(password));
  312.     INI_WriteInt(file, "class", 0);
  313.     INI_WriteInt(file, "cash", 0);
  314.     INI_WriteInt(file, "score", 0);
  315.     INI_WriteInt(file, "level", 0);
  316.     INI_WriteInt(file, "exp", 0);
  317.     INI_WriteInt(file, "totalexp", ExpForLevel);
  318.     INI_WriteInt(file, "weap1type", 0);
  319.     INI_WriteInt(file, "weap2type", 0);
  320.     INI_WriteInt(file, "weap3type", 0);
  321.     INI_WriteInt(file, "weap1spec", 0);
  322.     INI_WriteInt(file, "weap2spec", 0);
  323.     INI_WriteInt(file, "weap3spec", 0);
  324.     INI_WriteInt(file, "weap1lvl", 0);
  325.     INI_WriteInt(file, "weap2lvl", 0);
  326.     INI_WriteInt(file, "weap3lvl", 0);
  327.     INI_WriteInt(file, "points", 0);
  328.     INI_WriteInt(file, "strength", 1);
  329.     INI_WriteInt(file, "defence", 1);
  330.     INI_WriteInt(file, "weappoints", 0);
  331.     INI_WriteInt(file, "sawnoff", 1);
  332.     INI_WriteInt(file, "silenced", 1);
  333.     INI_WriteInt(file, "deagle", 1);
  334.     INI_WriteInt(file, "shotgun", 1);
  335.     INI_WriteInt(file, "spas12", 1);
  336.     INI_WriteInt(file, "micro_uzi", 1);
  337.     INI_WriteInt(file, "mp5", 1);
  338.     INI_WriteInt(file, "ak47", 1);
  339.     INI_WriteInt(file, "m4", 1);
  340.     INI_WriteInt(file, "sniperrifle", 1);
  341.     INI_Close(file);
  342.     PlayerInfo[playerid][PLAYER_CASH] = 0;
  343.     PlayerInfo[playerid][PLAYER_SCORE] = 0;
  344.     PlayerInfo[playerid][PLAYER_LEVEL] = 1;
  345.     PlayerInfo[playerid][PLAYER_EXP] = 0;
  346.     PlayerInfo[playerid][PLAYER_TOTALEXP] = ExpForLevel;
  347.     /*PlayerInfo[playerid][PLAYER_WEAP1TYPE] = 0;
  348.     PlayerInfo[playerid][PLAYER_WEAP2TYPE] = 0;
  349.     PlayerInfo[playerid][PLAYER_WEAP3TYPE] = 0;
  350.     PlayerInfo[playerid][PLAYER_WEAP1SPEC] = 0;
  351.     PlayerInfo[playerid][PLAYER_WEAP2SPEC] = 0;
  352.     PlayerInfo[playerid][PLAYER_WEAP3SPEC] = 0;
  353.     PlayerInfo[playerid][PLAYER_WEAP1LVL] = 0;
  354.     PlayerInfo[playerid][PLAYER_WEAP2LVL] = 0;
  355.     PlayerInfo[playerid][PLAYER_WEAP3LVL] = 0;*/
  356.     PlayerInfo[playerid][PLAYER_POINTS] = 0;
  357.     PlayerInfo[playerid][PLAYER_STRENGTH] = 1;
  358.     PlayerInfo[playerid][PLAYER_DEFENCE] = 1;
  359.     PlayerInfo[playerid][WEAPPOINTS] = 0;
  360.     PlayerInfo[playerid][SAWNOFF] = 1;
  361.     PlayerInfo[playerid][SILENCED] = 1;
  362.     PlayerInfo[playerid][DEAGLE] = 1;
  363.     PlayerInfo[playerid][SHOTGUN] = 1;
  364.     PlayerInfo[playerid][SPAS12] = 1;
  365.     PlayerInfo[playerid][MICRO_UZI] = 1;
  366.     PlayerInfo[playerid][MP5] = 1;
  367.     PlayerInfo[playerid][AK47] = 1;
  368.     PlayerInfo[playerid][M4] = 1;
  369.     PlayerInfo[playerid][SNIPERRIFLE] = 1;
  370.     SendClientMessage(playerid, 0xffff00ff, "It appears you just registered. Type /help to see help for this gamemode");
  371. }
  372.  
  373. main()
  374. {
  375. }
  376.  
  377. public OnGameModeInit()
  378. {
  379.     print("\n--------------------------------------");
  380.     print(" King_Hual's MMORPG For SA:MP");
  381.     print("--------------------------------------\n");
  382.     SetGameModeText("MMORPG by King_Hual");
  383.     ShowNameTags(0);
  384.     AddPlayerClass(267,1958.3783,1343.1572,15.3746,270.1425,10,1,32,1000,24,100);
  385.     OpponentHPImg = TextDrawCreate(200.0, 0, "LD_OTB2:butnAo"); // Text is txdfile:texture
  386.     TextDrawFont(OpponentHPImg, 4); // Font ID 4 is the sprite draw font
  387.     TextDrawColor(OpponentHPImg,0xFFFFFF22);
  388.     TextDrawTextSize(OpponentHPImg,256,32); // Text size is the Width:Height
  389.     OpponentHPImgFull = TextDrawCreate(200.0, 0, "LD_OTB2:butnAo"); // Text is txdfile:texture
  390.     TextDrawFont(OpponentHPImgFull, 4); // Font ID 4 is the sprite draw font
  391.     TextDrawColor(OpponentHPImgFull,0xFFFFFFFF);
  392.     TextDrawTextSize(OpponentHPImgFull,256,32); // Text size is the Width:Height
  393. }
  394.  
  395. public OnGameModeExit()
  396. {
  397. }
  398.  
  399. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
  400. {
  401.     if (logged_in[playerid] == 1)
  402.     {
  403.         new string[32], Float:HP;
  404.         GetPlayerHealth(playerid, HP);
  405.         if (HP > 0)
  406.         {
  407.             if (issuerid != INVALID_PLAYER_ID)
  408.             {
  409.                 if ((amount / 2) + (PlayerInfo[issuerid][PLAYER_STRENGTH] / 10) - (PlayerInfo[playerid][PLAYER_DEFENCE] / 10) < 0)
  410.                 {
  411.                     SetProgressBarValue(HPBar[playerid], GetProgressBarValue(HPBar[playerid]) - 1);
  412.                     UpdateProgressBar(HPBar[playerid], playerid);
  413.                 }
  414.                 else
  415.                 {
  416.                     SetProgressBarValue(HPBar[playerid], GetProgressBarValue(HPBar[playerid]) - ((amount + (PlayerInfo[issuerid][PLAYER_STRENGTH] / 10) - (PlayerInfo[playerid][PLAYER_DEFENCE] / 10)) / 2));
  417.                     UpdateProgressBar(HPBar[playerid], playerid);
  418.                 }
  419.             }
  420.             else
  421.             {
  422.                 SetProgressBarValue(HPBar[playerid], GetProgressBarValue(HPBar[playerid]) - (amount / 2));
  423.                 UpdateProgressBar(HPBar[playerid], playerid);
  424.             }
  425.             if (GetProgressBarValue(HPBar[playerid]) <= 0.4)
  426.             {
  427.                 SetPlayerHealth(playerid, 0);
  428.                 TextDrawSetString(HPText[playerid], "DEAD");
  429.             }
  430.             else
  431.             {
  432.                 format(string, sizeof(string), "%.0f/%d", GetProgressBarValue(HPBar[playerid]), (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  433.                 TextDrawSetString(HPText[playerid], string);
  434.                 UpdateBar(playerid);
  435.                 SetPlayerHealth(playerid, 100);
  436.             }
  437.         }
  438.         if (issuerid != INVALID_PLAYER_ID)
  439.         {
  440.  
  441.             new oppstr1[64], oppstr2[32], pname[MAX_PLAYER_NAME];
  442.             KillTimer(OpponentHPHide[issuerid]);
  443.             GetPlayerName(playerid, pname, sizeof(pname));
  444.             format(oppstr1, sizeof(oppstr1), "%s's HP:", pname);
  445.             TextDrawSetString(OpponentName[issuerid], oppstr1);
  446.             format(oppstr2, sizeof(oppstr2), "%.0f/%d", GetProgressBarValue(HPBar[playerid]), (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  447.             TextDrawSetString(OpponentHPText[issuerid], oppstr2);
  448.             SetProgressBarMaxValue(OpponentHPBar[issuerid], (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  449.             SetProgressBarValue(OpponentHPBar[issuerid], GetProgressBarValue(HPBar[playerid]));
  450.             ShowProgressBarForPlayer(issuerid, OpponentHPBar[issuerid]);
  451.             UpdateProgressBar(OpponentHPBar[issuerid], issuerid);
  452.             TextDrawShowForPlayer(issuerid, OpponentHPText[issuerid]);
  453.             TextDrawShowForPlayer(issuerid, OpponentName[issuerid]);
  454.             TextDrawHideForPlayer(issuerid, OpponentHPImg);
  455.             TextDrawShowForPlayer(issuerid, OpponentHPImgFull);
  456.             OpponentHPHide[playerid] = SetTimerEx("OppHPHideTimer", 15000, 0, "i", issuerid);
  457.         }
  458.  
  459.     }
  460. }
  461.  
  462. forward OppHPHideTimer(playerid);
  463.  
  464. public OppHPHideTimer(playerid)
  465. {
  466.         HideProgressBarForPlayer(playerid, OpponentHPBar[playerid]);
  467.         TextDrawHideForPlayer(playerid, OpponentHPText[playerid]);
  468.         TextDrawHideForPlayer(playerid, OpponentName[playerid]);
  469.         TextDrawShowForPlayer(playerid, OpponentHPImg);
  470.         TextDrawHideForPlayer(playerid, OpponentHPImgFull);
  471. }
  472.  
  473. public OnPlayerRequestClass(playerid, classid)
  474. {
  475.     SetPlayerInterior(playerid,14);
  476.     SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
  477.     SetPlayerFacingAngle(playerid, 270.0);
  478.     SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
  479.     SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
  480.     return 1;
  481. }
  482.  
  483. public OnPlayerConnect(playerid)
  484. {
  485.     new pname[MAX_PLAYER_NAME];
  486.     Retries[playerid] = 0;
  487.     logged_in[playerid] = 0;
  488.     SendDeathMessage(INVALID_PLAYER_ID, playerid, 200);
  489.     new pfile[100];
  490.     GetPlayerName(playerid, pname, sizeof(pname));
  491.     format(pfile, sizeof(pfile), "HAccounts/%s.ini",pname);
  492.     if(!fexist(pfile))  {
  493.         ShowPlayerDialog(playerid,101,DIALOG_STYLE_PASSWORD,"Registration","Please enter a password to register this account!","Register","Cancel");
  494.     }
  495.     else
  496.     {
  497.         INI_ParseFile(pfile, "yini", .bExtra = true, .extra = playerid);
  498.         ShowPlayerDialog(playerid,100,DIALOG_STYLE_PASSWORD,"Login","Please enter a password to login to this account!","Login","Cancel");
  499.     }
  500.     #if defined UseProgBar
  501.     bar[playerid] = CreateProgressBar(500.00, 5.00, 137.50, 15.19, ProgBarColor, 100.0);
  502.     #endif
  503.     ExpText[playerid] = TextDrawCreate(500.000000,3.000000,"_");
  504.     TextDrawAlignment(ExpText[playerid],0);
  505.     TextDrawBackgroundColor(ExpText[playerid],0x000000ff);
  506.     TextDrawFont(ExpText[playerid],1);
  507.     TextDrawLetterSize(ExpText[playerid],0.399999,1.800000);
  508.     TextDrawColor(ExpText[playerid],0xffff00ff);
  509.     TextDrawSetOutline(ExpText[playerid],1);
  510.     TextDrawSetProportional(ExpText[playerid],1);
  511.  
  512.     LevelText[playerid] = TextDrawCreate(546.000000,25.000000,"_");
  513.     TextDrawAlignment(LevelText[playerid],0);
  514.     TextDrawBackgroundColor(LevelText[playerid],0x000000ff);
  515.     TextDrawFont(LevelText[playerid],2);
  516.     TextDrawLetterSize(LevelText[playerid],0.299999,1.400000);
  517.     TextDrawColor(LevelText[playerid],0x00ff0099);
  518.     TextDrawSetOutline(LevelText[playerid],1);
  519.     TextDrawSetProportional(LevelText[playerid],1);
  520.     TextDrawSetShadow(LevelText[playerid],1);
  521.  
  522.     HPBar[playerid] = CreateProgressBar(548.00, 68.2, 58.50, 5.50, -16776961, 100.0);
  523.  
  524.     HPText[playerid] = TextDrawCreate(556.500000,66.500000,"_");
  525.     TextDrawAlignment(HPText[playerid],0);
  526.     TextDrawBackgroundColor(HPText[playerid],0x000000ff);
  527.     TextDrawFont(HPText[playerid],3);
  528.     TextDrawLetterSize(HPText[playerid],0.30,0.80);
  529.     TextDrawColor(HPText[playerid],0xffffffff);
  530.     TextDrawSetOutline(HPText[playerid],1);
  531.     TextDrawSetProportional(HPText[playerid],1);
  532.     TextDrawSetShadow(HPText[playerid],1);
  533.  
  534.     HP3DText[playerid] =Create3DTextLabel("_", -1, 0, 0, 0, 50, 0, 1);
  535.  
  536.     NameTag[playerid] = Create3DTextLabel(pname, 0xFFFFFFFF, 0,0,0, 50, 0, 1);
  537.  
  538.     LevelLabel[playerid] = Create3DTextLabel("_", TextLabelColor, 0, 0, 0, 50, 1);
  539.  
  540.     OpponentHPBar[playerid] = CreateProgressBar(234.00, 15.00, 184.50, 5.19, -16776961, 100.0);
  541.  
  542.     /*OpponentHPText[playerid] = TextDrawCreate(556.500000,66.500000,"100/100");
  543.     TextDrawAlignment(OpponentHPText[playerid],0);
  544.     TextDrawBackgroundColor(OpponentHPText[playerid],0x000000ff);
  545.     TextDrawFont(OpponentHPText[playerid],3);
  546.     TextDrawLetterSize(OpponentHPText[playerid],0.30,0.80);
  547.     TextDrawColor(OpponentHPText[playerid],0xffffffff);
  548.     TextDrawSetOutline(OpponentHPText[playerid],1);
  549.     TextDrawSetProportional(OpponentHPText[playerid],1);
  550.     TextDrawSetShadow(HPText[OpponentHPText],1);*/
  551.  
  552.     OpponentHPText[playerid] = TextDrawCreate(286.000000,12.900000,"_");
  553.     OpponentName[playerid] = TextDrawCreate(233.000000,2.000000,"_");
  554.     TextDrawAlignment(OpponentHPText[playerid],0);
  555.     TextDrawAlignment(OpponentName[playerid],0);
  556.     TextDrawBackgroundColor(OpponentHPText[playerid],0x000000ff);
  557.     TextDrawBackgroundColor(OpponentName[playerid],0x000000ff);
  558.     TextDrawFont(OpponentHPText[playerid],3);
  559.     TextDrawLetterSize(OpponentHPText[playerid],0.599999,0.899999);
  560.     TextDrawFont(OpponentName[playerid],1);
  561.     TextDrawLetterSize(OpponentName[playerid],0.499999,0.899999);
  562.     TextDrawColor(OpponentHPText[playerid],0xffffffff);
  563.     TextDrawColor(OpponentName[playerid],0xff0000cc);
  564.     TextDrawSetOutline(OpponentHPText[playerid],1);
  565.     TextDrawSetOutline(OpponentName[playerid],1);
  566.     TextDrawSetProportional(OpponentHPText[playerid],1);
  567.     TextDrawSetProportional(OpponentName[playerid],1);
  568.     TextDrawSetShadow(OpponentHPText[playerid],5);
  569.     TextDrawSetShadow(OpponentName[playerid],1);
  570.  
  571.     return 1;
  572. }
  573.  
  574. public OnPlayerDisconnect(playerid, reason)
  575. {
  576.     if(logged_in[playerid] == 1)
  577.     {
  578.         YINI_SAVE(playerid);
  579.     }
  580.     DestroyProgressBar(HPBar[playerid]);
  581.     TextDrawDestroy(HPText[playerid]);
  582.     TextDrawDestroy(ExpText[playerid]);
  583.     TextDrawDestroy(ExpText[playerid]);
  584.     Delete3DTextLabel(HP3DText[playerid]);
  585.     #if defined UseProgBar
  586.     DestroyProgressBar(bar[playerid]);
  587.     #endif
  588.     Delete3DTextLabel(LevelLabel[playerid]);
  589.     Retries[playerid] = 0;
  590.     logged_in[playerid] = 0;
  591.     SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
  592.     return 1;
  593. }
  594.  
  595. public OnPlayerSpawn(playerid)
  596. {
  597.     SetPlayerInterior(playerid, 0);
  598.     new string[16], string2[32];
  599.     TextDrawShowForPlayer(playerid, OpponentHPImg);
  600.     #if defined StaticNums
  601.     format(string, sizeof(string), "Level: %02i",PlayerInfo[playerid][PLAYER_LEVEL]);
  602.     #else
  603.     format(string, sizeof(string), "Level: %i",PlayerInfo[playerid][PLAYER_LEVEL]);
  604.     #endif
  605.     format(string2, sizeof(string2), "%i/%i",(PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2, (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  606.     TextDrawSetString(HPText[playerid], string2);
  607.     SetProgressBarMaxValue(HPBar[playerid], (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  608.     SetProgressBarValue(HPBar[playerid], (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  609.     UpdateProgressBar(HPBar[playerid], playerid);
  610.     ShowProgressBarForPlayer(playerid, HPBar[playerid]);
  611.     TextDrawShowForPlayer(playerid, HPText[playerid]);
  612.     Attach3DTextLabelToPlayer(HP3DText[playerid], playerid, 0, 0, 0.2);
  613.     Attach3DTextLabelToPlayer(NameTag[playerid], playerid, 0, 0, 0.4);
  614.     UpdateBar(playerid);
  615.     Update3DTextLabelText(LevelLabel[playerid], TextLabelColor, string);
  616.     Attach3DTextLabelToPlayer(LevelLabel[playerid], playerid, 0, 0, 0.6);
  617.     TextDrawShowForPlayer(playerid, ExpText[playerid]);
  618.     TextDrawShowForPlayer(playerid, LevelText[playerid]);
  619.     UpdateProgressBar(bar[playerid], playerid);
  620.     if (PlayerInfo[playerid][PLAYER_POINTS] > 0 || PlayerInfo[playerid][WEAPPOINTS] > 0)
  621.     {
  622.         GameTextForPlayer(playerid, "~p~You have unused points!~n~Press your ~g~~k~~CONVERSATION_NO~ key ~w~or ~g~~k~~CONVERSATION_YES~ key ~w~to open the upgrade stations!", 5000, 4);
  623.     }
  624.     return 1;
  625. }
  626.  
  627. public OnPlayerDeath(playerid, killerid, reason)
  628. {
  629.     if (killerid != INVALID_PLAYER_ID)
  630.     {
  631.         KillTimer(OpponentHPHide[killerid]);
  632.         KillTimer(OpponentHPHide[playerid]);
  633.         HideProgressBarForPlayer(playerid, OpponentHPBar[playerid]);
  634.         TextDrawHideForPlayer(playerid, OpponentHPText[playerid]);
  635.         TextDrawHideForPlayer(playerid, OpponentName[playerid]);
  636.         TextDrawShowForPlayer(playerid, OpponentHPImg);
  637.         TextDrawHideForPlayer(playerid, OpponentHPImgFull);
  638.         HideProgressBarForPlayer(killerid, OpponentHPBar[killerid]);
  639.         TextDrawHideForPlayer(killerid, OpponentHPText[killerid]);
  640.         TextDrawHideForPlayer(killerid, OpponentName[killerid]);
  641.         TextDrawShowForPlayer(killerid, OpponentHPImg);
  642.         TextDrawHideForPlayer(killerid, OpponentHPImgFull);
  643.     }
  644.     if (killerid != playerid) {
  645.         if (GetPlayerExpLevel(playerid) < GetPlayerExpLevel(killerid))
  646.         {
  647.             GivePlayerExp(killerid, 100, "killing a lower level player");
  648.         }
  649.         else if (GetPlayerExpLevel(playerid) > GetPlayerExpLevel(killerid))
  650.         {
  651.             GivePlayerExp(killerid, 300, "killing a higher level player");
  652.         }
  653.         else
  654.         {
  655.             GivePlayerExp(killerid, 200, "killing a player at your own level");
  656.         }
  657.         Update3DTextLabelText(HP3DText[playerid],-1, "{ff2400}DEAD");
  658.     } // An example of using my exp system.
  659.     return 1;
  660. }
  661.  
  662. public OnVehicleSpawn(vehicleid)
  663. {
  664.     return 1;
  665. }
  666.  
  667. public OnVehicleDeath(vehicleid, killerid)
  668. {
  669.     return 1;
  670. }
  671.  
  672. public OnPlayerText(playerid, text[])
  673. {
  674.     return 1;
  675. }
  676.  
  677. public OnPlayerCommandText(playerid, cmdtext[])
  678. {
  679.     if(!strcmp(cmdtext, "/help", true))
  680.     {
  681.         SendClientMessage(playerid, 0xffff00ff, "Level up by gaining EXP. With every level, you get one Passive Point and one Weapon Point.");
  682.         SendClientMessage(playerid, 0xffff00ff, "Open the Weapon upgrade station by pressing your 'Conversation Yes' key.");
  683.         SendClientMessage(playerid, 0xffff00ff, "Open the Passive Skill upgrade station by pressing your 'Conversation No' key.");
  684.         SendClientMessage(playerid, 0xffff00ff, "If you don't know which these keys are, type /yes for the yes key or /no for the no key to see them.");
  685.     }
  686.     if(!strcmp(cmdtext, "/yes", true))
  687.     {
  688.         GameTextForPlayer(playerid, "Your 'Yes' key is bound to ~g~~k~~CONVERSATION_YES~", 6000, 5);
  689.     }
  690.     if(!strcmp(cmdtext, "/no", true))
  691.     {
  692.         GameTextForPlayer(playerid, "Your 'No' key is bound to ~g~~k~~CONVERSATION_NO~", 6000, 5);
  693.     }
  694.     return 1;
  695. }
  696.  
  697. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  698. {
  699.     return 1;
  700. }
  701.  
  702. public OnPlayerExitVehicle(playerid, vehicleid)
  703. {
  704.     return 1;
  705. }
  706.  
  707. public OnPlayerStateChange(playerid, newstate, oldstate)
  708. {
  709.     return 1;
  710. }
  711.  
  712. public OnPlayerEnterCheckpoint(playerid)
  713. {
  714.     return 1;
  715. }
  716.  
  717. public OnPlayerLeaveCheckpoint(playerid)
  718. {
  719.     return 1;
  720. }
  721.  
  722. public OnPlayerEnterRaceCheckpoint(playerid)
  723. {
  724.     return 1;
  725. }
  726.  
  727. public OnPlayerLeaveRaceCheckpoint(playerid)
  728. {
  729.     return 1;
  730. }
  731.  
  732. public OnRconCommand(cmd[])
  733. {
  734.     return 1;
  735. }
  736.  
  737. public OnPlayerRequestSpawn(playerid)
  738. {
  739.     if (logged_in[playerid] == 0)
  740.     {
  741.         SendClientMessage(playerid, 0xFF00FFFF, "*You need to login to spawn.*");
  742.         return 0;
  743.     }
  744.     else
  745.     {
  746.         return 1;
  747.     }
  748. }
  749.  
  750. public OnObjectMoved(objectid)
  751. {
  752.     return 1;
  753. }
  754.  
  755. public OnPlayerObjectMoved(playerid, objectid)
  756. {
  757.     return 1;
  758. }
  759.  
  760. public OnPlayerPickUpPickup(playerid, pickupid)
  761. {
  762.     return 1;
  763. }
  764.  
  765. public OnVehicleMod(playerid, vehicleid, componentid)
  766. {
  767.     return 1;
  768. }
  769.  
  770. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  771. {
  772.     return 1;
  773. }
  774.  
  775. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  776. {
  777.     return 1;
  778. }
  779.  
  780. public OnPlayerSelectedMenuRow(playerid, row)
  781. {
  782.     return 1;
  783. }
  784.  
  785. public OnPlayerExitedMenu(playerid)
  786. {
  787.     return 1;
  788. }
  789.  
  790. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  791. {
  792.     return 1;
  793. }
  794.  
  795. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  796. {
  797.     if (newkeys & KEY_NO)
  798.     {
  799.         if (logged_in[playerid] == 1)
  800.         {
  801.             new string[45], string2[90];
  802.             format(string2, sizeof(string2), "Upgrade Strength - Current Level: %i\r\nUpgrade Defence - Current Level: %i", PlayerInfo[playerid][PLAYER_STRENGTH], PlayerInfo[playerid][PLAYER_DEFENCE]);
  803.             format(string, sizeof(string), "Upgrade Station - Upgrade Points Left: %i", PlayerInfo[playerid][PLAYER_POINTS]);
  804.             ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,string,string2,"Accept", "Cancel");
  805.         }
  806.     }
  807.     if (newkeys & KEY_YES)
  808.     {
  809.         if (logged_in[playerid] == 1)
  810.         {
  811.             new string[45], string2[180];
  812.             format(string, sizeof(string), "Weapon Station - Upgrade Points Left: %i", PlayerInfo[playerid][WEAPPOINTS]);
  813.             format(string2, sizeof(string2), "Sawnoff: %i\r\nSilenced Pistol: %i\r\nDeagle: %i\r\nShotgun: %i\r\nSpas12: %i\r\nUzi: %i\r\nMP5: %i\r\nAK47: %i\r\nM4: %i\r\nSniper Rifle: %i", PlayerInfo[playerid][SAWNOFF], PlayerInfo[playerid][SILENCED],PlayerInfo[playerid][DEAGLE], PlayerInfo[playerid][SHOTGUN], PlayerInfo[playerid][SPAS12],PlayerInfo[playerid][MICRO_UZI], PlayerInfo[playerid][MP5], PlayerInfo[playerid][AK47], PlayerInfo[playerid][M4], PlayerInfo[playerid][SNIPERRIFLE]);
  814.             ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,string,string2,"Accept", "Cancel");
  815.         }
  816.     }
  817.     return 1;
  818. }
  819.  
  820. public OnRconLoginAttempt(ip[], password[], success)
  821. {
  822.     return 1;
  823. }
  824.  
  825. public OnPlayerUpdate(playerid)
  826. {
  827.     return 1;
  828. }
  829.  
  830. public OnPlayerStreamIn(playerid, forplayerid)
  831. {
  832.     return 1;
  833. }
  834.  
  835. public OnPlayerStreamOut(playerid, forplayerid)
  836. {
  837.     return 1;
  838. }
  839.  
  840. public OnVehicleStreamIn(vehicleid, forplayerid)
  841. {
  842.     return 1;
  843. }
  844.  
  845. public OnVehicleStreamOut(vehicleid, forplayerid)
  846. {
  847.     return 1;
  848. }
  849.  
  850. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  851. {
  852.         if(dialogid == 101)
  853.         {
  854.             if(!strlen(inputtext) || !response) return ShowPlayerDialog(playerid,101,DIALOG_STYLE_PASSWORD,"Registration","ERROR: You did not enter a password.\nPlease enter a password to register this account!","Register","Cancel");
  855.             new string2[64], string3[32], string4[64];
  856.             RegisterPlayer(playerid, inputtext);
  857.             logged_in[playerid] = 1;
  858.             SendClientMessage(playerid, 0x00FF00FF, "*You have been registered! You have also been logged in!*");
  859.             #if defined StaticNums
  860.             format(string2, sizeof(string2), "Exp: %05d/%05d", PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]));
  861.             format(string3, sizeof(string3), "Level: %02d", PlayerInfo[playerid][PLAYER_LEVEL]);
  862.             #else
  863.             format(string2, sizeof(string2), "Exp: %d/%d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  864.             format(string3, sizeof(string3), "Level: %d",PlayerInfo[playerid][PLAYER_LEVEL]);
  865.             #endif
  866.             TextDrawSetString(ExpText[playerid], string2);
  867.             TextDrawSetString(LevelText[playerid], string3);
  868.             #if defined UseProgBar
  869.             SetProgressBarMaxValue(bar[playerid], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  870.             SetProgressBarValue(bar[playerid], PlayerInfo[playerid][PLAYER_EXP]);
  871.             #endif
  872.             SetProgressBarMaxValue(HPBar[playerid], (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  873.             SetProgressBarValue(HPBar[playerid], (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  874.             format(string4, sizeof(string4), "%d/%d",(PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2, (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  875.             TextDrawSetString(HPText[playerid], string4);
  876.             SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
  877.             SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, 1);
  878.             SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, 1);
  879.             SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, 1);
  880.             SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
  881.             SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, 1);
  882.             SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
  883.             SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, 1);
  884.             SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, 1);
  885.             SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, 1);
  886.             SetPlayerSkillLevel(playerid, WEAPONSKILL_SNIPERRIFLE, 1);
  887.         }
  888.         if(dialogid == 100)
  889.         {
  890.             if(!strlen(inputtext) || !response) return ShowPlayerDialog(playerid,100,DIALOG_STYLE_PASSWORD,"Login","ERROR: You did not enter a password.\nPlease enter a password to login to this account!","Login","Cancel");
  891.             LoginPlayer(playerid, inputtext);
  892.         }
  893.         if (dialogid == 1)
  894.         {
  895.             if (response)
  896.             {
  897.                 if (PlayerInfo[playerid][PLAYER_POINTS] > 0)
  898.                 {
  899.                     switch(listitem)
  900.                     {
  901.                         case 0:
  902.                         {
  903.                                 PlayerInfo[playerid][PLAYER_STRENGTH]++;
  904.                                 SendClientMessage(playerid, 0x00FF00FF, "You have upgraded your strength by 1 point!");
  905.                         }
  906.                         case 1:
  907.                         {
  908.                                 PlayerInfo[playerid][PLAYER_DEFENCE]++;
  909.                                 SendClientMessage(playerid, 0x00FF00FF, "You have upgraded your defence by 1 point!");
  910.                         }
  911.                     }
  912.                     new string[45], string2[90];
  913.                     format(string2, sizeof(string2), "Upgrade Strength - Current Level: %i\r\nUpgrade Defence - Current Level: %i", PlayerInfo[playerid][PLAYER_STRENGTH], PlayerInfo[playerid][PLAYER_DEFENCE]);
  914.                     format(string, sizeof(string), "Upgrade Station - Upgrade Points Left: %i", PlayerInfo[playerid][PLAYER_POINTS]);
  915.                     PlayerInfo[playerid][PLAYER_POINTS] -= 1;
  916.                     ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,string,string2,"Accept", "Cancel");
  917.                 }
  918.                 else
  919.                 {
  920.                     SendClientMessage(playerid, 0x00FF00FF, "You do not have enough points!");
  921.                 }
  922.             }
  923.         }
  924.         if (dialogid == 2)
  925.         {
  926.             if (response)
  927.             {
  928.                 if (PlayerInfo[playerid][WEAPPOINTS] > 0)
  929.                 {
  930.                     switch(listitem)
  931.                     {
  932.                         case 0:
  933.                         {
  934.                                 PlayerInfo[playerid][SAWNOFF]++;
  935.                                 SendClientMessage(playerid, 0x00FF00FF, "You have upgraded your Sawnoff skills by 1 point!");
  936.                                 SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, PlayerInfo[playerid][SAWNOFF] * 10);
  937.                         }
  938.                         case 1:
  939.                         {
  940.                                 PlayerInfo[playerid][SILENCED]++;
  941.                                 SendClientMessage(playerid, 0x00FF00FF, "You have upgraded your Silenced Pistol skills by 1 point!");
  942.                                 SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, PlayerInfo[playerid][SILENCED] * 10);
  943.                         }
  944.                         case 2:
  945.                         {
  946.                                 PlayerInfo[playerid][DEAGLE]++;
  947.                                 SendClientMessage(playerid, 0x00FF00FF, "You have upgraded your Deagle skills by 1 point!");
  948.                                 SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, PlayerInfo[playerid][DEAGLE] * 10);
  949.                         }
  950.                         case 3:
  951.                         {
  952.                                 PlayerInfo[playerid][SHOTGUN]++;
  953.                                 SendClientMessage(playerid, 0x00FF00FF, "You have upgraded your Shotgun skills by 1 point!");
  954.                                 SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, PlayerInfo[playerid][SHOTGUN] * 10);
  955.                         }
  956.                         case 4:
  957.                         {
  958.                                 PlayerInfo[playerid][SPAS12]++;
  959.                                 SendClientMessage(playerid, 0x00FF00FF, "You have upgraded your Spas12 skills by 1 point!");
  960.                                 SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, PlayerInfo[playerid][SPAS12] * 10);
  961.                         }
  962.                         case 5:
  963.                         {
  964.                                 PlayerInfo[playerid][MICRO_UZI]++;
  965.                                 SendClientMessage(playerid, 0x00FF00FF, "You have upgraded your Micro Uzi skills by 1 point!");
  966.                                 SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, PlayerInfo[playerid][MICRO_UZI] * 10);
  967.                         }
  968.                         case 6:
  969.                         {
  970.                                 PlayerInfo[playerid][MP5]++;
  971.                                 SendClientMessage(playerid, 0x00FF00FF, "You have upgraded your MP5 skills by 1 point!");
  972.                                 SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, PlayerInfo[playerid][MP5] * 10);
  973.                         }
  974.                         case 7:
  975.                         {
  976.                                 PlayerInfo[playerid][AK47]++;
  977.                                 SendClientMessage(playerid, 0x00FF00FF, "You have upgraded your AK47 skills by 1 point!");
  978.                                 SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, PlayerInfo[playerid][AK47] * 10);
  979.                         }
  980.                         case 8:
  981.                         {
  982.                                 PlayerInfo[playerid][M4]++;
  983.                                 SendClientMessage(playerid, 0x00FF00FF, "You have upgraded your M4 skills by 1 point!");
  984.                                 SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, PlayerInfo[playerid][M4] * 10);
  985.                         }
  986.                         case 9:
  987.                         {
  988.                                 PlayerInfo[playerid][SNIPERRIFLE]++;
  989.                                 SendClientMessage(playerid, 0x00FF00FF, "You have upgraded your Sniper Rifle skills by 1 point!");
  990.                                 SetPlayerSkillLevel(playerid, WEAPONSKILL_SNIPERRIFLE, PlayerInfo[playerid][SNIPERRIFLE] * 10);
  991.                         }
  992.                     }
  993.                     new string[45], string2[180];
  994.                     PlayerInfo[playerid][WEAPPOINTS] -= 1;
  995.                     format(string, sizeof(string), "Weapon Station - Upgrade Points Left: %i", PlayerInfo[playerid][WEAPPOINTS]);
  996.                     format(string2, sizeof(string2), "Sawnoff: %i\r\nSilenced Pistol: %i\r\nDeagle: %i\r\nShotgun: %i\r\nSpas12: %i\r\nUzi: %i\r\nMP5: %i\r\nAK47: %i\r\nM4: %i\r\nSniper Rifle: %i", PlayerInfo[playerid][SAWNOFF], PlayerInfo[playerid][SILENCED],PlayerInfo[playerid][DEAGLE], PlayerInfo[playerid][SHOTGUN], PlayerInfo[playerid][SPAS12],PlayerInfo[playerid][MICRO_UZI], PlayerInfo[playerid][MP5], PlayerInfo[playerid][AK47], PlayerInfo[playerid][M4], PlayerInfo[playerid][SNIPERRIFLE]);
  997.                     ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,string,string2,"Accept", "Cancel");
  998.                 }
  999.                 else
  1000.                 {
  1001.                     SendClientMessage(playerid, 0x00FF00FF, "You do not have enough points!");
  1002.                 }
  1003.             }
  1004.         }
  1005.         return 1;
  1006. }
  1007.  
  1008. stock LoginPlayer(playerid, password[])
  1009. {
  1010.     if (udb_hash(password) == PlayerInfo[playerid][PLAYER_PASS])
  1011.     {
  1012.         new string2[64], string3[64], string4[64];
  1013.         GivePlayerMoney(playerid, PlayerInfo[playerid][PLAYER_CASH]);
  1014.         SetPlayerScore(playerid, PlayerInfo[playerid][PLAYER_SCORE]);
  1015.         logged_in[playerid] = 1;
  1016.         SendClientMessage(playerid, 0x00FF00FF, "*You have been logged in!*");
  1017.         #if defined StaticNums
  1018.         format(string2, sizeof(string2), "Exp: %05d/%05d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  1019.         format(string3, sizeof(string3), "Level: %02d",PlayerInfo[playerid][PLAYER_LEVEL]);
  1020.         #else
  1021.         format(string2, sizeof(string2), "Exp: %d/%d",PlayerInfo[playerid][PLAYER_EXP], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  1022.         format(string3, sizeof(string3), "Level: %d",PlayerInfo[playerid][PLAYER_LEVEL]);
  1023.         #endif
  1024.         TextDrawSetString(ExpText[playerid], string2);
  1025.         TextDrawSetString(LevelText[playerid], string3);
  1026.         #if defined UseProgBar
  1027.         SetProgressBarMaxValue(bar[playerid], PlayerInfo[playerid][PLAYER_TOTALEXP]);
  1028.         SetProgressBarValue(bar[playerid], PlayerInfo[playerid][PLAYER_EXP]);
  1029.         #endif
  1030.         TextDrawColor(HPText[playerid], 0xffffffff);
  1031.         format(string4, sizeof(string4), "%d/%d",(PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2, (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  1032.         TextDrawSetString(HPText[playerid], string4);
  1033.         SetProgressBarMaxValue(HPBar[playerid], (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  1034.         SetProgressBarValue(HPBar[playerid], (PlayerInfo[playerid][PLAYER_LEVEL] * 50) / 2);
  1035.         Attach3DTextLabelToPlayer(HP3DText[playerid], playerid, 0, 0, 0.2);
  1036.         Attach3DTextLabelToPlayer(NameTag[playerid], playerid, 0, 0, 0.4);
  1037.         SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, PlayerInfo[playerid][SAWNOFF] * 10);
  1038.         SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, PlayerInfo[playerid][SILENCED] * 10);
  1039.         SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, PlayerInfo[playerid][DEAGLE] * 10);
  1040.         SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, PlayerInfo[playerid][SHOTGUN] * 10);
  1041.         SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, PlayerInfo[playerid][SPAS12] * 10);
  1042.         SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, PlayerInfo[playerid][MICRO_UZI] * 10);
  1043.         SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, PlayerInfo[playerid][MP5] * 10);
  1044.         SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, PlayerInfo[playerid][AK47] * 10);
  1045.         SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, PlayerInfo[playerid][M4] * 10);
  1046.         SetPlayerSkillLevel(playerid, WEAPONSKILL_SNIPERRIFLE, PlayerInfo[playerid][SNIPERRIFLE] * 10);
  1047.     }
  1048.     else
  1049.         {
  1050.             ShowPlayerDialog(playerid,100,DIALOG_STYLE_PASSWORD,"Login","ERROR: Invalid Password.\nPlease enter a password to login to this account!","Login","Cancel");
  1051.             Retries[playerid]++;
  1052.             if (Retries[playerid] == 5)
  1053.             {
  1054.                 SendClientMessage(playerid, 0xFF0000, "*You have been kicked for 5 incorrect password inputs.*");
  1055.                 Kick(playerid);
  1056.             }
  1057.         }
  1058.     return 1;
  1059. }
  1060.  
  1061. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  1062. {
  1063.     return 1;
  1064. }
  1065.  
  1066. stock udb_hash(buf[]) {
  1067.     new length=strlen(buf);
  1068.     new s1 = 1;
  1069.     new s2 = 0;
  1070.     new n;
  1071.     for (n=0; n<length; n++)
  1072.     {
  1073.        s1 = (s1 + buf[n]) % 65521;
  1074.        s2 = (s2 + s1)     % 65521;
  1075.     }
  1076.     return (s2 << 16) + s1;
  1077. }
Advertisement
Add Comment
Please, Sign In to add comment