Advertisement
Guest User

Unique Halloween System By Dennis12

a guest
Nov 11th, 2018
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 30.35 KB | None | 0 0
  1. #if defined ADD_TO_GAMEMODDE
  2.    
  3.     ["BEHIND DEFINES"]
  4.     #define Function::%0(%1) forward %0(%1); public %0(%1)
  5.  
  6. #endif
  7.  
  8. #if defined ADD_TO_DATABASE
  9.     ["PHPMYADMIN"]
  10.  
  11.     ACESTE LUCRURI NECESITA ADAUGARE IN DATABASE-UL VOSTRU:
  12.  
  13.     ALTER TABLE `your_players_table` ADD `user_hcandy` tinyint(3) NOT NULL DEFAULT '0';
  14.     ALTER TABLE `your_players_table` ADD `user_hpoints` tinyint(3) NOT NULL DEFAULT '0';
  15.     ALTER TABLE `your_players_table` ADD `user_htricked` tinyint(3) NOT NULL DEFAULT '0';
  16.     ALTER TABLE `your_players_table` ADD `user_htaken` varchar(128) NOT NULL DEFAULT '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0';
  17.     ALTER TABLE `your_players_table` ADD `user_items` varchar(64) NOT NULL DEFAULT '0 0 0';
  18.     ALTER TABLE `your_players_table` ADD `user_togitems` varchar(64) NOT NULL DEFAULT '0 0 0';
  19. #endif
  20.  
  21. #include "YSI\y_hooks"
  22. DEFINE_HOOK_REPLACEMENT(OnPlayer, OP_);
  23.  
  24. #define MAX_TRICK_POS 22
  25. #define START_HALLOWEEN_QUEST 1931.9956,147.5708,37.2813
  26.  
  27. #define DIALOG_H_SHOP 5421
  28. #define DIALOG_H_ACCS 5422
  29. #define DIALOG_H_TOG  5423
  30.  
  31. new
  32.     PlayerText: H_TD[MAX_PLAYERS][12],
  33.     trickArea[MAX_PLAYERS][MAX_TRICK_POS],
  34.     trickIcon[MAX_PLAYERS][MAX_TRICK_POS],
  35.     PlayerText3D: trickLabel[MAX_PLAYERS][MAX_TRICK_POS],
  36.     trickPickup[MAX_PLAYERS][MAX_TRICK_POS],
  37.     bool: takenHouse[MAX_PLAYERS][MAX_TRICK_POS],
  38.  
  39.     h_Candy[MAX_PLAYERS],
  40.     h_Points[MAX_PLAYERS],
  41.     h_Tricked[MAX_PLAYERS],
  42.  
  43.     bool: halloweenStarted[MAX_PLAYERS],
  44.     bool: followCP[MAX_PLAYERS],
  45.  
  46.     bool: h_objStatus[MAX_PLAYERS][3],
  47.     bool: h_objItems[MAX_PLAYERS][3];
  48.  
  49. new Float: halloween_Positions[MAX_TRICK_POS][3] = {
  50.     {2200.2559,-37.3183,28.1535},
  51.     {2197.6106,-60.6269,28.1535},
  52.     {2203.2383,-89.2961,28.1535},
  53.     {2245.4875,-122.2916,28.1535},
  54.     {2272.3247,-119.1340,28.1535},
  55.     {2293.7932,-124.9638,28.1535},
  56.     {2313.7847,-124.9644,28.1536},
  57.     {2322.2407,-124.9646,28.1536},
  58.     {2367.3530,-49.1274,28.1535},
  59.     {2392.3962,-54.9645,28.1536},
  60.     {2415.4785,-52.2845,28.1535},
  61.     {2392.3962,-54.9645,28.1536},
  62.     {2415.4785,-52.2845,28.1535},
  63.     {2438.8215,-54.9646,28.1535},
  64.     {2484.4668,-28.4039,28.4416},
  65.     {2513.3257,-28.4039,28.4416},
  66.     {2551.2224,-5.5376,27.6756},
  67.     {2549.2295,25.1517,27.6756},
  68.     {2551.2224,57.1389,27.6756},
  69.     {2518.4509,128.9880,27.6756},
  70.     {2458.9387,128.9881,27.6756},
  71.     {2323.8462,116.1741,28.4416}
  72. };
  73.  
  74. new grandmaSkins[] = {10, 39, 54, 58, 77, 130, 133, 161, 182, 197, 199, 218, 232};
  75.  
  76. hook OnGameModeInit()
  77. {
  78.     AddStaticPickup(19320, 23, START_HALLOWEEN_QUEST, 0);
  79.     Create3DTextLabel("{ED872D}Halloween Quest\nType '/starthalloween' to start.", -1, START_HALLOWEEN_QUEST, 20.0, 0, 0);
  80.     ShowPlayerMarkers(0);
  81.     return true;
  82. }
  83.  
  84. hook OP_EnterDynamicArea(playerid, areaid)
  85. {
  86.     new ho = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
  87.     if(-1 <= ho <= MAX_TRICK_POS)
  88.     {
  89.         if(IsPlayerInRangeOfPoint(playerid, 1.5, halloween_Positions[ho][0], halloween_Positions[ho][1], halloween_Positions[ho][2]))
  90.             SetPVarInt(playerid, "hHouse", ho);
  91.     }
  92.     return true;
  93. }
  94. hook OP_LeaveDynamicArea(playerid, areaid)
  95. {
  96.     new ho = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
  97.     if(-1 <= ho <= MAX_TRICK_POS)
  98.     {
  99.         if(!IsPlayerInRangeOfPoint(playerid, 1.5, halloween_Positions[ho][0], halloween_Positions[ho][1], halloween_Positions[ho][2]))
  100.             DeletePVar(playerid, "hHouse");
  101.     }
  102.     return true;
  103. }
  104.  
  105. hook OnPlayerConnect(playerid)
  106. {
  107.     halloweenStarted[playerid]      =
  108.     followCP[playerid]              =
  109.     h_objStatus[playerid][0]        =
  110.     h_objStatus[playerid][1]        =
  111.     h_objStatus[playerid][2]        =
  112.     h_objItems[playerid][0]         =  
  113.     h_objItems[playerid][1]         =
  114.     h_objItems[playerid][2]         =   false;
  115.  
  116.    
  117.     H_TD[playerid][0] = CreatePlayerTextDraw(playerid, 1.111127, 159.635574, "box");
  118.     PlayerTextDrawLetterSize(playerid, H_TD[playerid][0], 0.000000, 11.066666);
  119.     PlayerTextDrawTextSize(playerid, H_TD[playerid][0], 138.000000, 0.000000);
  120.     PlayerTextDrawAlignment(playerid, H_TD[playerid][0], 1);
  121.     PlayerTextDrawColor(playerid, H_TD[playerid][0], -1);
  122.     PlayerTextDrawUseBox(playerid, H_TD[playerid][0], 1);
  123.     PlayerTextDrawBoxColor(playerid, H_TD[playerid][0], 102);
  124.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][0], 0);
  125.     PlayerTextDrawSetOutline(playerid, H_TD[playerid][0], 0);
  126.     PlayerTextDrawBackgroundColor(playerid, H_TD[playerid][0], 255);
  127.     PlayerTextDrawFont(playerid, H_TD[playerid][0], 1);
  128.     PlayerTextDrawSetProportional(playerid, H_TD[playerid][0], 1);
  129.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][0], 0);
  130.  
  131.     H_TD[playerid][1] = CreatePlayerTextDraw(playerid, 69.555618, 160.133361, "HALLOWEEN_PRIZE");
  132.     PlayerTextDrawLetterSize(playerid, H_TD[playerid][1], 0.204888, 1.385954);
  133.     PlayerTextDrawTextSize(playerid, H_TD[playerid][1], 0.000000, 137.000000);
  134.     PlayerTextDrawAlignment(playerid, H_TD[playerid][1], 2);
  135.     PlayerTextDrawColor(playerid, H_TD[playerid][1], -1);
  136.     PlayerTextDrawUseBox(playerid, H_TD[playerid][1], 1);
  137.     PlayerTextDrawBoxColor(playerid, H_TD[playerid][1], 255);
  138.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][1], 0);
  139.     PlayerTextDrawSetOutline(playerid, H_TD[playerid][1], -2);
  140.     PlayerTextDrawBackgroundColor(playerid, H_TD[playerid][1], 255);
  141.     PlayerTextDrawFont(playerid, H_TD[playerid][1], 2);
  142.     PlayerTextDrawSetProportional(playerid, H_TD[playerid][1], 1);
  143.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][1], 0);
  144.  
  145.     H_TD[playerid][2] = CreatePlayerTextDraw(playerid, 73.888854, 164.955566, "");
  146.     PlayerTextDrawLetterSize(playerid, H_TD[playerid][2], 0.000000, 0.000000);
  147.     PlayerTextDrawTextSize(playerid, H_TD[playerid][2], 90.000000, 90.000000);
  148.     PlayerTextDrawAlignment(playerid, H_TD[playerid][2], 1);
  149.     PlayerTextDrawColor(playerid, H_TD[playerid][2], -1);
  150.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][2], 0);
  151.     PlayerTextDrawSetOutline(playerid, H_TD[playerid][2], 0);
  152.     PlayerTextDrawBackgroundColor(playerid, H_TD[playerid][2], 0);
  153.     PlayerTextDrawFont(playerid, H_TD[playerid][2], 5);
  154.     PlayerTextDrawSetProportional(playerid, H_TD[playerid][2], 0);
  155.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][2], 0);
  156.     PlayerTextDrawSetPreviewModel(playerid, H_TD[playerid][2], 197);
  157.     PlayerTextDrawSetPreviewRot(playerid, H_TD[playerid][2], 0.000000, 360.000000, 350.000000, 1.000000);
  158.  
  159.     H_TD[playerid][3] = CreatePlayerTextDraw(playerid, 1.888888, 211.746612, "");
  160.     PlayerTextDrawLetterSize(playerid, H_TD[playerid][3], 0.000000, 0.000000);
  161.     PlayerTextDrawTextSize(playerid, H_TD[playerid][3], 24.000000, 13.000000);
  162.     PlayerTextDrawAlignment(playerid, H_TD[playerid][3], 1);
  163.     PlayerTextDrawColor(playerid, H_TD[playerid][3], -1);
  164.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][3], 0);
  165.     PlayerTextDrawSetOutline(playerid, H_TD[playerid][3], 0);
  166.     PlayerTextDrawBackgroundColor(playerid, H_TD[playerid][3], 0);
  167.     PlayerTextDrawFont(playerid, H_TD[playerid][3], 5);
  168.     PlayerTextDrawSetProportional(playerid, H_TD[playerid][3], 0);
  169.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][3], 0);
  170.     PlayerTextDrawSetPreviewModel(playerid, H_TD[playerid][3], 18646);
  171.     PlayerTextDrawSetPreviewRot(playerid, H_TD[playerid][3], 270.000000, 0.000000, 210.000000, 1.000000);
  172.  
  173.     H_TD[playerid][4] = CreatePlayerTextDraw(playerid, -6.111110, 180.884414, "");
  174.     PlayerTextDrawLetterSize(playerid, H_TD[playerid][4], 0.000000, 0.000000);
  175.     PlayerTextDrawTextSize(playerid, H_TD[playerid][4], 49.000000, 24.000000);
  176.     PlayerTextDrawAlignment(playerid, H_TD[playerid][4], 1);
  177.     PlayerTextDrawColor(playerid, H_TD[playerid][4], -1);
  178.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][4], 0);
  179.     PlayerTextDrawSetOutline(playerid, H_TD[playerid][4], 0);
  180.     PlayerTextDrawBackgroundColor(playerid, H_TD[playerid][4], 0);
  181.     PlayerTextDrawFont(playerid, H_TD[playerid][4], 5);
  182.     PlayerTextDrawSetProportional(playerid, H_TD[playerid][4], 0);
  183.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][4], 0);
  184.     PlayerTextDrawSetPreviewModel(playerid, H_TD[playerid][4], 1274);
  185.     PlayerTextDrawSetPreviewRot(playerid, H_TD[playerid][4], 0.000000, 0.000000, 210.000000, 1.000000);
  186.  
  187.     H_TD[playerid][5] = CreatePlayerTextDraw(playerid, 4.111111, 219.213272, "");
  188.     PlayerTextDrawLetterSize(playerid, H_TD[playerid][5], 0.000000, 0.000000);
  189.     PlayerTextDrawTextSize(playerid, H_TD[playerid][5], 24.000000, 13.000000);
  190.     PlayerTextDrawAlignment(playerid, H_TD[playerid][5], 1);
  191.     PlayerTextDrawColor(playerid, H_TD[playerid][5], -2139062017);
  192.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][5], 0);
  193.     PlayerTextDrawSetOutline(playerid, H_TD[playerid][5], 0);
  194.     PlayerTextDrawBackgroundColor(playerid, H_TD[playerid][5], 0);
  195.     PlayerTextDrawFont(playerid, H_TD[playerid][5], 5);
  196.     PlayerTextDrawSetProportional(playerid, H_TD[playerid][5], 0);
  197.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][5], 0);
  198.     PlayerTextDrawSetPreviewModel(playerid, H_TD[playerid][5], 18646);
  199.     PlayerTextDrawSetPreviewRot(playerid, H_TD[playerid][5], 270.000000, 0.000000, 210.000000, 1.000000);
  200.  
  201.     H_TD[playerid][6] = CreatePlayerTextDraw(playerid, 12.111112, 213.239929, "");
  202.     PlayerTextDrawLetterSize(playerid, H_TD[playerid][6], 0.000000, 0.000000);
  203.     PlayerTextDrawTextSize(playerid, H_TD[playerid][6], 24.000000, 13.000000);
  204.     PlayerTextDrawAlignment(playerid, H_TD[playerid][6], 1);
  205.     PlayerTextDrawColor(playerid, H_TD[playerid][6], -1378294017);
  206.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][6], 0);
  207.     PlayerTextDrawSetOutline(playerid, H_TD[playerid][6], 0);
  208.     PlayerTextDrawBackgroundColor(playerid, H_TD[playerid][6], 0);
  209.     PlayerTextDrawFont(playerid, H_TD[playerid][6], 5);
  210.     PlayerTextDrawSetProportional(playerid, H_TD[playerid][6], 0);
  211.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][6], 0);
  212.     PlayerTextDrawSetPreviewModel(playerid, H_TD[playerid][6], 18646);
  213.     PlayerTextDrawSetPreviewRot(playerid, H_TD[playerid][6], 270.000000, 0.000000, 210.000000, 1.000000);
  214.  
  215.     H_TD[playerid][7] = CreatePlayerTextDraw(playerid, -6.111110, 180.884414, "");
  216.     PlayerTextDrawLetterSize(playerid, H_TD[playerid][7], 0.000000, 0.000000);
  217.     PlayerTextDrawTextSize(playerid, H_TD[playerid][7], 49.000000, 24.000000);
  218.     PlayerTextDrawAlignment(playerid, H_TD[playerid][7], 1);
  219.     PlayerTextDrawColor(playerid, H_TD[playerid][7], -1);
  220.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][7], 0);
  221.     PlayerTextDrawSetOutline(playerid, H_TD[playerid][7], 0);
  222.     PlayerTextDrawBackgroundColor(playerid, H_TD[playerid][7], 0);
  223.     PlayerTextDrawFont(playerid, H_TD[playerid][7], 5);
  224.     PlayerTextDrawSetProportional(playerid, H_TD[playerid][7], 0);
  225.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][7], 0);
  226.     PlayerTextDrawSetPreviewModel(playerid, H_TD[playerid][7], 1274);
  227.     PlayerTextDrawSetPreviewRot(playerid, H_TD[playerid][7], 0.000000, 0.000000, 210.000000, 1.000000);
  228.  
  229.     H_TD[playerid][8] = CreatePlayerTextDraw(playerid, -23.888887, 236.635528, "");
  230.     PlayerTextDrawLetterSize(playerid, H_TD[playerid][8], 0.000000, 0.000000);
  231.     PlayerTextDrawTextSize(playerid, H_TD[playerid][8], 64.000000, 36.000000);
  232.     PlayerTextDrawAlignment(playerid, H_TD[playerid][8], 1);
  233.     PlayerTextDrawColor(playerid, H_TD[playerid][8], -1);
  234.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][8], 0);
  235.     PlayerTextDrawSetOutline(playerid, H_TD[playerid][8], 0);
  236.     PlayerTextDrawBackgroundColor(playerid, H_TD[playerid][8], 0);
  237.     PlayerTextDrawFont(playerid, H_TD[playerid][8], 5);
  238.     PlayerTextDrawSetProportional(playerid, H_TD[playerid][8], 0);
  239.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][8], 0);
  240.     PlayerTextDrawSetPreviewModel(playerid, H_TD[playerid][8], 19528);
  241.     PlayerTextDrawSetPreviewRot(playerid, H_TD[playerid][8], 450.000000, 340.000000, 80.000000, 1.000000);
  242.  
  243.     H_TD[playerid][9] = CreatePlayerTextDraw(playerid, 40.222301, 186.017807, "100.000$");
  244.     PlayerTextDrawLetterSize(playerid, H_TD[playerid][9], 0.222665, 1.540266);
  245.     PlayerTextDrawAlignment(playerid, H_TD[playerid][9], 1);
  246.     PlayerTextDrawColor(playerid, H_TD[playerid][9], -1);
  247.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][9], 0);
  248.     PlayerTextDrawSetOutline(playerid, H_TD[playerid][9], -1);
  249.     PlayerTextDrawBackgroundColor(playerid, H_TD[playerid][9], 255);
  250.     PlayerTextDrawFont(playerid, H_TD[playerid][9], 2);
  251.     PlayerTextDrawSetProportional(playerid, H_TD[playerid][9], 1);
  252.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][9], 0);
  253.  
  254.     H_TD[playerid][10] = CreatePlayerTextDraw(playerid, 39.777839, 214.888900, "100_CANDY");
  255.     PlayerTextDrawLetterSize(playerid, H_TD[playerid][10], 0.222665, 1.540266);
  256.     PlayerTextDrawAlignment(playerid, H_TD[playerid][10], 1);
  257.     PlayerTextDrawColor(playerid, H_TD[playerid][10], -1);
  258.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][10], 0);
  259.     PlayerTextDrawSetOutline(playerid, H_TD[playerid][10], -1);
  260.     PlayerTextDrawBackgroundColor(playerid, H_TD[playerid][10], 255);
  261.     PlayerTextDrawFont(playerid, H_TD[playerid][10], 2);
  262.     PlayerTextDrawSetProportional(playerid, H_TD[playerid][10], 1);
  263.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][10], 0);
  264.  
  265.     H_TD[playerid][11] = CreatePlayerTextDraw(playerid, 39.777832, 242.764465, "100_H.P");
  266.     PlayerTextDrawLetterSize(playerid, H_TD[playerid][11], 0.222665, 1.540266);
  267.     PlayerTextDrawAlignment(playerid, H_TD[playerid][11], 1);
  268.     PlayerTextDrawColor(playerid, H_TD[playerid][11], -1);
  269.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][11], 0);
  270.     PlayerTextDrawSetOutline(playerid, H_TD[playerid][11], -1);
  271.     PlayerTextDrawBackgroundColor(playerid, H_TD[playerid][11], 255);
  272.     PlayerTextDrawFont(playerid, H_TD[playerid][11], 2);
  273.     PlayerTextDrawSetProportional(playerid, H_TD[playerid][11], 1);
  274.     PlayerTextDrawSetShadow(playerid, H_TD[playerid][11], 0);
  275.  
  276.     return true;
  277. }
  278. hook OnPlayerSpawn(playerid)
  279. {
  280.     sTime(playerid);
  281.     return true;
  282. }
  283. hook OnPlayerDeath(playerid)
  284. {
  285.     sTime(playerid);
  286.     return true;
  287. }
  288. hook OnPlayerDisconnect(playerid)
  289. {
  290.     sTime(playerid);
  291.     return true;
  292. }
  293.  
  294. hook OnPlayerEnterCheckpoint(playerid)
  295. {
  296.     if(followCP[playerid] == true) DisablePlayerCheckpoint(playerid);
  297.     return true;
  298. }
  299.  
  300. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  301. {
  302.     switch(dialogid)
  303.     {
  304.         case DIALOG_H_ACCS:
  305.         {
  306.             if(!response) return true;
  307.             switch(listitem)
  308.             {
  309.                 case 0:
  310.                 {
  311.                     if(h_Candy[playerid] < 700) return SCM(playerid, -1, "You don't have enough Halloween Candy.");
  312.                     h_Candy[playerid] -= 700;
  313.                     h_objItems[playerid][0] = true;
  314.  
  315.                     SCM(playerid, -1, "{ED872D}Congratulations! You bought a Halloween Hat. You can use /tog to use your hat.");
  316.  
  317.                     new QUERY[128];
  318.                     mysql_format(SQL, QUERY, sizeof QUERY, "UPDATE `users` SET `user_hcandy` = '%d', `user_items` = '%d %d %d' WHERE `user_name` = '%e' LIMIT 1;", h_Candy[playerid], h_objItems[playerid][0], h_objItems[playerid][1], h_objItems[playerid][2], GetName(playerid));
  319.                     mysql_tquery(SQL, QUERY, "", "");
  320.                 }
  321.                 case 1:
  322.                 {
  323.                     if(h_Candy[playerid] < 700) return SCM(playerid, -1, "You don't have enough Halloween Candy.");
  324.                     h_Candy[playerid] -= 700;
  325.                     h_objItems[playerid][2] = true;
  326.  
  327.                     SCM(playerid, -1, "{ED872D}Congratulations! You bought a Halloween Chainsaw. You can use /tog to use your chainsaw.");
  328.  
  329.                     new QUERY[128];
  330.                     mysql_format(SQL, QUERY, sizeof QUERY, "UPDATE `users` SET `user_hcandy` = '%d', `user_items` = '%d %d %d' WHERE `user_name` = '%e' LIMIT 1;", h_Candy[playerid], h_objItems[playerid][0], h_objItems[playerid][1], h_objItems[playerid][2], GetName(playerid));
  331.                     mysql_tquery(SQL, QUERY, "", "");
  332.                 }
  333.             }
  334.         }
  335.         case DIALOG_H_SHOP:
  336.         {
  337.             if(!response) return true;
  338.             switch(listitem)
  339.             {
  340.                 case 0:
  341.                 {
  342.                     if(h_Points[playerid] < 1000) return SCM(playerid, -1, "You don't have enough Halloween Points.");
  343.                     h_Points[playerid] -= 1000;
  344.                    
  345.                     new QUERY[128];
  346.                     mysql_format(SQL, QUERY, sizeof QUERY, "UPDATE `users` SET `user_hpoints` = '%d' WHERE `user_name` = '%e' LIMIT 1;", h_Points[playerid], GetName(playerid));
  347.                     mysql_tquery(SQL, QUERY, "", "");
  348.  
  349.                     new r_Money = 5000000 + random(5000000);
  350.                     GivePlayerMoney(playerid, r_Money);
  351.  
  352.                     new winStr[127];
  353.                     format(winStr, sizeof winStr, "{ffff00}You won: $%s.", FormatNumber(r_Money));
  354.                     SCM(playerid, -1, winStr);
  355.                 }
  356.                 case 1:
  357.                 {
  358.                     if(h_Points[playerid] < 1000) return SCM(playerid, -1, "You don't have enough Halloween Points.");
  359.                     h_Points[playerid] -= 1000;
  360.                     h_objItems[playerid][1] = true;
  361.                    
  362.                     SCM(playerid, -1, "{ED872D}Congratulations! You bought a Halloween Skin. You can use /tog to use your skin.");
  363.  
  364.                     new QUERY[128];
  365.                     mysql_format(SQL, QUERY, sizeof QUERY, "UPDATE `users` SET `user_hpoints` = '%d', `user_items` = '%d %d %d' WHERE `user_name` = '%e' LIMIT 1;", h_Points[playerid], h_objItems[playerid][0], h_objItems[playerid][1], h_objItems[playerid][2], GetName(playerid));
  366.                     mysql_tquery(SQL, QUERY, "", "");
  367.                 }
  368.             }
  369.         }
  370.         case DIALOG_H_TOG:
  371.         {
  372.             if(!response) return DeletePVar(playerid, "lastSkin");
  373.             switch(listitem)
  374.             {
  375.                 case 0 .. 2:
  376.                 {
  377.                     if(h_objItems[playerid][listitem] == false) return SCM(playerid, -1, "{ED872D}You don't have this accessory. Use [/halloweenaccs] to buy.");
  378.  
  379.                     h_objStatus[playerid][listitem] = !h_objStatus[playerid][listitem];
  380.                     if(h_objStatus[playerid][listitem] == true)  _hAction(playerid, listitem, true);
  381.                     if(h_objStatus[playerid][listitem] == false) _hAction(playerid, listitem, false);
  382.                
  383.                     new QUERY[128];
  384.                     mysql_format(SQL, QUERY, sizeof QUERY, "UPDATE `users` SET `user_togitems` = '%d %d %d' WHERE `user_name` = '%e' LIMIT 1;", (h_objStatus[playerid][0] == true) ? (1):(0), (h_objStatus[playerid][1] == true) ? (1):(0), (h_objStatus[playerid][2]== true) ? (1):(0), GetName(playerid));
  385.                     mysql_tquery(SQL, QUERY, "", "");
  386.                 }
  387.             }
  388.         }
  389.     }
  390.     return true;
  391. }
  392. hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  393. {
  394.     switch(newkeys)
  395.     {
  396.         case KEY_YES:
  397.         {
  398.             if(GetPVarInt(playerid, "hHouse") != -1 && halloweenStarted[playerid] == true && takenHouse[playerid][GetPVarInt(playerid, "hHouse")] == false)
  399.             {
  400.                 new
  401.                     str[128],
  402.                     tdStr[10],
  403.                     r_Money   = 20000 + random(30000),
  404.                     r_Candy   = 50 + random(55),
  405.                     r_Skin    = random(sizeof(grandmaSkins)),
  406.                     r_hPoints = 50 + random(50);  
  407.  
  408.                 ApplyAnimation(playerid, "PED", "IDLE_CHAT", 4.0, 0, 0, 0, 0, 0);
  409.                 RemovePlayerMapIcon(playerid, GetPVarInt(playerid, "hHouse"));
  410.                 DeletePlayer3DTextLabel(playerid, trickLabel[playerid][GetPVarInt(playerid, "hHouse")]);
  411.                 DestroyDynamicPickup(trickPickup[playerid][GetPVarInt(playerid, "hHouse")]);
  412.  
  413.                 takenHouse[playerid][GetPVarInt(playerid, "hHouse")] = true;
  414.                 h_Tricked[playerid] ++;
  415.  
  416.                 if(h_Tricked[playerid] < MAX_TRICK_POS)
  417.                 {
  418.                     SCM(playerid, -1, "--------------------------------------------------------------------------------------------------");
  419.                     format(str, sizeof str, "{FFFF00}Halloween Quest: You have to collar "#MAX_TRICK_POS" houses. [You rode: %d/"#MAX_TRICK_POS"]", h_Tricked[playerid]);
  420.                     SCM(playerid, -1, str);
  421.                     format(str, sizeof str, "{FFFF00}Halloween Quest: You roamed this house and received: $%s, %d candy, %d Halloween Points.", FormatNumber(r_Money), r_Candy, r_hPoints);
  422.                     SCM(playerid, -1, str);
  423.                     SCM(playerid, -1, "{FFFF00}Halloween Quest: You can use the /halloweenshop order to buy you something and /halloweenaccs to get halloween attachments.");
  424.                     SCM(playerid, -1, "--------------------------------------------------------------------------------------------------");
  425.                
  426.                     new QUERY[128];
  427.                     mysql_format(SQL, QUERY, sizeof QUERY, "UPDATE `users` SET `user_hcandy` = '%d', `user_hpoints` = '%d' WHERE `user_name` = '%e' LIMIT 1;", h_Candy[playerid], h_Points[playerid], GetName(playerid));
  428.                     mysql_tquery(SQL, QUERY, "", "");
  429.                 }
  430.                 if(h_Tricked[playerid] == MAX_TRICK_POS)
  431.                 {
  432.                     format(str, sizeof str, "{ED872D}Congratulations! You complete the Halloween quest. You won: $5.000.000, 500 Candy, 1000 Halloween Points.");
  433.                     SCM(playerid, -1, str);
  434.  
  435.                     GivePlayerMoney(playerid, 5000000);
  436.                     h_Candy[playerid] += 500;
  437.                     h_Points[playerid] += 1000;
  438.  
  439.                     sTime(playerid);
  440.                 }
  441.  
  442.                 format(tdStr, sizeof tdStr, "$%s", FormatNumber(r_Money));
  443.                 PlayerTextDrawSetString(playerid, H_TD[playerid][9], tdStr);
  444.  
  445.                 format(tdStr, sizeof tdStr, "%d_CANDY", r_Candy);
  446.                 PlayerTextDrawSetString(playerid, H_TD[playerid][10], tdStr);
  447.  
  448.                 format(tdStr, sizeof tdStr, "%d_H.P", r_hPoints);
  449.                 PlayerTextDrawSetString(playerid, H_TD[playerid][11], tdStr);
  450.  
  451.                 PlayerTextDrawSetPreviewModel(playerid, H_TD[playerid][2], grandmaSkins[r_Skin]);
  452.  
  453.                 for(new x, k = 12; x < k; x++)
  454.                     PlayerTextDrawShow(playerid, H_TD[playerid][x]);
  455.  
  456.                 SetTimerEx("hideHTD", 6500, false, "i", playerid);
  457.  
  458.                 GivePlayerMoney(playerid, r_Money);
  459.                 h_Candy[playerid]  += r_Candy;
  460.                 h_Points[playerid] += r_hPoints;
  461.             }
  462.         }
  463.     }
  464.     return true;
  465. }
  466.  
  467. // COMMANDS
  468.  
  469. /*
  470. (!) ------------------------------------------------- (!)
  471.  
  472. If you use ZCMD, replace this line with:
  473. CMD:starthalloween(playerid)
  474.  
  475. (!) ------------------------------------------------- (!)
  476. */
  477.  
  478. YCMD:sethpoints(playerid, params[], help)
  479. {
  480.     new
  481.         pID,
  482.         pHP,
  483.         QUERY[128];
  484.  
  485.     if(sscanf(params, "ui", pID, pHP)) return SCM(playerid, -1, "/sethp [playerid/name] [Halloween Points]");
  486.     h_Points[playerid] = pHP;
  487.     format(QUERY, sizeof QUERY, "{ED872D}Administrator %s has set your Halloween Points to: %d.", GetName(playerid), pHP);  
  488.     SCM(pID, -1, QUERY);
  489.  
  490.     mysql_format(SQL, QUERY, sizeof QUERY, "UPDATE `users` SET `user_hpoints` = '%d' WHERE `user_name` = '%e' LIMIT 1;", pHP, GetName(playerid));
  491.     mysql_tquery(SQL, QUERY, "", "");
  492.     return true;
  493. }
  494. YCMD:setcpoints(playerid, params[], help)
  495. {
  496.     new
  497.         pID,
  498.         pCP,
  499.         QUERY[128];
  500.  
  501.     if(sscanf(params, "ui", pID, pCP)) return SCM(playerid, -1, "/setcp [playerid/name] [Halloween Candy]");
  502.     h_Candy[playerid] = pCP;
  503.     format(QUERY, sizeof QUERY, "{ED872D}Administrator %s has set your Halloween Candy to: %d.", GetName(playerid), pCP);  
  504.     SCM(pID, -1, QUERY);
  505.  
  506.     mysql_format(SQL, QUERY, sizeof QUERY, "UPDATE `users` SET `user_hcandy` = '%d' WHERE `user_name` = '%e' LIMIT 1;", pCP, GetName(playerid));
  507.     mysql_tquery(SQL, QUERY, "", "");
  508.     return true;
  509. }
  510. YCMD:gotohalloween(playerid, params[], help)
  511. {
  512.     SetPlayerVirtualWorld(playerid, 0);
  513.     SetPlayerPos(playerid, START_HALLOWEEN_QUEST);
  514.     SCM(playerid, -1, "You have been teleported.");
  515.     return true;
  516. }
  517. YCMD:starthalloween(playerid, params[], help)
  518. {
  519.     if(h_Tricked[playerid] == MAX_TRICK_POS) return SCM(playerid, -1, "You finished the 'Halloween Quest'.");
  520.     if(!IsPlayerInRangeOfPoint(playerid, 5.0, START_HALLOWEEN_QUEST)) return SCM(playerid, -1, "You're not at the place where you can start halloween carols."), SetPlayerCheckpoint(playerid, START_HALLOWEEN_QUEST, 2.0), followCP[playerid] = true;
  521.     for(new i, j = MAX_TRICK_POS; i < j; i++)
  522.     {
  523.         if(takenHouse[playerid][i] == false)
  524.         {
  525.             trickArea[playerid][i]   = CreateDynamicSphere(halloween_Positions[i][0], halloween_Positions[i][1], halloween_Positions[i][2], 1.5, -1, -1, -1, 0);
  526.             Streamer_SetIntData(STREAMER_TYPE_AREA, trickArea[playerid][i], E_STREAMER_EXTRA_ID, i);
  527.             trickLabel[playerid][i]  = CreatePlayer3DTextLabel(playerid, "{ED872D}Halloween House\nPress 'Y' to say 'Trick or Treat'", 0xFFFFFFFF, halloween_Positions[i][0], halloween_Positions[i][1], halloween_Positions[i][2], 40.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID,0);  
  528.             trickIcon[playerid][i]   = SetPlayerMapIcon(playerid, i, halloween_Positions[i][0], halloween_Positions[i][1], halloween_Positions[i][2], 56, 0, MAPICON_GLOBAL);
  529.             trickPickup[playerid][i] = CreateDynamicPickup(19320,23, halloween_Positions[i][0], halloween_Positions[i][1], halloween_Positions[i][2], 0,-1,-1,50);
  530.             if(i == MAX_TRICK_POS) break;
  531.         }
  532.     }
  533.     halloweenStarted[playerid] = true;
  534.     SetPlayerTime(playerid, 20, 0);
  535.     SetPlayerWeather(playerid, 32);
  536.     SetPlayerVirtualWorld(playerid, 0);
  537.  
  538.     new str[84];
  539.     format(str, sizeof str, "{FFFF00}Halloween Quest: You have to collar "#MAX_TRICK_POS" houses. [You rode: %d/"#MAX_TRICK_POS"]", h_Tricked[playerid]);
  540.     SCM(playerid, -1, str);
  541.     return true;
  542. }
  543. YCMD:halloweenshop(playerid, params[], help)
  544. {
  545.     new hShop[256], hTitle[50];
  546.     format(hTitle, sizeof hTitle, "{ffffff}Halloween Shop: {E0218A}%d points", h_Points[playerid]);
  547.     strcat(hShop, "Item\tPrice\n{ffffff}Random Money\t{E0218A}1000 H.P\n{ffffff}Halloween Skin\t{E0218A}1000 H.P");
  548.     ShowPlayerDialog(playerid, DIALOG_H_SHOP, DIALOG_STYLE_TABLIST_HEADERS, hTitle, hShop, "Buy", "Cancel");
  549.     return true;
  550. }
  551. YCMD:halloweenaccs(playerid, params[], help)
  552. {
  553.     new hAccs[256], hTitle[50];
  554.     format(hTitle, sizeof hTitle, "{ffffff}Halloween Accs: {ED872D}%d candy", h_Candy[playerid]);
  555.     strcat(hAccs, "Item\tPrice\n{ffffff}Halloween Hat\t{ED872D}700 candy\n{ffffff}Halloween chainsaw\t{ED872D}700 candy");
  556.     ShowPlayerDialog(playerid, DIALOG_H_ACCS, DIALOG_STYLE_TABLIST_HEADERS, hTitle, hAccs, "Buy", "Cancel");
  557.     return true;
  558. }
  559. YCMD:tog(playerid, params[], help)
  560. {
  561.     new togString[256];
  562.     strcat(togString, "Item\tStatus\n");
  563.     format(togString, sizeof togString, "%sHalloween Hat\t%s\nHalloween Skin\t%s\nHalloween Chainsaw\t%s", togString, (h_objStatus[playerid][0] == true) ? ("{008000}Enabled"):("{ff0000}Disabled"), (h_objStatus[playerid][1] == true) ? ("{008000}Enabled"):("{ff0000}Disabled"), (h_objStatus[playerid][2] == true) ? ("{008000}Enabled"):("{ff0000}Disabled"));  
  564.     ShowPlayerDialog(playerid, DIALOG_H_TOG, DIALOG_STYLE_TABLIST_HEADERS, "Tog Items", togString, "Select", "Exit");
  565.     SetPVarInt(playerid, "lastSkin", GetPlayerSkin(playerid));
  566.     return true;
  567. }
  568.  
  569. // Functions
  570. Function:: hideHTD(const playerid)
  571. {
  572.     for(new x, k = 12; x < k; x++)
  573.         PlayerTextDrawHide(playerid, H_TD[playerid][x]);
  574.  
  575.     TogglePlayerControllable(playerid, true);
  576.     return true;
  577. }
  578.  
  579. // Stocks
  580. stock GetName(const playerid) {
  581.     new name[MAX_PLAYER_NAME];
  582.     GetPlayerName(playerid, name, sizeof name);
  583.     return name;
  584. }
  585.  
  586. /*
  587. (!) ------------------------------------------------- (!)
  588.  
  589. Add when this function when the player's data is loaded.
  590. The function will call this form: loadHalloweenVars(playerid);
  591.  
  592. (!) ------------------------------------------------- (!)
  593. */
  594.  
  595. loadHalloweenVars(const playerid)
  596. {
  597.     new
  598.         szExplode[64],
  599.         takenDate[23],
  600.         boolDates[6];
  601.  
  602.     h_Candy[playerid]    = cache_get_field_content_int(0, "user_hcandy");
  603.     h_Points[playerid]   = cache_get_field_content_int(0, "user_hpoints");
  604.     h_Tricked[playerid]  = cache_get_field_content_int(0, "user_htricked");
  605.  
  606.     cache_get_field_content(0, "user_htaken", szExplode);
  607.     sscanf(szExplode, "p<|>iiiiiiiiiiiiiiiiiiiiii", takenDate[0], takenDate[1], takenDate[2], takenDate[3], takenDate[4],
  608.                                                     takenDate[5], takenDate[6], takenDate[7], takenDate[8], takenDate[9],
  609.                                                     takenDate[10], takenDate[11], takenDate[12], takenDate[13], takenDate[14],
  610.                                                     takenDate[15], takenDate[16], takenDate[17], takenDate[18], takenDate[19],
  611.                                                     takenDate[20], takenDate[21], takenDate[22]);
  612.     cache_get_field_content(0, "user_items", szExplode);
  613.     sscanf(szExplode, "p<|>iii", boolDates[0], boolDates[4], boolDates[5]);    
  614.     h_objItems[playerid][0]     = boolDates[0] == 1 ? (true):(false);
  615.     h_objItems[playerid][1]     = boolDates[4] == 1 ? (true):(false);
  616.     h_objItems[playerid][2]     = boolDates[5] == 1 ? (true):(false);
  617.  
  618.     cache_get_field_content(0, "user_togitems", szExplode);
  619.     sscanf(szExplode, "p<|>iii", boolDates[1], boolDates[2], boolDates[3]);
  620.     h_objStatus[playerid][0]    = boolDates[1] == 1 ? (true):(false);
  621.     h_objStatus[playerid][1]    = boolDates[2] == 1 ? (true):(false);
  622.     h_objStatus[playerid][2]    = boolDates[3] == 1 ? (true):(false);
  623.  
  624.     for(new i, j = MAX_TRICK_POS; i < j; i++)
  625.         takenHouse[playerid][i] = takenDate[i] == 1 ? (true) : (false);
  626.  
  627.     if(h_objStatus[playerid][0] == true) SetPlayerAttachedObject( playerid, 8, 19528, 2, 0.142636, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
  628.     if(h_objStatus[playerid][2] == true) SetPlayerAttachedObject( playerid, 7, 341, 1, -0.349702, -0.235238, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
  629.     return true;
  630. }
  631.  
  632. sTime(const playerid)
  633. {
  634.     new h, m, s;
  635.     gettime(h,m,s);
  636.     SetPlayerTime(playerid, h,m);
  637.  
  638.     DeletePVar(playerid, "hHouse");
  639.     for(new i, j = MAX_TRICK_POS; i < j; i++)
  640.     {
  641.         DeletePlayer3DTextLabel(playerid, trickLabel[playerid][i]);
  642.         RemovePlayerMapIcon(playerid, i);
  643.         DestroyDynamicPickup(trickPickup[playerid][i]);
  644.         if(i == MAX_TRICK_POS) break;
  645.     }
  646.  
  647.     new QUERY[256];
  648.     mysql_format(SQL, QUERY, sizeof QUERY, "UPDATE `users` SET `user_htaken` = '%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d', `user_htricked` = '%d', `user_hpoints` = '%d', `user_hcandy` = '%d' WHERE `user_name` = '%e' LIMIT 1;", takenHouse[playerid][0], takenHouse[playerid][1], takenHouse[playerid][2], takenHouse[playerid][3],
  649.                                                                                                                                                                                                                takenHouse[playerid][4], takenHouse[playerid][5], takenHouse[playerid][6], takenHouse[playerid][7],
  650.                                                                                                                                                                                                                takenHouse[playerid][8], takenHouse[playerid][9], takenHouse[playerid][10], takenHouse[playerid][11],
  651.                                                                                                                                                                                                                takenHouse[playerid][12], takenHouse[playerid][13], takenHouse[playerid][14], takenHouse[playerid][15],
  652.                                                                                                                                                                                                                takenHouse[playerid][16], takenHouse[playerid][17], takenHouse[playerid][18], takenHouse[playerid][19],
  653.                                                                                                                                                                                                                takenHouse[playerid][20], takenHouse[playerid][21], h_Tricked[playerid], h_Points[playerid], h_Candy[playerid], GetName(playerid));
  654.     mysql_tquery(SQL, QUERY, "", "");
  655.     return true;
  656. }
  657.  
  658. FormatNumber(number) {
  659.     new numOfPeriods = 0, tmp = number,str[32];
  660.     while(tmp > 1000) tmp = floatround(tmp / 1000, floatround_floor), ++numOfPeriods;
  661.     valstr(str, number);
  662.     new slen = strlen(str);
  663.     for(new i = 1; i != numOfPeriods + 1; ++i) strins(str, ".", slen - 3*i);
  664.     return str;
  665. }
  666.  
  667. _hAction(const playerid, lAction, bool: iAction)
  668. {
  669.     switch(lAction)
  670.     {
  671.         case 0:
  672.         {
  673.             if(iAction == true) SetPlayerAttachedObject( playerid, 8, 19528, 2, 0.142636, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
  674.             if(iAction == false) RemovePlayerAttachedObject(playerid, 8);
  675.         }
  676.         case 1:
  677.         {
  678.             if(iAction == true) SetPlayerSkin(playerid, 264);
  679.             if(iAction == false) SetPlayerSkin(playerid, GetPVarInt(playerid, "lastSkin"));
  680.         }
  681.         case 2:
  682.         {
  683.             if(iAction == true) SetPlayerAttachedObject( playerid, 7, 341, 1, -0.349702, -0.235238, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
  684.             if(iAction == false) RemovePlayerAttachedObject(playerid, 7);
  685.         }
  686.     }
  687.     return true;
  688. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement