Advertisement
Guest User

g_casinogames_utilities.pwn (By GhoulSlayeR)

a guest
Feb 27th, 2013
4,983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 18.04 KB | None | 0 0
  1. /*
  2.        
  3.         _________               .__              
  4.         \_   ___ \_____    _____|__| ____   ____  
  5.         /    \  \/\__  \  /  ___/  |/    \ /  _ \
  6.         \     \____/ __ \_\___ \|  |   |  (  <_> )
  7.          \______  (____  /____  >__|___|  /\____/
  8.                 \/     \/     \/        \/        
  9.           ________                              
  10.          /  _____/_____    _____   ____   ______
  11.         /   \  ___\__  \  /     \_/ __ \ /  ___/
  12.         \    \_\  \/ __ \|  Y Y  \  ___/ \___ \
  13.          \______  (____  /__|_|  /\___  >____  >
  14.                 \/     \/      \/     \/     \/
  15.  
  16.                         Utilities
  17.                
  18.           Developed By Dan 'GhoulSlayeR' Reed
  19.                  mrdanreed@gmail.com
  20.          
  21. ===========================================================
  22. This software was written for the sole purpose to not be
  23. destributed without written permission from the software
  24. developer.
  25.  
  26. Changelog:
  27.  
  28. 1.0.0 - Inital Release
  29.  
  30. Readme:
  31.  
  32. This is a open-source filterscript that is designed to be
  33. used with other gcasino game modules. The purpose is to
  34. convert whatever your gamemode's currency into 'chips'
  35. that the modules uses.
  36.  
  37. IE. You may use this filterscript to disable any chip
  38. payout to make the casino games simply "for fun".
  39.  
  40. It's recommended for experienced scripters to load
  41. the content of this filterscript into their gamemode,
  42. however you can still compile and use this filterscript
  43. if you so desire.
  44.  
  45. PVar-
  46. "cgChips" - The player variable that is holding the number
  47. of chips the player is holding. You may want to save this
  48. variable within your gamemode.
  49.  
  50. ===========================================================
  51.  
  52.  
  53. */
  54.  
  55. #include <a_samp>
  56. #include <zcmd>
  57. #include <sscanf2>
  58.  
  59. // Colors
  60. #define COLOR_WHITE                         0xFFFFFFAA
  61. #define COLOR_GOLD                          0xFFCC00AA
  62.  
  63. // Dialogs
  64. #define DIALOG_CMACHINEADMINMENU            32200
  65. #define DIALOG_CMACHINESSELECT              32201
  66. #define DIALOG_CMACHINESSETUP               32202
  67. #define DIALOG_CMACHINEBUYSELLCHIPS         32203
  68. #define DIALOG_CMACHINEBUYCHIPS             32204
  69. #define DIALOG_CMACHINESELLCHIPS            32205
  70.  
  71. // Objects
  72. #define OBJ_CHIP_MACHINE                    962
  73.  
  74. // Chip Machine
  75. #define MAX_CHIPMACHINES                    10
  76. #define DRAWDISTANCE_CHIP_MACHINE           150.0
  77. #define DRAWDISTANCE_CHIP_MACHINE_MISC      50.0
  78.  
  79. enum cmInfo
  80. {
  81.     cmPlaced,
  82.     cmObjectID,
  83.     Text3D:cmText3DID,
  84.     Float:cmX,
  85.     Float:cmY,
  86.     Float:cmZ,
  87.     Float:cmRX,
  88.     Float:cmRY,
  89.     Float:cmRZ,
  90.     cmInt,
  91.     cmVW,
  92. };
  93. new ChipMachine[MAX_CHIPMACHINES][cmInfo];
  94.  
  95.  
  96. public OnFilterScriptInit()
  97. {
  98.     print("\n");
  99.     print("========================================");
  100.     printf("gCasino Games (Utilities)");
  101.     print("Developed By: Dan 'GhoulSlayeR' Reed");
  102.     print("========================================");
  103.     print("\n");
  104.  
  105.     InitChipMachines();
  106.    
  107.     return 1;
  108. }
  109.  
  110. //------------------------------------------------
  111.  
  112. GlobalPlaySound(soundid, Float:x, Float:y, Float:z)
  113. {
  114.     for(new i = 0; i < GetMaxPlayers(); i++) {
  115.         if(IsPlayerInRangeOfPoint(i, 25.0, x, y, z)) {
  116.             PlayerPlaySound(i, soundid, x, y, z);
  117.         }
  118.     }
  119. }
  120.  
  121. forward split(const strsrc[], strdest[][], delimiter);
  122. public split(const strsrc[], strdest[][], delimiter)
  123. {
  124.     new i, li;
  125.     new aNum;
  126.     new len;
  127.     while(i <= strlen(strsrc)){
  128.         if(strsrc[i]==delimiter || i==strlen(strsrc)){
  129.             len = strmid(strdest[aNum], strsrc, li, i, 128);
  130.             strdest[aNum][len] = 0;
  131.             li = i+1;
  132.             aNum++;
  133.         }
  134.         i++;
  135.     }
  136.     return 1;
  137. }
  138.  
  139. // Returns the exact amount of chips.
  140. GetChipAmount(playerid)
  141. {
  142.     return GetPVarInt(playerid, "cgChips");
  143. }
  144.  
  145. // Returns the exact amount of currency.
  146. // You may wish to convert this to your gamemode's currency pvar.
  147. GetCurrencyAmount(playerid)
  148. {
  149.     return GetPlayerMoney(playerid);
  150.    
  151.     // or IE:
  152.     // return GetPVarInt(playerid, "pCash");
  153. }
  154.  
  155. // Returns 0 if unable to buy chips, 1 if successful.
  156. // Be sure to adjust to your gamemode's currency pvar.
  157. BuyChips(playerid, amount)
  158. {
  159.     new currencyAmount = GetCurrencyAmount(playerid);
  160.  
  161.     if(currencyAmount >= amount) {
  162.    
  163.         SetPVarInt(playerid, "cgChips", GetChipAmount(playerid)+amount);
  164.         GivePlayerMoney(playerid, -amount);
  165.        
  166.         // or IE:
  167.         // currencyAmount -= amount;
  168.         // SetPVarInt(playerid, "pCash", currencyAmount);
  169.         // SetPVarInt(playerid, "cgChips", GetChipAmount(playerid)+amount);
  170.  
  171.         return 1;
  172.     }
  173.     return 0;
  174. }
  175.  
  176. // Returns 0 if unable to sell chips, 1 if successful.
  177. // Be sure to adjust to your gamemode's currency pvar.
  178. SellChips(playerid, amount)
  179. {
  180.     if(GetPVarInt(playerid, "cgChips") >= amount) {
  181.         SetPVarInt(playerid, "cgChips", GetPVarInt(playerid, "cgChips")-amount);
  182.         GivePlayerMoney(playerid, amount);
  183.        
  184.         // or IE:
  185.         // currencyAmount += amount;
  186.         // SetPVarInt(playerid, "pCash", currencyAmount);
  187.         // SetPVarInt(playerid, "cgChips", GetPVarInt(playerid, "cgChips")-amount);
  188.        
  189.         return 1;
  190.     }
  191.     return 0;
  192. }
  193.  
  194. InitChipMachines()
  195. {
  196.     for(new i = 0; i < MAX_CHIPMACHINES; i++) {
  197.         ChipMachine[i][cmPlaced] = 0;
  198.         ChipMachine[i][cmObjectID] = 0;
  199.         ChipMachine[i][cmX] = 0.0;
  200.         ChipMachine[i][cmY] = 0.0;
  201.         ChipMachine[i][cmZ] = 0.0;
  202.         ChipMachine[i][cmRX] = 0.0;
  203.         ChipMachine[i][cmRY] = 0.0;
  204.         ChipMachine[i][cmRZ] = 0.0;
  205.         ChipMachine[i][cmInt] = 0;
  206.         ChipMachine[i][cmVW] = 0;
  207.     }
  208.    
  209.     LoadChipMachines();
  210. }
  211.  
  212. LoadChipMachines()
  213. {
  214.     new tmpArray[8][64];
  215.     new tmpString[512];
  216.     new File: file = fopen("chipmachines.cfg", io_read);
  217.     if (file)
  218.     {
  219.         new idx;
  220.         while (idx < sizeof(ChipMachine))
  221.         {
  222.             fread(file, tmpString);
  223.             split(tmpString, tmpArray, '|');
  224.            
  225.             ChipMachine[idx][cmX] = floatstr(tmpArray[0]);
  226.             ChipMachine[idx][cmY] = floatstr(tmpArray[1]);
  227.             ChipMachine[idx][cmZ] = floatstr(tmpArray[2]);
  228.             ChipMachine[idx][cmRX] = floatstr(tmpArray[3]);
  229.             ChipMachine[idx][cmRY] = floatstr(tmpArray[4]);
  230.             ChipMachine[idx][cmRZ] = floatstr(tmpArray[5]);
  231.             ChipMachine[idx][cmInt] = strval(tmpArray[6]);
  232.             ChipMachine[idx][cmVW] = strval(tmpArray[7]);
  233.  
  234.            
  235.             if(ChipMachine[idx][cmX] != 0.0) {
  236.                 PlaceChipMachine(idx, ChipMachine[idx][cmX], ChipMachine[idx][cmY], ChipMachine[idx][cmZ], ChipMachine[idx][cmRX], ChipMachine[idx][cmRY], ChipMachine[idx][cmRZ], ChipMachine[idx][cmVW], ChipMachine[idx][cmInt]);
  237.             }
  238.             idx++;
  239.         }
  240.         fclose(file);
  241.     }
  242.     return 1;
  243. }
  244.  
  245. SaveChipMachines()
  246. {
  247.     new idx;
  248.     new File: file;
  249.     while (idx < sizeof(ChipMachine))
  250.     {
  251.         new tmpString[512];
  252.         format(tmpString, sizeof(tmpString), "%f|%f|%f|%f|%f|%f|%d|%d\n",
  253.             ChipMachine[idx][cmX],
  254.             ChipMachine[idx][cmY],
  255.             ChipMachine[idx][cmZ],
  256.             ChipMachine[idx][cmRX],
  257.             ChipMachine[idx][cmRY],
  258.             ChipMachine[idx][cmRZ],
  259.             ChipMachine[idx][cmInt],
  260.             ChipMachine[idx][cmVW]
  261.         );
  262.        
  263.         if(idx == 0) {
  264.             file = fopen("chipmachines.cfg", io_write);
  265.         } else {
  266.             file = fopen("chipmachines.cfg", io_append);
  267.         }
  268.        
  269.         fwrite(file, tmpString);
  270.         idx++;
  271.         fclose(file);
  272.     }
  273.     return 1;
  274. }
  275.  
  276. PlaceChipMachine(machineid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, virtualworld, interior)
  277. {
  278.     ChipMachine[machineid][cmPlaced] = 1;
  279.     ChipMachine[machineid][cmX] = x;
  280.     ChipMachine[machineid][cmY] = y;
  281.     ChipMachine[machineid][cmZ] = z;
  282.     ChipMachine[machineid][cmRX] = rx;
  283.     ChipMachine[machineid][cmRY] = ry;
  284.     ChipMachine[machineid][cmRZ] = rz;
  285.     ChipMachine[machineid][cmVW] = virtualworld;
  286.     ChipMachine[machineid][cmInt] = interior;
  287.    
  288.     // Create Machine
  289.     ChipMachine[machineid][cmObjectID] = CreateObject(OBJ_CHIP_MACHINE, x, y, z, rx, ry, rz, DRAWDISTANCE_CHIP_MACHINE);
  290.    
  291.     // Create 3D Text Label
  292.     new szString[64];
  293.     format(szString, sizeof(szString), "Chip Machine %d\n\n/chips", machineid);
  294.     ChipMachine[machineid][cmText3DID] = Create3DTextLabel(szString, COLOR_GOLD, x, y, z+1.3, DRAWDISTANCE_CHIP_MACHINE_MISC, virtualworld, interior);
  295.  
  296.     SaveChipMachines();
  297.    
  298.     return machineid;
  299. }
  300.  
  301. DestroyChipMachine(machineid)
  302. {
  303.     ChipMachine[machineid][cmX] = 0.0;
  304.     ChipMachine[machineid][cmY] = 0.0;
  305.     ChipMachine[machineid][cmZ] = 0.0;
  306.     ChipMachine[machineid][cmRX] = 0.0;
  307.     ChipMachine[machineid][cmRY] = 0.0;
  308.     ChipMachine[machineid][cmRZ] = 0.0;
  309.     ChipMachine[machineid][cmInt] = 0;
  310.     ChipMachine[machineid][cmVW] = 0;
  311.    
  312.     if(ChipMachine[machineid][cmPlaced] == 1) {
  313.         // Delete Object
  314.         if(IsValidObject(ChipMachine[machineid][cmObjectID])) DestroyObject(ChipMachine[machineid][cmObjectID]);
  315.        
  316.         // Delete 3D TextDraw
  317.         Delete3DTextLabel(ChipMachine[machineid][cmText3DID]);
  318.     }
  319.    
  320.     ChipMachine[machineid][cmPlaced] = 0;
  321.    
  322.     SaveChipMachines();
  323.    
  324.     return machineid;
  325. }
  326.  
  327. ShowChipMachinesMenu(playerid, dialogid)
  328. {
  329.     switch(dialogid)
  330.     {
  331.         case DIALOG_CMACHINEBUYSELLCHIPS:
  332.         {
  333.             new szString[256];
  334.             format(szString, sizeof(szString), "{FFFFFF}Buy Chips\t({00FF00}$%d{FFFFFF})\nSell Chips\t({00FF00}%d{FFFFFF})", GetCurrencyAmount(playerid), GetChipAmount(playerid));
  335.             ShowPlayerDialog(playerid, DIALOG_CMACHINEBUYSELLCHIPS, DIALOG_STYLE_LIST, "Chip Machines - (Buy/Sell Chips)", szString, "Select", "Close");
  336.         }
  337.         case DIALOG_CMACHINEBUYCHIPS:
  338.         {
  339.             new szString[256];
  340.             format(szString, sizeof(szString), "{FFFFFF}Please input an amount you wish to purchase:\n\nCurrency: {00FF00}$%d{FFFFFF}\nChips: {00FF00}%d\n\n", GetCurrencyAmount(playerid), GetChipAmount(playerid));
  341.             ShowPlayerDialog(playerid, DIALOG_CMACHINEBUYCHIPS, DIALOG_STYLE_INPUT, "Chip Machines - (Buy Chips)", szString, "Buy Chips", "Back");
  342.         }
  343.         case DIALOG_CMACHINESELLCHIPS:
  344.         {
  345.             new szString[256];
  346.             format(szString, sizeof(szString), "{FFFFFF}Please input an amount you wish to sell:\n\nCurrency: {00FF00}$%d{FFFFFF}\nChips: {00FF00}%d{FFFFFF}\n\n", GetCurrencyAmount(playerid), GetChipAmount(playerid));
  347.             ShowPlayerDialog(playerid, DIALOG_CMACHINESELLCHIPS, DIALOG_STYLE_INPUT, "Chip Machines - (Sell Chips)", szString, "Sell Chips", "Back");
  348.         }
  349.         case DIALOG_CMACHINEADMINMENU:
  350.         {
  351.             return ShowPlayerDialog(playerid, DIALOG_CMACHINEADMINMENU, DIALOG_STYLE_LIST, "{FFFFFF}Chip Machines - (Admin Menu)", "{FFFFFF}Setup Chip Machine...", "Select", "Close");
  352.         }
  353.         case DIALOG_CMACHINESSELECT:
  354.         {
  355.             new szString[1024];
  356.             new szPlaced[64];
  357.            
  358.             for(new i = 0; i < MAX_CHIPMACHINES; i++) {
  359.                 if(ChipMachine[i][cmPlaced] == 1) { format(szPlaced, sizeof(szPlaced), "{00FF00}Active{FFFFFF}"); }
  360.                 if(ChipMachine[i][cmPlaced] == 0) { format(szPlaced, sizeof(szPlaced), "{FF0000}Deactived{FFFFFF}"); }
  361.                 format(szString, sizeof(szString), "%sChip Machine %d (%s)\n", szString, i, szPlaced);
  362.             }
  363.             return ShowPlayerDialog(playerid, DIALOG_CMACHINESSELECT, DIALOG_STYLE_LIST, "{FFFFFF}Chip Machines - (Select Machine)", szString, "Select", "Back");
  364.         }
  365.         case DIALOG_CMACHINESSETUP:
  366.         {
  367.             new machineid = GetPVarInt(playerid, "tmpEditChipMachineID")-1;
  368.            
  369.             if(ChipMachine[machineid][cmPlaced] == 0) {
  370.                 return ShowPlayerDialog(playerid, DIALOG_CMACHINESSETUP, DIALOG_STYLE_LIST, "{FFFFFF}Chip Machines - (Select Machine)", "{FFFFFF}Place Machine...", "Select", "Back");
  371.             } else {
  372.                 return ShowPlayerDialog(playerid, DIALOG_CMACHINESSETUP, DIALOG_STYLE_LIST, "{FFFFFF}Chip Machines - (Select Machine)", "{FFFFFF}Edit Machine...\nDelete Machine...", "Select", "Back");
  373.             }
  374.         }
  375.     }
  376.     return 1;
  377. }
  378.  
  379. CMD:chipmachines(playerid, params[])
  380. {
  381.     if(IsPlayerAdmin(playerid)) {
  382.         ShowChipMachinesMenu(playerid, DIALOG_CMACHINEADMINMENU);
  383.     } else {
  384.         SendClientMessage(playerid, COLOR_WHITE, "You are not a rcon admin, you cannot use this command!");
  385.     }
  386.     return 1;
  387. }
  388.  
  389. CMD:chips(playerid, params[])
  390. {
  391.     for(new i = 0; i < MAX_CHIPMACHINES; i++) {
  392.         if(IsPlayerInRangeOfPoint(playerid, 5.0, ChipMachine[i][cmX], ChipMachine[i][cmY], ChipMachine[i][cmZ])) {
  393.             GlobalPlaySound(6400, ChipMachine[i][cmX], ChipMachine[i][cmY], ChipMachine[i][cmZ]);
  394.            
  395.             ShowChipMachinesMenu(playerid, DIALOG_CMACHINEBUYSELLCHIPS);
  396.             return 1;
  397.         }
  398.     }
  399.     return SendClientMessage(playerid, COLOR_WHITE, "You are not near a Chip Machine!");
  400. }
  401.  
  402. public OnPlayerConnect(playerid)
  403. {
  404.     return 1;
  405. }
  406.  
  407. public OnPlayerDisconnect(playerid, reason)
  408. {
  409.     return 1;
  410. }
  411.  
  412. public OnPlayerUpdate(playerid)
  413. {
  414.     if(GetPVarType(playerid, "tmpPlaceChipMachine"))
  415.     {
  416.         new keys, updown, leftright;
  417.         GetPlayerKeys(playerid, keys, updown, leftright);
  418.        
  419.         if(keys == KEY_SPRINT) {
  420.             DeletePVar(playerid, "tmpPlaceChipMachine");
  421.            
  422.             new Float:x, Float:y, Float:z;
  423.             GetPlayerPos(playerid, x, y, z);
  424.             new int = GetPlayerInterior(playerid);
  425.             new vw = GetPlayerVirtualWorld(playerid);
  426.            
  427.             new machineid = PlaceChipMachine(GetPVarInt(playerid, "tmpEditChipMachineID")-1, x, y, z+2.0, 0.0, 0.0, 0.0, vw, int);
  428.            
  429.             SetPVarFloat(playerid, "tmpCmX", ChipMachine[machineid][cmX]);
  430.             SetPVarFloat(playerid, "tmpCmY", ChipMachine[machineid][cmY]);
  431.             SetPVarFloat(playerid, "tmpCmZ", ChipMachine[machineid][cmZ]);
  432.             SetPVarFloat(playerid, "tmpCmRX", ChipMachine[machineid][cmRX]);
  433.             SetPVarFloat(playerid, "tmpCmRY", ChipMachine[machineid][cmRY]);
  434.             SetPVarFloat(playerid, "tmpCmRZ", ChipMachine[machineid][cmRZ]);
  435.            
  436.             EditObject(playerid, ChipMachine[machineid][cmObjectID]);
  437.            
  438.             new szString[128];
  439.             format(szString, sizeof(szString), "You have placed Chip Machine %d, You may now customize it's position/rotation.", machineid);
  440.             SendClientMessage(playerid, COLOR_WHITE, szString);
  441.         }
  442.     }
  443.     return 1;
  444. }
  445.  
  446. public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ)
  447. {
  448.     if(type == SELECT_OBJECT_GLOBAL_OBJECT)
  449.     {
  450.         EditObject(playerid, objectid);
  451.     }
  452.     return 1;
  453. }
  454.  
  455. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
  456. {
  457.     SetObjectPos(objectid, fX, fY, fZ);
  458.     SetObjectRot(objectid, fRotX, fRotY, fRotZ);
  459.    
  460.     if(response == EDIT_RESPONSE_FINAL)
  461.     {
  462.         if(GetPVarType(playerid, "tmpEditChipMachineID")) {
  463.             new machineid = GetPVarInt(playerid, "tmpEditChipMachineID")-1;
  464.             DeletePVar(playerid, "tmpEditChipMachineID");
  465.                
  466.             DeletePVar(playerid, "tmpCmX");
  467.             DeletePVar(playerid, "tmpCmY");
  468.             DeletePVar(playerid, "tmpCmZ");
  469.             DeletePVar(playerid, "tmpCmRX");
  470.             DeletePVar(playerid, "tmpCmRY");
  471.             DeletePVar(playerid, "tmpCmRZ");
  472.                
  473.             DestroyChipMachine(machineid);
  474.             PlaceChipMachine(machineid, fX, fY, fZ, fRotX, fRotY, fRotZ, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
  475.                
  476.             ShowChipMachinesMenu(playerid, DIALOG_CMACHINESSELECT);
  477.         }
  478.     }
  479.    
  480.     if(response == EDIT_RESPONSE_CANCEL)
  481.     {
  482.         if(GetPVarType(playerid, "tmpEditChipMachineID")) {
  483.             new machineid = GetPVarInt(playerid, "tmpEditChipMachineID")-1;
  484.             DeletePVar(playerid, "tmpEditChipMachineID");
  485.            
  486.             DestroyChipMachine(machineid);
  487.             PlaceChipMachine(machineid, GetPVarFloat(playerid, "tmpCmX"), GetPVarFloat(playerid, "tmpCmY"), GetPVarFloat(playerid, "tmpCmZ"), GetPVarFloat(playerid, "tmpCmRX"), GetPVarFloat(playerid, "tmpCmRY"), GetPVarFloat(playerid, "tmpCmRZ"), GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
  488.            
  489.             DeletePVar(playerid, "tmpCmX");
  490.             DeletePVar(playerid, "tmpCmY");
  491.             DeletePVar(playerid, "tmpCmZ");
  492.             DeletePVar(playerid, "tmpCmRX");
  493.             DeletePVar(playerid, "tmpCmRY");
  494.             DeletePVar(playerid, "tmpCmRZ");
  495.            
  496.             ShowChipMachinesMenu(playerid, DIALOG_CMACHINESSELECT);
  497.         }
  498.     }
  499. }
  500.  
  501. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  502. {
  503.     if(dialogid == DIALOG_CMACHINEBUYSELLCHIPS)
  504.     {
  505.         if(response) {
  506.             switch(listitem)
  507.             {
  508.                 case 0: // Buy
  509.                 {
  510.                     ShowChipMachinesMenu(playerid, DIALOG_CMACHINEBUYCHIPS);
  511.                 }
  512.                 case 1: // Sell
  513.                 {
  514.                     ShowChipMachinesMenu(playerid, DIALOG_CMACHINESELLCHIPS);
  515.                 }
  516.             }
  517.         }
  518.     }
  519.     if(dialogid == DIALOG_CMACHINEBUYCHIPS)
  520.     {
  521.         if(response) {
  522.             if(strval(inputtext) > 0 && strval(inputtext) < 10000000) {
  523.                 BuyChips(playerid, strval(inputtext));
  524.             }
  525.             ShowChipMachinesMenu(playerid, DIALOG_CMACHINEBUYCHIPS);
  526.         } else {
  527.             ShowChipMachinesMenu(playerid, DIALOG_CMACHINEBUYSELLCHIPS);
  528.         }
  529.     }
  530.     if(dialogid == DIALOG_CMACHINESELLCHIPS)
  531.     {
  532.         if(response) {
  533.             if(strval(inputtext) > 0 && strval(inputtext) < 10000000) {
  534.                 SellChips(playerid, strval(inputtext));
  535.             }
  536.             ShowChipMachinesMenu(playerid, DIALOG_CMACHINESELLCHIPS);
  537.         } else {
  538.             ShowChipMachinesMenu(playerid, DIALOG_CMACHINEBUYSELLCHIPS);
  539.         }
  540.     }
  541.     if(dialogid == DIALOG_CMACHINEADMINMENU)
  542.     {
  543.         if(response) {
  544.             switch(listitem)
  545.             {
  546.                 case 0:
  547.                 {
  548.                     ShowChipMachinesMenu(playerid, DIALOG_CMACHINESSELECT);
  549.                 }
  550.             }
  551.         }
  552.     }
  553.     if(dialogid == DIALOG_CMACHINESSELECT)
  554.     {
  555.         if(response) {
  556.             SetPVarInt(playerid, "tmpEditChipMachineID", listitem+1);
  557.             ShowChipMachinesMenu(playerid, DIALOG_CMACHINESSETUP);
  558.         } else {
  559.             ShowChipMachinesMenu(playerid, DIALOG_CMACHINEADMINMENU);
  560.         }
  561.     }
  562.     if(dialogid == DIALOG_CMACHINESSETUP)
  563.     {
  564.         if(response) {
  565.             new machineid = GetPVarInt(playerid, "tmpEditChipMachineID")-1;
  566.            
  567.             if(ChipMachine[machineid][cmPlaced] == 0) {
  568.                 switch(listitem)
  569.                 {
  570.                     case 0:
  571.                     {
  572.                         new szString[128];
  573.                         format(szString, sizeof(szString), "Press '{3399FF}~k~~PED_SPRINT~{FFFFFF}' to place chip machine.");
  574.                         SendClientMessage(playerid, COLOR_WHITE, szString);
  575.                        
  576.                         SetPVarInt(playerid, "tmpPlaceChipMachine", 1);
  577.                     }
  578.                 }
  579.             } else {
  580.                 switch(listitem)
  581.                 {
  582.                     case 0: // Edit Machine
  583.                     {
  584.                         SetPVarFloat(playerid, "tmpCmX", ChipMachine[machineid][cmX]);
  585.                         SetPVarFloat(playerid, "tmpCmY", ChipMachine[machineid][cmY]);
  586.                         SetPVarFloat(playerid, "tmpCmZ", ChipMachine[machineid][cmZ]);
  587.                         SetPVarFloat(playerid, "tmpCmRX", ChipMachine[machineid][cmRX]);
  588.                         SetPVarFloat(playerid, "tmpCmRY", ChipMachine[machineid][cmRY]);
  589.                         SetPVarFloat(playerid, "tmpCmRZ", ChipMachine[machineid][cmRZ]);
  590.                    
  591.                         EditObject(playerid, ChipMachine[machineid][cmObjectID]);
  592.            
  593.                         new szString[128];
  594.                         format(szString, sizeof(szString), "You have selected Chip Machine %d, You may now customize it's position/rotation.", machineid);
  595.                         SendClientMessage(playerid, COLOR_WHITE, szString);
  596.                     }
  597.                     case 1: // Delete Machine
  598.                     {
  599.                         DestroyChipMachine(machineid);
  600.                        
  601.                         new szString[64];
  602.                         format(szString, sizeof(szString), "You have deleted Chip Machine %d.", machineid);
  603.                         SendClientMessage(playerid, COLOR_WHITE, szString);
  604.                        
  605.                         ShowChipMachinesMenu(playerid, DIALOG_CMACHINESSELECT);
  606.                     }
  607.                 }
  608.             }
  609.         }
  610.     }
  611.     return 0;
  612. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement