Advertisement
friezakinght

Drug System v3.0

Jul 10th, 2014
1,130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 21.16 KB | None | 0 0
  1. /*Drug System made by Friezakinght
  2. Current Version: 3.0
  3.  
  4. Commands:
  5. /buydrugs
  6. /usedrugs
  7. /mydrugs
  8. /givedrugs
  9. /selldrugs
  10. /acceptdrugs
  11. /drugcmds
  12. /setdrugs (only for RCON admins)
  13. /agivedrugs (only for RCON admins)
  14. /checkdrugs (only for RCON admins)
  15.  
  16. Author/Scripter: friezakinght
  17. Thanks to:
  18. Y_Less for - foreach, sscanf, Y_ini
  19. Zeex for - ZCMD
  20.  
  21. You can modify the script how you like, however, please keep the credits.
  22. This is the final version of the script, thank you for downloading, any minor update would be in work if found any bugs!
  23.  
  24. Changelog v3.0:
  25. Added a message box instead of a text message which shows how much drugs the player have and how much are they worth on the street.
  26. Added /selldrugs command for players to sell drugs to other players. The value by default is 1000$ per gram - 100$ dealer fee.
  27. Added /acceptdrugs [dealer id] command for players to accept a dealer's deal.
  28. Added /drugcmds command to see all of the drug system commands, admins can see all commands + admin commands.
  29. Now you can /givedrugs and /selldrugs or /acceptdrugs only if you are close to the player you're giving/selling to or accepting from.
  30. Added 2 more drug types: Opium(30HP) and Meth(15HP)
  31. Changed Cocaine(80HP), Weed(60HP) and Heroine(50HP) HP value.
  32.  
  33. */
  34.  
  35. #include <a_samp>
  36. #include <YSI\y_ini>
  37. #include <zcmd>
  38. #include <sscanf2>
  39. #include <foreach>
  40.  
  41. #define USER_FILE "UserDrugs/%s.ini"
  42. #define DRUG_SHOP_MENU 1
  43. #define MY_DRUGS_MENU 2
  44. #define DRUG_COMMANDS_MENU 3
  45. #define DRUG_GRAM_PRICE 1000
  46. #define DRUG_DEALER_FEE 100
  47.  
  48. #define RED 0xFF0000FF
  49. #define BLUE 0x999999
  50. #define WHITE 0xFFFFFFAA
  51. #define GREEN 0x33AA33AA
  52.  
  53. enum PlayerInfo
  54. {
  55.     pName,
  56.     pDrugs
  57. }
  58. new PDrugs[MAX_PLAYERS][PlayerInfo];
  59. new IsHigh[MAX_PLAYERS];
  60. new Deal[MAX_PLAYERS];
  61. new ddprice = DRUG_GRAM_PRICE - DRUG_DEALER_FEE;
  62. new DDAmount[MAX_PLAYERS];
  63.  
  64. public OnFilterScriptInit()
  65. {
  66.     print("\n--------------------------------------");
  67.     print(" Drug System by friezakinght v2.0");
  68.     print("--------------------------------------\n");
  69.    
  70.     return 1;
  71. }
  72.  
  73. public OnFilterScriptExit()
  74. {
  75.     foreach(Player, p)
  76.     {
  77.         if(IsPlayerConnected(p))
  78.         {
  79.             SaveUserDrugStats(p);
  80.         }
  81.     }
  82.     return 1;
  83. }
  84.  
  85. public OnPlayerConnect(playerid)
  86. {
  87.     if(fexist(DrugFilePath(playerid)))
  88.     {
  89.         INI_ParseFile(DrugFilePath(playerid), "LoadDrugData_%s", .bExtra = true, .extra = playerid);
  90.     }
  91.     else
  92.     {
  93.         new playerName[MAX_PLAYER_NAME];
  94.         GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
  95.         new INI:ufile = INI_Open(DrugFilePath(playerid));
  96.         INI_SetTag(ufile, "general");
  97.         INI_WriteString(ufile, "pName", playerName);
  98.         INI_WriteInt(ufile, "pDrugs",  0);
  99.         INI_Close(ufile);
  100.     }
  101.     return 1;
  102. }
  103.  
  104. public OnPlayerDisconnect(playerid, reason)
  105. {
  106.     SaveUserDrugStats(playerid);
  107.     return 1;
  108. }
  109.  
  110. public OnPlayerSpawn(playerid)
  111. {
  112.     IsHigh[playerid] = 0;
  113.     SetPlayerDrunkLevel(playerid, 0);
  114.     return 1;
  115. }
  116.  
  117. public OnPlayerDeath(playerid, killerid, reason)
  118. {
  119.     IsHigh[playerid] = 0;
  120.     SetPlayerWeather(playerid, 1);
  121.     SetPlayerDrunkLevel(playerid, 0);
  122.     return 1;
  123. }
  124.  
  125. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  126. {
  127.     if(dialogid == DRUG_SHOP_MENU && response == 1)
  128.     {
  129.         new dstr[150];
  130.         format(dstr, sizeof(dstr), "{FFFFCC}Enter the amount of {006600}grams {FFFFCC}you would like to {00FF00}buy:{FFFFCC}\nCurrent price per gram: ${00FF00}%d{FFFFCC}", DRUG_GRAM_PRICE);
  131.         if(strlen(inputtext) <= 0) { ShowPlayerDialog(playerid, DRUG_SHOP_MENU, DIALOG_STYLE_INPUT,"{006600}Buy drugs:", dstr, "Buy", "Close"); }
  132.         else if(!DrugAmountIsNumeric(inputtext)) { ShowPlayerDialog(playerid, DRUG_SHOP_MENU, DIALOG_STYLE_INPUT,"{006600}Buy drugs:", dstr, "Buy", "Close"); }
  133.         else
  134.         {
  135.         new
  136.             pcash = GetPlayerMoney(playerid),
  137.             str[128],
  138.             amount = strval(inputtext),
  139.             cash = amount * DRUG_GRAM_PRICE;
  140.         if(amount <= 500)
  141.         {
  142.             if(pcash >= cash)
  143.             {
  144.                 GivePlayerMoney(playerid, - cash);
  145.                 format(str, sizeof(str), "You bought {00FF00}%d {FFFFFF}grams of drugs for {00FF00}$%d{FFFFFF}.", amount, cash);
  146.                 SendClientMessage(playerid, -1, str);
  147.                 PDrugs[playerid][pDrugs] += amount;
  148.                 SaveUserDrugStats(playerid);
  149.             }
  150.             else
  151.             {
  152.                 format(str, sizeof(str), "You don't have enough money for %dg of drugs!", amount);
  153.                 SendClientMessage(playerid, RED, str);
  154.             }
  155.         }
  156.         else
  157.         {
  158.             format(str, sizeof(str), "You cannot buy more than 500g of drugs per purchase!");
  159.             SendClientMessage(playerid, RED, str);
  160.         }
  161.         }
  162.     }
  163.     return 1;
  164. }
  165.  
  166. CMD:buydrugs(playerid, params[])
  167. {
  168.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, "You need to be connected to buy drugs!");
  169.     new dstr[150];
  170.     format(dstr, sizeof(dstr), "{FFFFCC}Enter the amount of {006600}grams {FFFFCC}you would like to {00FF00}buy:{FFFFCC}\nCurrent price per gram: ${00FF00}%d{FFFFCC}", DRUG_GRAM_PRICE);
  171.     ShowPlayerDialog(playerid, DRUG_SHOP_MENU, DIALOG_STYLE_INPUT,"{006600}Buy drugs:", dstr, "Buy", "Close");
  172.     return true;
  173. }
  174.  
  175. CMD:usedrugs(playerid, params[])
  176. {
  177.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, BLUE, "You're not even connected to the server.");
  178.     if(IsHigh[playerid] == 1) return SendClientMessage(playerid, BLUE, "You're already high!" );
  179.     if(PDrugs[playerid][pDrugs] == 0) return SendClientMessage(playerid, BLUE, "You don't have a gram of drugs");
  180.     new drugname[32];
  181.     if(sscanf(params,"s[32]",drugname))
  182.     {
  183.         SendClientMessage(playerid, BLUE, "USAGE: /usedrugs [drugname/number]");
  184.         SendClientMessage(playerid, BLUE, "CHOICES: Cocaine [1](80HP), Weed [2](60HP), Heroine [3](50HP), Opium[4](30HP), Meth[5](15HP).");
  185.  
  186.         return 1;
  187.     }
  188.     new Float:PHealth;
  189.     if(strcmp(drugname, "cocaine", true) == 0 || strcmp(drugname, "1", true) == 0)
  190.     {
  191.         GetPlayerHealth(playerid, PHealth);
  192.         if(PDrugs[playerid][pDrugs] >= 5)
  193.         {
  194.             SetPlayerWeather(playerid, -66);
  195.             SetPlayerDrunkLevel(playerid, 4999);
  196.             SetPlayerTime(playerid,12,00);
  197.             GameTextForPlayer(playerid, "~r~The drug effect will be gone in a minute", 3000, 5);
  198.             IsHigh[playerid] = 1;
  199.             PDrugs[playerid][pDrugs] -= 5;
  200.             SaveUserDrugStats(playerid);
  201.             SendClientMessage(playerid, WHITE, "You snorted 5g of cocaine.");
  202.             SetTimer("IsHighTimer", 120000, false);
  203.             if(PHealth <= 80)
  204.             {
  205.                 GivePlayerHealth(playerid, 20);
  206.             }
  207.             else
  208.             {
  209.                 SetPlayerHealth(playerid, 100);
  210.             }
  211.         }
  212.         else
  213.         {
  214.             SendClientMessage(playerid, BLUE, "You need 5g of drugs to snort cocaine.");
  215.         }
  216.     }
  217.     if(strcmp(drugname, "weed", true) == 0 || strcmp(drugname, "2", true) == 0)
  218.     {
  219.         if(PDrugs[playerid][pDrugs] >= 4)
  220.         {
  221.             GetPlayerHealth(playerid, PHealth);
  222.             SetPlayerWeather(playerid, -66);
  223.             SetPlayerDrunkLevel(playerid, 4750);
  224.             SetPlayerTime(playerid,12,00);
  225.             GameTextForPlayer(playerid, "~r~The drug effect will be gone in a minute", 3000, 5);
  226.             IsHigh[playerid] = 1;
  227.             PDrugs[playerid][pDrugs] -= 4;
  228.             SaveUserDrugStats(playerid);
  229.             SetPlayerSpecialAction(playerid, SPECIAL_ACTION_SMOKE_CIGGY);
  230.             SendClientMessage(playerid, WHITE, "You lit a joint and started smoking.");
  231.             SetTimer("IsHighTimer", 120000, false);
  232.             if(PHealth <= 60)
  233.             {
  234.                 GivePlayerHealth(playerid, 60);
  235.             }
  236.             else
  237.             {
  238.                 SetPlayerHealth(playerid, 100);
  239.             }
  240.         }
  241.         else
  242.         {
  243.             SendClientMessage(playerid, BLUE, "You need 4g of drugs to smoke weed.");
  244.         }
  245.  
  246.     }
  247.     if(strcmp(drugname, "heroine", true) == 0 || strcmp(drugname, "3", true) == 0)
  248.     {
  249.         if(PDrugs[playerid][pDrugs] >= 3)
  250.         {
  251.             SetPlayerWeather(playerid, -66);
  252.             SetPlayerDrunkLevel(playerid, 4500);
  253.             SetPlayerTime(playerid,12,00);
  254.             GameTextForPlayer(playerid, "~r~The drug effect will be gone in a minute", 3000, 5);
  255.             IsHigh[playerid] = 1;
  256.             PDrugs[playerid][pDrugs] -= 3;
  257.             SaveUserDrugStats(playerid);
  258.             SendClientMessage(playerid, WHITE, "You injected 3g of heroine into your veins.");
  259.             SetTimer("IsHighTimer", 120000, false);
  260.             if(PHealth <= 50)
  261.             {
  262.                 GivePlayerHealth(playerid, 50);
  263.             }
  264.             else
  265.             {
  266.                 SetPlayerHealth(playerid, 100);
  267.             }
  268.         }
  269.         else
  270.         {
  271.             SendClientMessage(playerid, BLUE, "You need 3g of drugs to inject heroine.");
  272.         }
  273.     }
  274.     if(strcmp(drugname, "opium", true) == 0 || strcmp(drugname, "4", true) == 0)
  275.     {
  276.         if(PDrugs[playerid][pDrugs] >= 2)
  277.         {
  278.             SetPlayerWeather(playerid, -66);
  279.             SetPlayerDrunkLevel(playerid, 4500);
  280.             SetPlayerTime(playerid,12,00);
  281.             GameTextForPlayer(playerid, "~r~The drug effect will be gone in a minute", 3000, 5);
  282.             IsHigh[playerid] = 1;
  283.             PDrugs[playerid][pDrugs] -= 2;
  284.             SaveUserDrugStats(playerid);
  285.             SendClientMessage(playerid, WHITE, "You took a pipe from your pocket and you started smoking Opium.");
  286.             SetTimer("IsHighTimer", 120000, false);
  287.             if(PHealth <= 30)
  288.             {
  289.                 GivePlayerHealth(playerid, 30);
  290.             }
  291.             else if(PHealth >= 70)
  292.             {
  293.                 SetPlayerHealth(playerid, 100);
  294.             }
  295.             else if(PHealth > 30)
  296.             {
  297.                 GivePlayerHealth(playerid, 30);
  298.             }
  299.         }
  300.         else
  301.         {
  302.             SendClientMessage(playerid, BLUE, "You need 2g of drugs to smoke Opium.");
  303.         }
  304.     }
  305.     if(strcmp(drugname, "meth", true) == 0 || strcmp(drugname, "5", true) == 0)
  306.     {
  307.         if(PDrugs[playerid][pDrugs] >= 1)
  308.         {
  309.             SetPlayerWeather(playerid, -66);
  310.             SetPlayerDrunkLevel(playerid, 4500);
  311.             SetPlayerTime(playerid,12,00);
  312.             GameTextForPlayer(playerid, "~r~The drug effect will be gone in a minute", 3000, 5);
  313.             IsHigh[playerid] = 1;
  314.             PDrugs[playerid][pDrugs] -= 1;
  315.             SaveUserDrugStats(playerid);
  316.             SendClientMessage(playerid, WHITE, "You snorted 1g of Meth Powder.");
  317.             SetTimer("IsHighTimer", 120000, false);
  318.             if(PHealth <= 15)
  319.             {
  320.                 GivePlayerHealth(playerid, 15);
  321.             }
  322.             else if(PHealth >= 85)
  323.             {
  324.                 SetPlayerHealth(playerid, 100);
  325.             }
  326.             else if(PHealth > 15)
  327.             {
  328.                 GivePlayerHealth(playerid, 15);
  329.             }
  330.         }
  331.         else
  332.         {
  333.             SendClientMessage(playerid, BLUE, "You need 1g of Meth to snort Meth Powder.");
  334.         }
  335.     }
  336.     return 1;
  337. }
  338.  
  339. CMD:mydrugs(playerid, params[])
  340. {
  341.     new pdrg = PDrugs[playerid][pDrugs];
  342.     new dprice = DRUG_GRAM_PRICE;
  343.     new dfee = pdrg * DRUG_DEALER_FEE;
  344.     new dworth = pdrg * dprice - dfee;
  345.     new dstr[150];
  346.     format(dstr, sizeof(dstr), "{FFFFCC}Drugs: {00FF00}%d{FFFFCC}g\n{FFFFCC}Drugs worth: {00FF00}$%d", PDrugs[playerid][pDrugs], dworth);
  347.     ShowPlayerDialog(playerid, MY_DRUGS_MENU, DIALOG_STYLE_MSGBOX,"{006600}Your drug stats:", dstr, "Ok", "");
  348.     return 1;
  349. }
  350.  
  351. CMD:setdrugs(playerid, params[])
  352. {
  353.     new fstr[200];
  354.     new damount, id;
  355.     if(sscanf(params, "ud", id, damount)) return SendClientMessage(playerid, RED, "[USAGE]: /setdrugs [player id] [amount]");
  356.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid, RED, "Player not found.");
  357.     if(IsPlayerAdmin(playerid))
  358.     {
  359.         PDrugs[id][pDrugs] = damount;
  360.         PlayerPlaySound(id,1085,0.0,0.0,0.0);
  361.         format(fstr, sizeof(fstr), "You have set %s [%d] drug amount to {00FF00}%d{FFFFFF}.", GetName(id), id, damount);
  362.         SendClientMessage(playerid, WHITE, fstr);
  363.         format(fstr, sizeof(fstr), "Admin %s [%d] has set your drug amount to {00FF00}%d{FFFFFF}.", GetName(playerid), playerid, damount);
  364.         SendClientMessage(id, WHITE, fstr);
  365.         SaveUserDrugStats(id);
  366.     }
  367.     else
  368.     {
  369.         SendClientMessage(playerid, RED, "You don't have the permission to acces this command!");
  370.     }
  371.     return true;
  372. }
  373.  
  374. CMD:givedrugs(playerid, params[])
  375. {
  376.     new fstr[200], fstr2[80];
  377.     new damount, id;
  378.     if(sscanf(params, "ud", id, damount)) return SendClientMessage(playerid, RED, "[USAGE]: /givedrugs [player id] [amount]");
  379.     format(fstr2, sizeof(fstr2), "%s [%d] is not close enough.", GetName(id), id);
  380.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid, RED, "Player not found.");
  381.     if(!ProxDetectorS(5.0, playerid, id)) return SendClientMessage(playerid, RED, fstr2);
  382.     if(PDrugs[playerid][pDrugs] >= damount)
  383.     {
  384.         PDrugs[id][pDrugs] += damount;
  385.         PDrugs[playerid][pDrugs] -= damount;
  386.         PlayerPlaySound(id,1085,0.0,0.0,0.0);
  387.         format(fstr, sizeof(fstr), "You have given %s [%d] {00FF00}%d{FFFFFF} drug grams.", GetName(id), id, damount);
  388.         SendClientMessage(playerid, WHITE, fstr);
  389.         format(fstr, sizeof(fstr), "%s [%d] has given you {00FF00}%d{FFFFFF} grams of drugs.", GetName(playerid), playerid, damount);
  390.         SendClientMessage(id, WHITE, fstr);
  391.         SaveUserDrugStats(id);
  392.         SaveUserDrugStats(playerid);
  393.     }
  394.     else
  395.     {
  396.         SendClientMessage(playerid, RED, "You don't have enough grams of drugs!");
  397.     }
  398.     return true;
  399. }
  400.  
  401. CMD:selldrugs(playerid, params[])
  402. {
  403.     new fstr[200], fstr2[200], fstr3[64];
  404.     new damount, id;
  405.     if(sscanf(params, "ud", id, damount)) return SendClientMessage(playerid, RED, "[USAGE]: /selldrugs [player id] [amount]");
  406.     format(fstr3, sizeof(fstr3), "%s [%d] is not close enough", GetName(id), id);
  407.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid, RED, "Player not found.");
  408.     if(!ProxDetectorS(5.0, playerid, id)) return SendClientMessage(playerid, RED, fstr3);
  409.     if(id == playerid) return SendClientMessage(playerid, RED, "You can't sell drugs to yourself!");
  410.     if(damount > 0 && damount <= 500)
  411.     {
  412.         if(PDrugs[playerid][pDrugs] >= damount)
  413.         {
  414.             new dworth = damount * ddprice;
  415.             PlayerPlaySound(id,1085,0.0,0.0,0.0);
  416.             format(fstr, sizeof(fstr), "You offered %s [%d] {00FF00}%d{FFFFFF} grams of drugs for {00FF00}%d{FFFFFF}, wait until they accept the deal.", GetName(id), id, damount, dworth);
  417.             SendClientMessage(playerid, WHITE, fstr);
  418.             format(fstr, sizeof(fstr), "%s [%d] wants to sell {00FF00}%d{FFFFFF} grams of drugs to you for {00FF00}%d{FFFFFF}.", GetName(playerid), playerid, damount, dworth);
  419.             SendClientMessage(id, WHITE, fstr);
  420.             format(fstr2, sizeof(fstr2), "Type {0099CC}/acceptdrugs  %d{FFFFFF} to accept the deal, the command will expire in {CC0000}45 seconds{FFFFFF}.", playerid);
  421.             SendClientMessage(id, WHITE, fstr2);
  422.             SetTimer("DealTimer", 45000, false);
  423.             Deal[id] = 1;
  424.             Deal[playerid] = 1;
  425.             DDAmount[playerid] = damount;
  426.         }
  427.         else
  428.         {
  429.             SendClientMessage(playerid, RED, "You don't have enough grams of drugs!");
  430.         }
  431.     }
  432.     else
  433.     {
  434.         SendClientMessage(playerid, RED, "You need to insert an amount between 1 and 500!");
  435.     }
  436.     return true;
  437. }
  438.  
  439. CMD:acceptdrugs(playerid, params[])
  440. {
  441.     new msg[200], msg2[128], msg3[64];
  442.     new id;
  443.     if(sscanf(params, "u", id)) return SendClientMessage(playerid, RED, "[USAGE]: /acceptdrugs [dealer id]");
  444.     format(msg3, sizeof(msg3), "%s [%d] is not close enough", GetName(id), id);
  445.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid, RED, "Dealer not found.");
  446.     if(!ProxDetectorS(5.0, playerid, id)) return SendClientMessage(playerid, RED, msg3);
  447.     new pcash = GetPlayerMoney(playerid);
  448.     new dworth = DDAmount[id] * ddprice;
  449.     if(pcash >= dworth)
  450.     {
  451.         if(Deal[playerid] == 1 && Deal[id] == 1)
  452.         {
  453.             PDrugs[playerid][pDrugs] += DDAmount[id];
  454.             PDrugs[id][pDrugs] -= DDAmount[id];
  455.             GivePlayerMoney(id, dworth);
  456.             GivePlayerMoney(playerid, - dworth);
  457.             format(msg, sizeof(msg), "You sold {00FF00}%d{FFFFFF} grams of drugs to %s [%d] for {00FF00}$%d{FFFFFF}.", DDAmount[id], GetName(playerid), playerid, dworth);
  458.             SendClientMessage(id, WHITE, msg);
  459.             format(msg2, sizeof(msg2), "You bought {00FF00}%d{FFFFFF} grams of drugs from %s [%d] for {00FF00}$%d{FFFFFF}.", DDAmount[id], GetName(id), id, dworth);
  460.             SendClientMessage(playerid, WHITE, msg2);
  461.             Deal[id] = 0;
  462.             Deal[playerid] = 0;
  463.             SaveUserDrugStats(id);
  464.             SaveUserDrugStats(playerid);
  465.         }
  466.         else
  467.         {
  468.             SendClientMessage(playerid, RED, "That dealer hasn't offered you any drugs!");
  469.         }
  470.     }
  471.     else
  472.     {
  473.         SendClientMessage(playerid, RED, "You don't have enough cash!");
  474.     }
  475.     return true;
  476. }
  477.  
  478. CMD:agivedrugs(playerid, params[])
  479. {
  480.     new fstr[200];
  481.     new damount, id;
  482.     if(sscanf(params, "ud", id, damount)) return SendClientMessage(playerid, RED, "[USAGE]: /agivedrugs [player id] [amount]");
  483.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid, RED, "Player not found.");
  484.     if(IsPlayerAdmin(playerid))
  485.     {
  486.         PDrugs[id][pDrugs] += damount;
  487.         PlayerPlaySound(id,1085,0.0,0.0,0.0);
  488.         format(fstr, sizeof(fstr), "You have given %s [%d] {00FF00}%d{FFFFFF} drug grams.", GetName(id), id, damount);
  489.         SendClientMessage(playerid, WHITE, fstr);
  490.         format(fstr, sizeof(fstr), "Admin %s [%d] has given you {00FF00}%d{FFFFFF} grams of drugs.", GetName(playerid), playerid, damount);
  491.         SendClientMessage(id, WHITE, fstr);
  492.         SaveUserDrugStats(id);
  493.     }
  494.     else
  495.     {
  496.         SendClientMessage(playerid, RED, "You don't have the permission to acces this command!");
  497.     }
  498.     return true;
  499. }
  500.  
  501. CMD:checkdrugs(playerid, params[])
  502. {
  503.     new id;
  504.     if(sscanf(params, "u", id)) return SendClientMessage(playerid, RED, "[USAGE]: /checkdrugs [player id]");
  505.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid, RED, "Player not found.");
  506.     if(IsPlayerAdmin(playerid))
  507.     {
  508.         new pdrg = PDrugs[id][pDrugs];
  509.         new dprice = DRUG_GRAM_PRICE;
  510.         new dfee = pdrg * DRUG_DEALER_FEE;
  511.         new dworth = pdrg * dprice - dfee;
  512.         new dstr[150], dstrt[48];
  513.         format(dstr, sizeof(dstr), "{FFFFCC}Drugs: {00FF00}%d{FFFFCC}g\n{FFFFCC}Drugs worth: {00FF00}$%d", PDrugs[id][pDrugs], dworth);
  514.         format(dstrt, sizeof(dstrt), "{006600}%s's [%d] drug stats:", GetName(id), id);
  515.         ShowPlayerDialog(playerid, MY_DRUGS_MENU, DIALOG_STYLE_MSGBOX, dstrt, dstr, "Ok", "");
  516.     }
  517.     else
  518.     {
  519.          SendClientMessage(playerid, RED, "You don't have the permission to acces this command!");
  520.     }
  521.     return true;
  522. }
  523.  
  524. CMD:drugcmds(playerid, params[])
  525. {
  526.     if(IsPlayerAdmin(playerid))
  527.     {
  528.         new dstr[1024];
  529.         format(dstr, sizeof(dstr), "{FFFFCC}Commands: \n/buydrugs - Buy drugs. Price: {00FF00}$%d{FFFFCC}/g\n/usedrugs - Use the drugs you have\n/mydrugs - See how much drugs you have and how much are they worth on the streets\n/givedrugs - Give drugs to another player\n/selldrugs - Sell drugs to another player\n/acceptdrugs - Accept a drug dealer's offer\n/setdrugs\n/agivedrugs\n/checkdrugs", DRUG_GRAM_PRICE);
  530.         ShowPlayerDialog(playerid, MY_DRUGS_MENU, DIALOG_STYLE_MSGBOX,"{006600}Drug System Commands:", dstr, "Ok", "");
  531.     }
  532.     else
  533.     {
  534.         new dstr[1024];
  535.         format(dstr, sizeof(dstr), "{FFFFCC}Commands: \n/buydrugs - Buy drugs. Price: {00FF00}$%d{FFFFCC}/g\n/usedrugs - Use the drugs you have\n/mydrugs - See how much drugs you have and how much are they worth on the streets\n/givedrugs - Give drugs to another player\n/selldrugs - Sell drugs to another player\n/acceptdrugs - Accept a drug dealer's offer", DRUG_GRAM_PRICE);
  536.         ShowPlayerDialog(playerid, MY_DRUGS_MENU, DIALOG_STYLE_MSGBOX,"{006600}Drug System Commands:", dstr, "Ok", "");
  537.     }
  538.     return true;
  539. }
  540.  
  541. stock SaveUserDrugStats(playerid)
  542. {
  543.     if(IsPlayerConnected(playerid))
  544.     {
  545.         new playerName[MAX_PLAYER_NAME];
  546.         GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
  547.         new file[40];
  548.         format(file, sizeof(file), USER_FILE, playerName);
  549.         new INI:ufile = INI_Open(file);
  550.         INI_SetTag(ufile, "general");
  551.         INI_WriteString(ufile, "pName", playerName);
  552.         INI_WriteInt(ufile, "pDrugs",  PDrugs[playerid][pDrugs]);
  553.         INI_Close(ufile);
  554.     }
  555.     return 1;
  556. }
  557.  
  558. forward LoadDrugData_general(playerid, name[], value[]);
  559. public LoadDrugData_general(playerid, name[], value[])
  560. {
  561.     INI_Int("pName", PDrugs[playerid][pName]);
  562.     INI_Int("pDrugs", PDrugs[playerid][pDrugs]);
  563.     return 1;
  564. }
  565.  
  566. forward IsHighTimer(playerid);
  567. public IsHighTimer(playerid)
  568. {
  569.     IsHigh[playerid] = 0;
  570.     SetPlayerWeather(playerid, 1);
  571.     SetPlayerDrunkLevel(playerid, 0);
  572. }
  573.  
  574. forward DealTimer(playerid);
  575. public DealTimer(playerid)
  576. {
  577.     Deal[playerid] = 0;
  578. }
  579.  
  580. forward ProxDetectorS(Float:radi, playerid, targetid);
  581. public ProxDetectorS(Float:radi, playerid, targetid)
  582. {
  583.     if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
  584.     {
  585.         new Float:posx, Float:posy, Float:posz;
  586.         new Float:oldposx, Float:oldposy, Float:oldposz;
  587.         new Float:tempposx, Float:tempposy, Float:tempposz;
  588.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  589.         GetPlayerPos(targetid, posx, posy, posz);
  590.         tempposx = (oldposx -posx);
  591.         tempposy = (oldposy -posy);
  592.         tempposz = (oldposz -posz);
  593.         if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  594.         {
  595.             return 1;
  596.         }
  597.     }
  598.     return 0;
  599. }
  600.  
  601.  
  602. stock DrugAmountIsNumeric(const string[])
  603. {
  604.     new i;
  605.     while(string[i] != '\0') //end of string
  606.     {
  607.         if (string[i] > '9' || string[i] < '0'){return 0;}
  608.         i++;
  609.     }
  610.     return 1;
  611. }
  612.  
  613. stock GivePlayerHealth(playerid,Float:Health)
  614. {
  615.     new Float:health; GetPlayerHealth(playerid,health);
  616.     SetPlayerHealth(playerid,health+Health);
  617. }
  618.  
  619. stock GetName(playerid)
  620. {
  621.     new Name[24];
  622.     GetPlayerName(playerid, (Name), sizeof(Name));
  623.     return Name;
  624. }
  625.  
  626. stock DrugFilePath(playerid)
  627. {
  628.     new string[128],playername[MAX_PLAYER_NAME];
  629.     GetPlayerName(playerid,playername,sizeof(playername));
  630.     format(string,sizeof(string),USER_FILE,playername);
  631.     return string;
  632. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement