Guest User

My first gamemode paste - finelaq

a guest
Oct 20th, 2013
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 39.88 KB | None | 0 0
  1. // This is my first gamemode.
  2. // Credits:
  3. // Login & Register = Kushi
  4. // Gamemode = By Me!
  5.  
  6. /* !!!!!!!!!DO NOT REMOVE CREDITS!!!!!!!!! */
  7.  
  8. #include <a_samp>
  9. #include <YSI\y_ini>
  10. #include <sscanf>
  11. #include <zcmd>
  12. #include <a_samp>
  13. #include <core>
  14. #include <float>
  15. #include "../include/gl_spawns.inc"
  16. #include "../include/gl_common.inc"
  17.  
  18. #pragma tabsize 0
  19.  
  20. // Dialogs:
  21. #define DIALOG_REGISTER 1
  22. #define DIALOG_LOGIN 2
  23. #define DIALOG_GUNSHOP 3
  24. #define DIALOG_HELP 4
  25. #define DIALOG_AHELP 5
  26.  
  27. //Folder:
  28. #define FOLDER "Server Stats/Players/%s.ini"
  29.  
  30. //Colors:
  31. #define COLOR_RED 0xF21616FF
  32. #define COLOR_GREY 0xDBDBDBFF
  33. #define COLOR_YELLOW 0xF7EA31FF
  34. #define COLOR_GREEN 0x509E2CFF
  35. #define COL_WHITE "{FFFFFF}"
  36. #define COL_RED "{F81414}"
  37. #define COL_GREEN "{00FF22}"
  38. #define COL_LIGHTBLUE "{00CED1}"
  39.  
  40. //Enums:
  41. enum pInfo
  42. {
  43.     pPass,
  44.     pCash,
  45.     pAdmin,
  46.     pKills,
  47.     pDeaths,
  48.     Score,
  49.     Job
  50. }
  51. new PlayerInfo[MAX_PLAYERS][pInfo];
  52. new GodMode[MAX_PLAYERS];
  53. new ScoreFunc[MAX_PLAYERS];
  54. new RestartFunc[MAX_PLAYERS];
  55. new RMessages[][] =
  56. {
  57.     "[SERVER] Check the server rules! (/rules)", //this is the text of your first message
  58.     "[SERVER] Be sure you check the forum, at www.link.com", //this is the text of your second message
  59.     "[SERVER] etc..." //this is the text of your third message
  60. };
  61.  
  62. public LoadUser_data(playerid,name[],value[])
  63. {
  64.     INI_Int("Password",PlayerInfo[playerid][pPass]);
  65.     INI_Int("Cash",PlayerInfo[playerid][pCash]);
  66.     INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  67.     INI_Int("Kills",PlayerInfo[playerid][pKills]);
  68.     INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  69.     INI_Int("Score",PlayerInfo[playerid][Score]);
  70.     INI_Int("Job",PlayerInfo[playerid][Job]);
  71.     return 1;
  72. }
  73.  
  74. // Forwards:
  75. forward LoadUser_data(playerid,name[],value[]);
  76. forward RandomMessages();
  77.  
  78. /* The Car Spawner Sthings */
  79. #define TOTAL_ITEMS         207
  80. #define SELECTION_ITEMS     21
  81. #define ITEMS_PER_LINE      7
  82. #define HEADER_TEXT "Vehicles"
  83. #define NEXT_TEXT   "Next"
  84. #define PREV_TEXT   "Prev"
  85. #define DIALOG_BASE_X       75.0
  86. #define DIALOG_BASE_Y       130.0
  87. #define DIALOG_WIDTH        550.0
  88. #define DIALOG_HEIGHT       180.0
  89. #define SPRITE_DIM_X        60.0
  90. #define SPRITE_DIM_Y        70.0
  91. new gTotalItems = TOTAL_ITEMS;
  92. new PlayerText:gCurrentPageTextDrawId[MAX_PLAYERS];
  93. new PlayerText:gHeaderTextDrawId[MAX_PLAYERS];
  94. new PlayerText:gBackgroundTextDrawId[MAX_PLAYERS];
  95. new PlayerText:gNextButtonTextDrawId[MAX_PLAYERS];
  96. new PlayerText:gPrevButtonTextDrawId[MAX_PLAYERS];
  97. new PlayerText:gSelectionItems[MAX_PLAYERS][SELECTION_ITEMS];
  98. new gSelectionItemsTag[MAX_PLAYERS][SELECTION_ITEMS];
  99. new gItemList[TOTAL_ITEMS] = {
  100. 400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,
  101. 431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,450,451,452,453,454,455,456,457,458,459,460,461,
  102. 462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,
  103. 493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,
  104. 524,525,526,527,528,529,530,531,532,533,534,535,536,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,
  105. 555,556,557,558,559,560,561,562,563,564,565,566,567,568,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,
  106. 586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611
  107. };
  108. /* The Car Spawner Ends */
  109.  
  110.  
  111.  
  112.  
  113. main()
  114. {
  115.     print("\nMy First Gamemode");
  116.     print(" By finelaq");
  117.     print("\nLoaded...!");
  118. }
  119.  
  120. public OnGameModeInit()
  121. {
  122.     SetGameModeText("finelaq gamemode");
  123.     ShowPlayerMarkers(PLAYER_MARKERS_MODE_GLOBAL);
  124.     ShowNameTags(1);
  125.     SetNameTagDrawDistance(40.0);
  126.     EnableStuntBonusForAll(0);
  127.     DisableInteriorEnterExits();
  128.    
  129.     // The Timer
  130.     SetTimer("RandomMessages", 300000, true);
  131.    
  132.     // Skins:
  133.     AddPlayerClass(281,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  134.     AddPlayerClass(282,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  135.     AddPlayerClass(283,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  136.     AddPlayerClass(284,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  137.     AddPlayerClass(285,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  138.     AddPlayerClass(286,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  139.     AddPlayerClass(287,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  140.     AddPlayerClass(288,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  141.     AddPlayerClass(289,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  142.     AddPlayerClass(265,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  143.     AddPlayerClass(266,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  144.     AddPlayerClass(267,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  145.     AddPlayerClass(268,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  146.     AddPlayerClass(269,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  147.     AddPlayerClass(270,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  148.     AddPlayerClass(1,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  149.     AddPlayerClass(2,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  150.     AddPlayerClass(3,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  151.     AddPlayerClass(4,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  152.     AddPlayerClass(5,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  153.     AddPlayerClass(6,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  154.     AddPlayerClass(8,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  155.     AddPlayerClass(42,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  156.     AddPlayerClass(65,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  157.     AddPlayerClass(74,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  158.     AddPlayerClass(86,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  159.     AddPlayerClass(119,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  160.     AddPlayerClass(149,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  161.     AddPlayerClass(208,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  162.     AddPlayerClass(273,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  163.     AddPlayerClass(289,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  164.     AddPlayerClass(47,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  165.     AddPlayerClass(48,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  166.     AddPlayerClass(49,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  167.     AddPlayerClass(50,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  168.     AddPlayerClass(51,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  169.     AddPlayerClass(52,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  170.     AddPlayerClass(53,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  171.     AddPlayerClass(54,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  172.     AddPlayerClass(55,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  173.     AddPlayerClass(56,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  174.     AddPlayerClass(57,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  175.     AddPlayerClass(58,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  176.     AddPlayerClass(68,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  177.     AddPlayerClass(69,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  178.     AddPlayerClass(70,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  179.     AddPlayerClass(71,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  180.     AddPlayerClass(72,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  181.     AddPlayerClass(73,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  182.     AddPlayerClass(75,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  183.     AddPlayerClass(76,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  184.     AddPlayerClass(78,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  185.     AddPlayerClass(79,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  186.     AddPlayerClass(80,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  187.     AddPlayerClass(81,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  188.     AddPlayerClass(82,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  189.     AddPlayerClass(83,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  190.     AddPlayerClass(84,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  191.     AddPlayerClass(85,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  192.     AddPlayerClass(87,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  193.     AddPlayerClass(88,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  194.     AddPlayerClass(89,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  195.     AddPlayerClass(91,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  196.     AddPlayerClass(92,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  197.     AddPlayerClass(93,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  198.     AddPlayerClass(95,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  199.     AddPlayerClass(96,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  200.     AddPlayerClass(97,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  201.     AddPlayerClass(98,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  202.     AddPlayerClass(99,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
  203.     return 1;
  204. }
  205.  
  206. public RandomMessages()
  207. {
  208.     new rMsg = random(sizeof(RMessages));
  209.     SendClientMessageToAll(COLOR_YELLOW, RMessages[rMsg]);
  210. }
  211.  
  212. public OnGameModeExit()
  213. {
  214.     return 1;
  215. }
  216.  
  217. public OnPlayerRequestClass(playerid, classid)
  218. {
  219.     SetPlayerInterior(playerid,11);
  220.     SetPlayerPos(playerid,508.7362,-87.4335,998.9609);
  221.     SetPlayerFacingAngle(playerid,0.0);
  222.     SetPlayerCameraPos(playerid,508.7362,-83.4335,998.9609);
  223.     SetPlayerCameraLookAt(playerid,508.7362,-87.4335,998.9609);
  224.     return 1;
  225. }
  226.  
  227. public OnPlayerConnect(playerid)
  228. {
  229.     new string[64], pName[MAX_PLAYER_NAME];
  230.     GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
  231.     format(string,sizeof string,"%s has connected server!",pName);
  232.     SendClientMessageToAll(0xFFFFFFAA,string);
  233.  
  234.  
  235.     if(fexist(UserPath(playerid)))
  236.     {
  237.         INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  238.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"SERVER NAME",""COL_WHITE"Welcome back!,\n\nPlease type your account password:","Log-In","Quit");
  239.     }
  240.     else
  241.     {
  242.         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"SERVER NAME",""COL_WHITE"Welcome!,\n\nPlease type your account password, to register:","Register","Quit");
  243.     }
  244.     // Timer
  245.     ScoreFunc[playerid] = SetTimer("ScoreTimer", 60000, 1);
  246.    
  247.    
  248.     // Map Icons
  249.     SetPlayerMapIcon(playerid,49,822.6,-1590.3,13.5,7,0,MAPICON_LOCAL);
  250.     SetPlayerMapIcon(playerid,50,-2570.1,245.4,10.3,7,0,MAPICON_LOCAL);
  251.     SetPlayerMapIcon(playerid,51,2726.6,-2026.4,17.5,7,0,MAPICON_LOCAL);
  252.     SetPlayerMapIcon(playerid,52,2080.3,2119.0,10.8,7,0,MAPICON_LOCAL);
  253.     SetPlayerMapIcon(playerid,53,675.7,-496.6,16.8,7,0,MAPICON_LOCAL);
  254.     SetPlayerMapIcon(playerid,54,-1805.7,943.2,24.8,29,0,MAPICON_LOCAL);
  255.     SetPlayerMapIcon(playerid,55,2750.9,2470.9,11.0,29,0,MAPICON_LOCAL);
  256.     SetPlayerMapIcon(playerid,56,2351.8,2529.0,10.8,29,0,MAPICON_LOCAL);
  257.     SetPlayerMapIcon(playerid,57,2635.5,1847.4,11.0,29,0,MAPICON_LOCAL);
  258.     SetPlayerMapIcon(playerid,58,2083.4,2221.0,11.0,29,0,MAPICON_LOCAL);
  259.     SetPlayerMapIcon(playerid,59,-1719.1,1359.4,8.6,29,0,MAPICON_LOCAL);
  260.     SetPlayerMapIcon(playerid,60,2330.2,75.2,31.0,29,0,MAPICON_LOCAL);
  261.     SetPlayerMapIcon(playerid,61,203.2,-200.4,6.5,29,0,MAPICON_LOCAL);
  262.     SetPlayerMapIcon(playerid,62,812.9,-1616.1,13.6,10,0,MAPICON_LOCAL);
  263.     SetPlayerMapIcon(playerid,63,1199.1,-924.0,43.3,10,0,MAPICON_LOCAL);
  264.     SetPlayerMapIcon(playerid,64,2362.2,2069.9,10.8,10,0,MAPICON_LOCAL);
  265.     SetPlayerMapIcon(playerid,65,2469.5,2033.8,10.8,10,0,MAPICON_LOCAL);
  266.     SetPlayerMapIcon(playerid,66,2172.9,2795.7,10.8,10,0,MAPICON_LOCAL);
  267.     SetPlayerMapIcon(playerid,67,1875.3,2072.0,10.8,10,0,MAPICON_LOCAL);
  268.     SetPlayerMapIcon(playerid,68,1161.5,2072.0,10.8,10,0,MAPICON_LOCAL);
  269.     SetPlayerMapIcon(playerid,69,-2356.0,1009.0,49.0,10,0,MAPICON_LOCAL);
  270.     SetPlayerMapIcon(playerid,70,-1913.3,826.2,36.9,10,0,MAPICON_LOCAL);
  271.     SetPlayerMapIcon(playerid,71,-2335.6,-165.6,39.5,10,0,MAPICON_LOCAL);
  272.     SetPlayerMapIcon(playerid,72,2397.8,-1895.6,13.7,14,0,MAPICON_LOCAL);
  273.     SetPlayerMapIcon(playerid,73,2421.6,-1509.6,24.1,14,0,MAPICON_LOCAL);
  274.     SetPlayerMapIcon(playerid,74,-2671.6,257.4,4.6,14,0,MAPICON_LOCAL);
  275.     SetPlayerMapIcon(playerid,75,2392.4,2046.5,10.8,14,0,MAPICON_LOCAL);
  276.     SetPlayerMapIcon(playerid,76,2844.5,2401.1,11.0,14,0,MAPICON_LOCAL);
  277.     SetPlayerMapIcon(playerid,77,2635.5,1674.3,11.0,14,0,MAPICON_LOCAL);
  278.     SetPlayerMapIcon(playerid,78,2105.7,2228.7,11.0,14,0,MAPICON_LOCAL);
  279.     SetPlayerMapIcon(playerid,79,-2154.0,-2461.2,30.8,14,0,MAPICON_LOCAL);
  280.     SetPlayerMapIcon(playerid,80,-1816.2,620.8,37.5,14,0,MAPICON_LOCAL);
  281.     SetPlayerMapIcon(playerid,81,-1216.0,1831.4,45.3,14,0,MAPICON_LOCAL);
  282.     SetPlayerMapIcon(playerid,82,172.73,1176.76,13.7,14,0,MAPICON_LOCAL);
  283.     SetPlayerMapIcon(playerid,83,932.0,-1353.0,14.0,14,0,MAPICON_LOCAL);
  284.     SetPlayerMapIcon(playerid,84,1971.7,-2036.6,13.5,39,0,MAPICON_LOCAL);
  285.     SetPlayerMapIcon(playerid,85,2071.6,-1779.9,13.5,39,0,MAPICON_LOCAL);
  286.     SetPlayerMapIcon(playerid,86,2094.6,2119.0,10.8,39,0,MAPICON_LOCAL);
  287.     SetPlayerMapIcon(playerid,87,-2490.5,-40.1,39.3,39,0,MAPICON_LOCAL);
  288.     SetPlayerMapIcon(playerid,88,1372.9,-1278.8,12.5,6,0,MAPICON_LOCAL);
  289.     SetPlayerMapIcon(playerid,89,2400.5,-1978.4,13.5,6,0,MAPICON_LOCAL);
  290.     SetPlayerMapIcon(playerid,90,-2626.6,209.4,4.9,6,0,MAPICON_LOCAL);
  291.     SetPlayerMapIcon(playerid,91,2535.9,2083.5,10.8,6,0,MAPICON_LOCAL);
  292.     SetPlayerMapIcon(playerid,92,2156.5,943.2,10.8,6,0,MAPICON_LOCAL);
  293.     SetPlayerMapIcon(playerid,93,779.7,1874.3,4.9,6,0,MAPICON_LOCAL);
  294.     SetPlayerMapIcon(playerid,94,-2092.7,-2463.8,30.6,6,0,MAPICON_LOCAL);
  295.     SetPlayerMapIcon(playerid,95,240.0,-178.2,2.0,6,0,MAPICON_LOCAL);
  296.     SetPlayerMapIcon(playerid,96,-1509.4,2611.8,58.5,6,0,MAPICON_LOCAL);
  297.     SetPlayerMapIcon(playerid,97,-315.67,829.87,13.43,6,0,MAPICON_LOCAL);
  298.     SetPlayerMapIcon(playerid,98,2332.9,63.6,31.0,6,0,MAPICON_LOCAL);
  299.     return 1;
  300. }
  301.  
  302. forward ScoreTimer(playerid);
  303. public ScoreTimer(playerid)
  304. {
  305.     SetPlayerScore(playerid, GetPlayerScore(playerid) +1);
  306.     KillTimer(ScoreFunc[playerid]);
  307.     ScoreFunc[playerid] = SetTimer("ScoreTimer", 60000, 1);
  308.     PlayerInfo[playerid][Score] ++;
  309. }
  310. forward RestartTimer(playerid);
  311. public RestartTimer(playerid)
  312. {
  313.     SendClientMessageToAll(COLOR_GREY,"Server restart has been started now!");
  314.     SendRconCommand("gmx");
  315. }
  316.  
  317. public OnPlayerDisconnect(playerid, reason)
  318. {
  319.     new INI:File = INI_Open(UserPath(playerid));
  320.     INI_SetTag(File,"data");
  321.     INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  322.     INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  323.     INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
  324.     INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  325.     INI_WriteInt(File,"Score",GetPlayerScore(playerid));
  326.     INI_WriteInt(File,"Job",PlayerInfo[playerid][Job]);
  327.     INI_Close(File);
  328.  
  329.     new szString[64],name[MAX_PLAYER_NAME];
  330.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  331.  
  332.     switch(reason)
  333.     {
  334.         case 0: format(szString, sizeof szString, "%s has left the server. (Crashed)", name);
  335.         case 1: format(szString, sizeof szString, "%s has left the server. (Left)", name);
  336.         case 2: format(szString, sizeof szString, "%s has left the server. (Kicked)", name);
  337.     }
  338.  
  339.     SendClientMessageToAll(0xC4C4C4FF, szString);
  340.     return 1;
  341. }
  342.  
  343. public OnPlayerSpawn(playerid)
  344. {
  345.     new RndmSpwn = 0;
  346.  
  347.     RndmSpwn = random(sizeof(gRandomSpawns_LosSantos));
  348.     SetPlayerPos(playerid,
  349.     gRandomSpawns_LosSantos[RndmSpwn][0],
  350.     gRandomSpawns_LosSantos[RndmSpwn][1],
  351.     gRandomSpawns_LosSantos[RndmSpwn][2]);
  352.     SetPlayerFacingAngle(playerid,gRandomSpawns_LosSantos[RndmSpwn][3]);
  353.  
  354.     SetPlayerInterior(playerid,0);
  355.     TogglePlayerClock(playerid,0);
  356.     ResetPlayerMoney(playerid);
  357.     GivePlayerMoney(playerid, 30000);
  358.     return 1;
  359. }
  360.  
  361. public OnPlayerDeath(playerid, killerid, reason)
  362. {
  363.     new cash;
  364.     if(killerid == INVALID_PLAYER_ID) {
  365.         ResetPlayerMoney(playerid);
  366.     } else {
  367.         cash = GetPlayerMoney(playerid);
  368.         if(cash > 0)  {
  369.             GivePlayerMoney(killerid, cash);
  370.             ResetPlayerMoney(playerid);
  371.         }
  372.     }
  373.     PlayerInfo[playerid][pDeaths]++;
  374.     PlayerInfo[killerid][pKills]++;
  375.     return 1;
  376. }
  377.  
  378. public OnVehicleSpawn(vehicleid)
  379. {
  380.     return 1;
  381. }
  382.  
  383. public OnVehicleDeath(vehicleid, killerid)
  384. {
  385.     return 1;
  386. }
  387.  
  388. public OnPlayerText(playerid, text[])
  389. {
  390.     return 1;
  391. }
  392.  
  393. public OnPlayerCommandText(playerid, cmdtext[])
  394. {
  395.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  396.     {
  397.         // Do something here
  398.         return 1;
  399.     }
  400.     return 0;
  401. }
  402.  
  403. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  404. {
  405.     return 1;
  406. }
  407.  
  408. public OnPlayerExitVehicle(playerid, vehicleid)
  409. {
  410.     return 1;
  411. }
  412.  
  413. public OnPlayerStateChange(playerid, newstate, oldstate)
  414. {
  415.     return 1;
  416. }
  417.  
  418. public OnPlayerEnterCheckpoint(playerid)
  419. {
  420.     return 1;
  421. }
  422.  
  423. public OnPlayerLeaveCheckpoint(playerid)
  424. {
  425.     return 1;
  426. }
  427.  
  428. public OnPlayerEnterRaceCheckpoint(playerid)
  429. {
  430.     return 1;
  431. }
  432.  
  433. public OnPlayerLeaveRaceCheckpoint(playerid)
  434. {
  435.     return 1;
  436. }
  437.  
  438. public OnRconCommand(cmd[])
  439. {
  440.     return 1;
  441. }
  442.  
  443. public OnPlayerRequestSpawn(playerid)
  444. {
  445.     return 1;
  446. }
  447.  
  448. public OnObjectMoved(objectid)
  449. {
  450.     return 1;
  451. }
  452.  
  453. public OnPlayerObjectMoved(playerid, objectid)
  454. {
  455.     return 1;
  456. }
  457.  
  458. public OnPlayerPickUpPickup(playerid, pickupid)
  459. {
  460.     return 1;
  461. }
  462.  
  463. public OnVehicleMod(playerid, vehicleid, componentid)
  464. {
  465.     return 1;
  466. }
  467.  
  468. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  469. {
  470.     return 1;
  471. }
  472.  
  473. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  474. {
  475.     return 1;
  476. }
  477.  
  478. public OnPlayerSelectedMenuRow(playerid, row)
  479. {
  480.     return 1;
  481. }
  482.  
  483. public OnPlayerExitedMenu(playerid)
  484. {
  485.     return 1;
  486. }
  487.  
  488. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  489. {
  490.     return 1;
  491. }
  492.  
  493. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  494. {
  495.     return 1;
  496. }
  497.  
  498. public OnRconLoginAttempt(ip[], password[], success)
  499. {
  500.     return 1;
  501. }
  502.  
  503. public OnPlayerUpdate(playerid)
  504. {
  505.     // Interior no weapons
  506.     if(GetPlayerInterior(playerid) != 0 && GetPlayerWeapon(playerid) != 0) {
  507.         SetPlayerArmedWeapon(playerid,0); // First
  508.         return 0;
  509.     }
  510.     return 1;
  511. }
  512.  
  513. public OnPlayerStreamIn(playerid, forplayerid)
  514. {
  515.     return 1;
  516. }
  517.  
  518. public OnPlayerStreamOut(playerid, forplayerid)
  519. {
  520.     return 1;
  521. }
  522.  
  523. public OnVehicleStreamIn(vehicleid, forplayerid)
  524. {
  525.     return 1;
  526. }
  527.  
  528. public OnVehicleStreamOut(vehicleid, forplayerid)
  529. {
  530.     return 1;
  531. }
  532.  
  533. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  534. {
  535.     if(dialogid == DIALOG_GUNSHOP)
  536.     {
  537.         if(response)
  538.         {
  539.             if(listitem == 0)
  540.             {
  541.                 if(GetPlayerMoney(playerid) <25000) return SendClientMessage(playerid,COLOR_RED, "You don't have the money!");
  542.                 GivePlayerWeapon(playerid, 31, 5000);
  543.                 SendClientMessage(playerid,COLOR_GREEN,"Thank you buying M4!");
  544.                 GivePlayerMoney(playerid, -25000);
  545.             }
  546.             if(listitem == 1)
  547.             {
  548.                 if(GetPlayerMoney(playerid) <35000) return SendClientMessage(playerid,COLOR_RED, "You don't have the money!");
  549.                 GivePlayerWeapon(playerid, 30, 5000);
  550.                 SendClientMessage(playerid,COLOR_GREEN,"Thank you buying AK-47!");
  551.                 GivePlayerMoney(playerid, -35000);
  552.             }
  553.             if(listitem == 2)
  554.             {
  555.                 if(GetPlayerMoney(playerid) <70000000) return SendClientMessage(playerid,COLOR_RED, "You don't have the money!");
  556.                 GivePlayerWeapon(playerid, 38, 999999999);
  557.                 SendClientMessage(playerid,COLOR_GREEN,"Thank you buying MiniGun!");
  558.                 GivePlayerMoney(playerid, -70000000);
  559.             }
  560.             if(listitem == 3)
  561.             {
  562.                 if(GetPlayerMoney(playerid) <500) return SendClientMessage(playerid,COLOR_RED, "You don't have the money!");
  563.                 GivePlayerWeapon(playerid, 4, 1);
  564.                 SendClientMessage(playerid,COLOR_GREEN,"Thank you buying Knife!");
  565.                 GivePlayerMoney(playerid, -500);
  566.             }
  567.             if(listitem == 4)
  568.             {
  569.                 if(GetPlayerMoney(playerid) <55000) return SendClientMessage(playerid,COLOR_RED, "You don't have the money!");
  570.                 GivePlayerWeapon(playerid, 24, 5000);
  571.                 SendClientMessage(playerid,COLOR_GREEN,"Thank you buying Deagle!");
  572.                 GivePlayerMoney(playerid, -55000);
  573.             }
  574.             if(listitem == 5)
  575.             {
  576.                 if(GetPlayerMoney(playerid) <20000) return SendClientMessage(playerid,COLOR_RED, "You don't have the money!");
  577.                 GivePlayerWeapon(playerid, 29, 5000);
  578.                 SendClientMessage(playerid,COLOR_GREEN,"Thank you buying MP5!");
  579.                 GivePlayerMoney(playerid, -20000);
  580.             }
  581.         }
  582.     }
  583.     switch( dialogid )
  584.     {
  585.         case DIALOG_REGISTER:
  586.         {
  587.             if (!response) return Kick(playerid);
  588.             if(response)
  589.             {
  590.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"SERVER NAME",""COL_RED"Heres no password!\n"COL_WHITE"Try aigan! Type password to register account:","Register","Quit");               new INI:File = INI_Open(UserPath(playerid));
  591.                 INI_SetTag(File,"data");
  592.                 INI_WriteInt(File,"Password",udb_hash(inputtext));
  593.                 INI_WriteInt(File,"Cash",0);
  594.                 INI_WriteInt(File,"Admin",0);
  595.                 INI_WriteInt(File,"Kills",0);
  596.                 INI_WriteInt(File,"Deaths",0);
  597.                 INI_WriteInt(File,"Score",0);
  598.                 INI_WriteInt(File,"Job",0);
  599.                 INI_Close(File);
  600.  
  601.                 SendClientMessage(playerid,COLOR_GREEN,"You are succesuly registred!");
  602.             }
  603.         }
  604.  
  605.         case DIALOG_LOGIN:
  606.         {
  607.             if ( !response ) return Kick ( playerid );
  608.             if( response )
  609.             {
  610.                 if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  611.                 {
  612.                     INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  613.                     GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  614.                     SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
  615.                     SendClientMessage(playerid,COLOR_GREEN,"You are succesuly logged in!");
  616.                 }
  617.                 else
  618.                 {
  619.                     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"SERVER NAME",""COL_RED"This is incorrect password.\n"COL_WHITE"Try aigan! Type your password:","log-In","Quit");
  620.                 }
  621.                 return 1;
  622.             }
  623.         }
  624.     }
  625.     return 1;
  626. }
  627.  
  628. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  629. {
  630.     if(GetPVarInt(playerid, "vspawner_active") == 0) return 0;
  631.  
  632.     // Handle: They cancelled (with ESC)
  633.     if(clickedid == Text:INVALID_TEXT_DRAW) {
  634.         DestroySelectionMenu(playerid);
  635.         SetPVarInt(playerid, "vspawner_active", 0);
  636.         PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  637.         return 1;
  638.     }
  639.  
  640.     return 0;
  641. }
  642.  
  643. //------------------------------------------------
  644.  
  645. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  646. {
  647.     if(GetPVarInt(playerid, "vspawner_active") == 0) return 0;
  648.  
  649.     new curpage = GetPVarInt(playerid, "vspawner_page");
  650.  
  651.     // Handle: next button
  652.     if(playertextid == gNextButtonTextDrawId[playerid]) {
  653.         if(curpage < (GetNumberOfPages() - 1)) {
  654.             SetPVarInt(playerid, "vspawner_page", curpage + 1);
  655.             ShowPlayerModelPreviews(playerid);
  656.             UpdatePageTextDraw(playerid);
  657.             PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  658.         } else {
  659.             PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  660.         }
  661.         return 1;
  662.     }
  663.  
  664.     // Handle: previous button
  665.     if(playertextid == gPrevButtonTextDrawId[playerid]) {
  666.         if(curpage > 0) {
  667.             SetPVarInt(playerid, "vspawner_page", curpage - 1);
  668.             ShowPlayerModelPreviews(playerid);
  669.             UpdatePageTextDraw(playerid);
  670.             PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
  671.         } else {
  672.             PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  673.         }
  674.         return 1;
  675.     }
  676.  
  677.     // Search in the array of textdraws used for the items
  678.     new x=0;
  679.     while(x != SELECTION_ITEMS) {
  680.         if(playertextid == gSelectionItems[playerid][x]) {
  681.             HandlePlayerItemSelection(playerid, x);
  682.             PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  683.             DestroySelectionMenu(playerid);
  684.             CancelSelectTextDraw(playerid);
  685.             SetPVarInt(playerid, "vspawner_active", 0);
  686.             return 1;
  687.         }
  688.         x++;
  689.     }
  690.  
  691.     return 0;
  692. }
  693.  
  694. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  695. {
  696.     return 1;
  697. }
  698. CMD:kick(playerid, params[])
  699. {
  700.     new id, reason[128];
  701.     if(PlayerInfo[playerid][pAdmin] <= 1) return SendClientMessage(playerid, COLOR_GREY, "You don't have the rights!");
  702.     else if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_GREY, "USE: /kick [Player ID] [Reason]");
  703.     else if (id==INVALID_PLAYER_ID)SendClientMessage(playerid,COLOR_GREY,"You can't kick bots!");
  704.     else {
  705.         new Name[MAX_PLAYER_NAME], KickMessage[128];
  706.         new Name2[MAX_PLAYER_NAME];
  707.         GetPlayerName(playerid, Name, sizeof(Name));
  708.         GetPlayerName(id, Name2, sizeof(Name2));
  709.         format(KickMessage, sizeof(KickMessage), "AdmCmd: Admin %s(%d) has kicked %s(%d) out of the server. Reason: %s", Name, playerid, Name2, id);
  710.         SendClientMessageToAll(COLOR_RED, KickMessage);
  711.         Kick(id);
  712.     }
  713.     return 1;
  714. }
  715.  
  716. CMD:ban(playerid, params[])
  717. {
  718.     new id, reason[128];
  719.     if(PlayerInfo[playerid][pAdmin] <= 1) return SendClientMessage(playerid, COLOR_GREY, "You don't have the rights!");
  720.     else if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_GREY, "USE: /ban [Player ID] [Reason]");
  721.     else if (id==INVALID_PLAYER_ID)SendClientMessage(playerid,COLOR_GREY,"You can't ban bots");
  722.     else {
  723.         new Name[MAX_PLAYER_NAME], KickMessage[128];
  724.         new Name2[MAX_PLAYER_NAME];
  725.         GetPlayerName(playerid, Name, sizeof(Name));
  726.         GetPlayerName(id, Name2, sizeof(Name2));
  727.         format(KickMessage, sizeof(KickMessage), "AdmCmd: Admin %s(%d) blocked the %s(%d) account. Reason: %s", Name, playerid, Name2, id);
  728.         SendClientMessageToAll(COLOR_RED, KickMessage);
  729.         Ban(id);
  730.     }
  731.     return 1;
  732. }
  733. CMD:veh(playerid, params[])
  734. {
  735.     if(PlayerInfo[playerid][pAdmin] <= 1) return SendClientMessage(playerid, COLOR_GREY, "You don't have the rights!");
  736.     DestroySelectionMenu(playerid);
  737.     SetPVarInt(playerid, "vspawner_active", 1);
  738.     CreateSelectionMenu(playerid);
  739.     SelectTextDraw(playerid, 0xACCBF1FF);
  740.     return 1;
  741. }
  742.  
  743. COMMAND:aguns(playerid, params[])
  744. {
  745.     if(PlayerInfo[playerid][pAdmin] <= 2) return SendClientMessage(playerid, COLOR_GREY, "You don't have the rights!");
  746.     GivePlayerWeapon(playerid, 4, 2);
  747.     GivePlayerWeapon(playerid, 24, 50000);
  748.     GivePlayerWeapon(playerid, 26, 50000);
  749.     GivePlayerWeapon(playerid, 29, 50000);
  750.     GivePlayerWeapon(playerid, 31, 50000);
  751.     GivePlayerWeapon(playerid, 36, 50000);
  752.     return 1;
  753. }
  754. COMMAND:health(playerid, params[])
  755. {
  756.     if(PlayerInfo[playerid][pAdmin] <= 2) return SendClientMessage(playerid, COLOR_GREY, "You don't have the rights!");
  757.     SetPlayerHealth(playerid,100);
  758.     return 1;
  759. }
  760. COMMAND:restart(playerid, params[])
  761. {
  762.     if(PlayerInfo[playerid][pAdmin] <= 5) return SendClientMessage(playerid, COLOR_GREY, "You don't have the rights!");
  763.     RestartFunc[playerid] = SetTimer("RestartTimer", 5000, 1);
  764.  SendClientMessage(playerid,COLOR_YELLOW,"You has starded the server restart!");
  765.     SendClientMessageToAll(COLOR_YELLOW,"Server restart has been started in 5 seconds!");
  766.     return 1;
  767. }
  768. COMMAND:kill(playerid, params[])
  769. {
  770.     SetPlayerHealth(playerid,-9999);
  771.     return 1;
  772. }
  773. COMMAND:help(playerid, params[])
  774. {
  775.     ShowPlayerDialog(playerid,DIALOG_HELP,DIALOG_STYLE_MSGBOX,"HELP","{F7EA31}Commands: /help /kill /gunshop /pay","Ok","");
  776.     return 1;
  777. }
  778. COMMAND:ahelp(playerid, params[])
  779. {
  780.     if(PlayerInfo[playerid][pAdmin] <= 1) return SendClientMessage(playerid, COLOR_GREY, "You don't have the rights!");
  781.     ShowPlayerDialog(playerid,DIALOG_AHELP,DIALOG_STYLE_MSGBOX,"ADMIN HELP","{F7EA31}Commands: /aguns /kick /ban /god /veh /givecash","Ok","");
  782.     return 1;
  783. }
  784. COMMAND:pay(playerid, params[])
  785. {
  786.     new player, amount,name1[24], name2[24], string[128];
  787.     if(!sscanf(params, "ui",player,amount))
  788.     {
  789.         if(playerid != player)
  790.         {
  791.             if(GetPlayerMoney(playerid) >= amount)
  792.             {
  793.                 GetPlayerName(playerid, name1, 24);
  794.                 GetPlayerName(player, name2, 24);
  795.                 format(string, sizeof(string), "You gaved $%d to %s.",amount,name2);
  796.                 SendClientMessage(playerid, 0xFFFF00FF, string);
  797.                 format(string, sizeof(string), "%s gave you $%d!", name1, amount);
  798.                 SendClientMessage(player, 0xFFFF00FF, string);
  799.                 GivePlayerMoney(playerid, -amount);
  800.                 GivePlayerMoney(player, amount);
  801.             }
  802.             else return SendClientMessage(playerid, 0xFF0000FF,"You don't have that much.");
  803.         }
  804.         else return SendClientMessage(playerid, 0xFF0000FF,"You can't pay to yourself.");
  805.     }
  806.     else return SendClientMessage(playerid, 0xFFFFFFFF,"Usage: /pay [Player ID][Amount]");
  807.     return 1;
  808. }
  809. COMMAND:givecash(playerid, params[])
  810. {
  811.     new player, amount,name1[24], name2[24], string[128];
  812.     if(!sscanf(params, "ui",player,amount))
  813.     {
  814.         GetPlayerName(playerid, name1, 24);
  815.         GetPlayerName(player, name2, 24);
  816.         format(string, sizeof(string), "You gaved $%d to %s.",amount,name2);
  817.         SendClientMessage(playerid, 0xFFFF00FF, string);
  818.         format(string, sizeof(string), "Admin %s gave you $%d!", name1, amount);
  819.         SendClientMessage(player, 0xFFFF00FF, string);
  820.         GivePlayerMoney(player, amount);
  821.     }
  822.     else return SendClientMessage(playerid, 0xFFFFFFFF,"Usage: /givecash [Player ID][Amount]");
  823.     return 1;
  824. }
  825. COMMAND:armour(playerid, params[])
  826. {
  827.     if(PlayerInfo[playerid][pAdmin] <= 2) return SendClientMessage(playerid, COLOR_GREY, "You don't have the rights!");
  828.     SetPlayerArmour(playerid,100);
  829.     return 1;
  830. }
  831. COMMAND:gunshop(playerid, params[])
  832. {
  833.     ShowPlayerDialog(playerid, DIALOG_GUNSHOP, DIALOG_STYLE_LIST,"GUNSHOP:","M4 25,000€\nAK-47 35,000€\nMiniGun 7,000,000,000,0€\nKnife 500€\nDeagle 55,000€\nMP5 20,000€","Buy","Quit");
  834.     return 1;
  835. }
  836. COMMAND:god(playerid, params[])
  837. {
  838.     if(PlayerInfo[playerid][pAdmin] <= 2) return SendClientMessage(playerid, COLOR_GREY, "You don't have the rights!");
  839.     if(GodMode[playerid] == 0)
  840.     {
  841.        GodMode[playerid] = 1;
  842.        SetPlayerHealth(playerid,999999);
  843.        SendClientMessage(playerid,COLOR_GREEN,"GodMode ON!");
  844.     }
  845.     else
  846.     {
  847.        GodMode[playerid] = 0;
  848.        SetPlayerHealth(playerid,100);
  849.        SendClientMessage(playerid,COLOR_RED,"GodMode OFF!");
  850.     }
  851.     return 1;
  852. }
  853.  
  854. // Car Spawner Things
  855. GetNumberOfPages()
  856. {
  857.     if((gTotalItems >= SELECTION_ITEMS) && (gTotalItems % SELECTION_ITEMS) == 0)
  858.     {
  859.         return (gTotalItems / SELECTION_ITEMS);
  860.     }
  861.     else return (gTotalItems / SELECTION_ITEMS) + 1;
  862. }
  863.  
  864. //------------------------------------------------
  865.  
  866. PlayerText:CreateCurrentPageTextDraw(playerid, Float:Xpos, Float:Ypos)
  867. {
  868.     new PlayerText:txtInit;
  869.     txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, "0/0");
  870.     PlayerTextDrawUseBox(playerid, txtInit, 0);
  871.     PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
  872.     PlayerTextDrawFont(playerid, txtInit, 1);
  873.     PlayerTextDrawSetShadow(playerid, txtInit, 0);
  874.     PlayerTextDrawSetOutline(playerid, txtInit, 1);
  875.     PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
  876.     PlayerTextDrawShow(playerid, txtInit);
  877.     return txtInit;
  878. }
  879.  
  880. //------------------------------------------------
  881. // Creates a button textdraw and returns the textdraw ID.
  882.  
  883. PlayerText:CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, button_text[])
  884. {
  885.     new PlayerText:txtInit;
  886.     txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, button_text);
  887.     PlayerTextDrawUseBox(playerid, txtInit, 1);
  888.     PlayerTextDrawBoxColor(playerid, txtInit, 0x000000FF);
  889.     PlayerTextDrawBackgroundColor(playerid, txtInit, 0x000000FF);
  890.     PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
  891.     PlayerTextDrawFont(playerid, txtInit, 1);
  892.     PlayerTextDrawSetShadow(playerid, txtInit, 0); // no shadow
  893.     PlayerTextDrawSetOutline(playerid, txtInit, 0);
  894.     PlayerTextDrawColor(playerid, txtInit, 0x4A5A6BFF);
  895.     PlayerTextDrawSetSelectable(playerid, txtInit, 1);
  896.     PlayerTextDrawAlignment(playerid, txtInit, 2);
  897.     PlayerTextDrawTextSize(playerid, txtInit, Height, Width); // The width and height are reversed for centering.. something the game does <g>
  898.     PlayerTextDrawShow(playerid, txtInit);
  899.     return txtInit;
  900. }
  901.  
  902. //------------------------------------------------
  903.  
  904. PlayerText:CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, header_text[])
  905. {
  906.     new PlayerText:txtInit;
  907.     txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, header_text);
  908.     PlayerTextDrawUseBox(playerid, txtInit, 0);
  909.     PlayerTextDrawLetterSize(playerid, txtInit, 1.25, 3.0);
  910.     PlayerTextDrawFont(playerid, txtInit, 0);
  911.     PlayerTextDrawSetShadow(playerid, txtInit, 0);
  912.     PlayerTextDrawSetOutline(playerid, txtInit, 1);
  913.     PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
  914.     PlayerTextDrawShow(playerid, txtInit);
  915.     return txtInit;
  916. }
  917.  
  918. //------------------------------------------------
  919.  
  920. PlayerText:CreatePlayerBackgroundTextDraw(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height)
  921. {
  922.     new PlayerText:txtBackground = CreatePlayerTextDraw(playerid, Xpos, Ypos,
  923.     "                                            ~n~"); // enough space for everyone
  924.     PlayerTextDrawUseBox(playerid, txtBackground, 1);
  925.     PlayerTextDrawBoxColor(playerid, txtBackground, 0x00000099);
  926.     PlayerTextDrawLetterSize(playerid, txtBackground, 5.0, 5.0);
  927.     PlayerTextDrawFont(playerid, txtBackground, 0);
  928.     PlayerTextDrawSetShadow(playerid, txtBackground, 0);
  929.     PlayerTextDrawSetOutline(playerid, txtBackground, 0);
  930.     PlayerTextDrawColor(playerid, txtBackground,0x000000FF);
  931.     PlayerTextDrawTextSize(playerid, txtBackground, Width, Height);
  932.     PlayerTextDrawBackgroundColor(playerid, txtBackground, 0x00000099);
  933.     PlayerTextDrawShow(playerid, txtBackground);
  934.     return txtBackground;
  935. }
  936.  
  937. //------------------------------------------------
  938. // Creates a model preview sprite
  939.  
  940. PlayerText:CreateModelPreviewTextDraw(playerid, modelindex, Float:Xpos, Float:Ypos, Float:width, Float:height)
  941. {
  942.     new PlayerText:txtPlayerSprite = CreatePlayerTextDraw(playerid, Xpos, Ypos, ""); // it has to be set with SetText later
  943.     PlayerTextDrawFont(playerid, txtPlayerSprite, TEXT_DRAW_FONT_MODEL_PREVIEW);
  944.     PlayerTextDrawColor(playerid, txtPlayerSprite, 0xFFFFFFFF);
  945.     PlayerTextDrawBackgroundColor(playerid, txtPlayerSprite, 0x000000EE);
  946.     PlayerTextDrawTextSize(playerid, txtPlayerSprite, width, height); // Text size is the Width:Height
  947.     PlayerTextDrawSetPreviewModel(playerid, txtPlayerSprite, modelindex);
  948.     PlayerTextDrawSetPreviewRot(playerid,txtPlayerSprite, -16.0, 0.0, -55.0);
  949.     PlayerTextDrawSetSelectable(playerid, txtPlayerSprite, 1);
  950.     PlayerTextDrawShow(playerid,txtPlayerSprite);
  951.     return txtPlayerSprite;
  952. }
  953.  
  954. //------------------------------------------------
  955.  
  956. DestroyPlayerModelPreviews(playerid)
  957. {
  958.     new x=0;
  959.     while(x != SELECTION_ITEMS) {
  960.         if(gSelectionItems[playerid][x] != PlayerText:INVALID_TEXT_DRAW) {
  961.             PlayerTextDrawDestroy(playerid, gSelectionItems[playerid][x]);
  962.             gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
  963.         }
  964.         x++;
  965.     }
  966. }
  967.  
  968. //------------------------------------------------
  969.  
  970. ShowPlayerModelPreviews(playerid)
  971. {
  972.     new x=0;
  973.     new Float:BaseX = DIALOG_BASE_X;
  974.     new Float:BaseY = DIALOG_BASE_Y - (SPRITE_DIM_Y * 0.33); // down a bit
  975.     new linetracker = 0;
  976.  
  977.     new itemat = GetPVarInt(playerid, "vspawner_page") * SELECTION_ITEMS;
  978.  
  979.     // Destroy any previous ones created
  980.     DestroyPlayerModelPreviews(playerid);
  981.  
  982.     while(x != SELECTION_ITEMS && itemat < gTotalItems) {
  983.         if(linetracker == 0) {
  984.             BaseX = DIALOG_BASE_X + 25.0; // in a bit from the box
  985.             BaseY += SPRITE_DIM_Y + 1.0; // move on the Y for the next line
  986.         }
  987.         gSelectionItems[playerid][x] = CreateModelPreviewTextDraw(playerid, gItemList[itemat], BaseX, BaseY, SPRITE_DIM_X, SPRITE_DIM_Y);
  988.         gSelectionItemsTag[playerid][x] = gItemList[itemat];
  989.         BaseX += SPRITE_DIM_X + 1.0; // move on the X for the next sprite
  990.         linetracker++;
  991.         if(linetracker == ITEMS_PER_LINE) linetracker = 0;
  992.         itemat++;
  993.         x++;
  994.     }
  995. }
  996.  
  997. //------------------------------------------------
  998.  
  999. UpdatePageTextDraw(playerid)
  1000. {
  1001.     new PageText[64+1];
  1002.     format(PageText, 64, "%d/%d", GetPVarInt(playerid,"vspawner_page") + 1, GetNumberOfPages());
  1003.     PlayerTextDrawSetString(playerid, gCurrentPageTextDrawId[playerid], PageText);
  1004. }
  1005.  
  1006. //------------------------------------------------
  1007.  
  1008. CreateSelectionMenu(playerid)
  1009. {
  1010.     gBackgroundTextDrawId[playerid] = CreatePlayerBackgroundTextDraw(playerid, DIALOG_BASE_X, DIALOG_BASE_Y + 20.0, DIALOG_WIDTH, DIALOG_HEIGHT);
  1011.     gHeaderTextDrawId[playerid] = CreatePlayerHeaderTextDraw(playerid, DIALOG_BASE_X, DIALOG_BASE_Y, HEADER_TEXT);
  1012.     gCurrentPageTextDrawId[playerid] = CreateCurrentPageTextDraw(playerid, DIALOG_WIDTH - 30.0, DIALOG_BASE_Y + 15.0);
  1013.     gNextButtonTextDrawId[playerid] = CreatePlayerDialogButton(playerid, DIALOG_WIDTH - 30.0, DIALOG_BASE_Y+DIALOG_HEIGHT+100.0, 50.0, 16.0, NEXT_TEXT);
  1014.     gPrevButtonTextDrawId[playerid] = CreatePlayerDialogButton(playerid, DIALOG_WIDTH - 90.0, DIALOG_BASE_Y+DIALOG_HEIGHT+100.0, 50.0, 16.0, PREV_TEXT);
  1015.  
  1016.     ShowPlayerModelPreviews(playerid);
  1017.     UpdatePageTextDraw(playerid);
  1018. }
  1019.  
  1020. //------------------------------------------------
  1021.  
  1022. DestroySelectionMenu(playerid)
  1023. {
  1024.     DestroyPlayerModelPreviews(playerid);
  1025.  
  1026.     PlayerTextDrawDestroy(playerid, gHeaderTextDrawId[playerid]);
  1027.     PlayerTextDrawDestroy(playerid, gBackgroundTextDrawId[playerid]);
  1028.     PlayerTextDrawDestroy(playerid, gCurrentPageTextDrawId[playerid]);
  1029.     PlayerTextDrawDestroy(playerid, gNextButtonTextDrawId[playerid]);
  1030.     PlayerTextDrawDestroy(playerid, gPrevButtonTextDrawId[playerid]);
  1031.  
  1032.     gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  1033.     gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  1034.     gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  1035.     gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  1036.     gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
  1037. }
  1038.  
  1039. //------------------------------------------------
  1040.  
  1041. SpawnVehicle_InfrontOfPlayer(playerid, vehiclemodel, color1, color2)
  1042. {
  1043.     new Float:x,Float:y,Float:z;
  1044.     new Float:facing;
  1045.     new Float:distance;
  1046.  
  1047.     GetPlayerPos(playerid, x, y, z);
  1048.     GetPlayerFacingAngle(playerid, facing);
  1049.  
  1050.     new Float:size_x,Float:size_y,Float:size_z;
  1051.     GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
  1052.  
  1053.     distance = size_x + 0.5;
  1054.  
  1055.     x += (distance * floatsin(-facing, degrees));
  1056.     y += (distance * floatcos(-facing, degrees));
  1057.  
  1058.     facing += 90.0;
  1059.     if(facing > 360.0) facing -= 360.0;
  1060.  
  1061.     return CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
  1062. }
  1063.  
  1064. //------------------------------------------------
  1065.  
  1066. HandlePlayerItemSelection(playerid, selecteditem)
  1067. {
  1068.     // In this case we're spawning a vehicle for them
  1069.     SpawnVehicle_InfrontOfPlayer(playerid, gSelectionItemsTag[playerid][selecteditem], -1, -1);
  1070. }
  1071.  
  1072. //------------------------------------------------
  1073. /* Car Spawner Things Ends */
  1074.  
  1075.  
  1076. // Stocks:
  1077. stock UserPath(playerid)
  1078. {
  1079.     new string[128],playername[MAX_PLAYER_NAME];
  1080.     GetPlayerName(playerid,playername,sizeof(playername));
  1081.     format(string,sizeof(string),FOLDER,playername);
  1082.     return string;
  1083. }
  1084.  
  1085. stock udb_hash(buf[]) {
  1086.     new length=strlen(buf);
  1087.     new s1 = 1;
  1088.     new s2 = 0;
  1089.     new n;
  1090.     for (n=0; n<length; n++)
  1091.     {
  1092.        s1 = (s1 + buf[n]) % 65521;
  1093.        s2 = (s2 + s1)     % 65521;
  1094.     }
  1095.     return (s2 << 16) + s1;
  1096. }
Advertisement
Add Comment
Please, Sign In to add comment