SHARE
TWEET

Untitled

a guest Dec 30th, 2011 161 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. */
  3. //==============================================================================
  4. #include <a_samp>
  5. #include <Dini>
  6. #include <foreach>
  7. //==============================================================================
  8. #pragma tabsize 0
  9. //==============================================================================
  10. #define MAX_WEED 5000 //Weed Limit
  11. //==============================================================================
  12. #define CHECKPOINT_NONE 0 //No Checkpoint
  13. //==============================================================================
  14. #define COLOR_GRAD1 0xB4B5B7FF
  15. #define COLOR_GRAD2 0xBFC0C2FF
  16. #define COLOR_GRAD3 0xCBCCCEFF
  17. #define COLOR_GRAD4 0xD8D8D8FF
  18. #define COLOR_GRAD5 0xE3E3E3FF
  19. #define COLOR_GRAD6 0xF0F0F0FF
  20. #define COLOR_GREY 0xAFAFAFAA
  21. //==============================================================================
  22. #define COLOR_FADE1 0xE6E6E6E6
  23. #define COLOR_FADE2 0xC8C8C8C8
  24. #define COLOR_FADE3 0xAAAAAAAA
  25. #define COLOR_FADE4 0x8C8C8C8C
  26. #define COLOR_FADE5 0x6E6E6E6E
  27. #define COLOR_PURPLE 0xC2A2DAAA
  28. //==============================================================================
  29. forward InitPlayer(playerid);
  30. forward SaveDrugs(playerid);
  31. forward LoadDrugs(playerid);
  32. forward ShowDrugs(playerid,targetid);
  33. forward WeedTimer();
  34. forward Plantation();
  35. forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
  36. forward TimerPlantou();
  37. //==============================================================================
  38. stock PlayerName(playerid)
  39. {
  40.       new name[MAX_PLAYER_NAME];
  41.       GetPlayerName(playerid, name, sizeof(name));
  42.       return name;
  43. }
  44. //==============================================================================
  45. strtok(const string[], &index)
  46. {
  47.     new length = strlen(string);
  48.     while ((index < length) && (string[index] <= ' '))
  49.     {
  50.         index++;
  51.     }
  52.  
  53.     new offset = index;
  54.     new result[20];
  55.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  56.     {
  57.         result[index - offset] = string[index];
  58.         index++;
  59.     }
  60.     result[index - offset] = EOS;
  61.     return result;
  62. }
  63. //==============================================================================
  64. GiveNameSpace(str[])
  65. {
  66.     new strl;
  67.     strl=strlen(str);
  68.     while(strl--) {
  69.     if(str[strl]=='_')  str[strl]=' ';
  70.     }
  71.     return 0;
  72. }
  73. //==============================================================================
  74. enum pInfo
  75. {
  76.      sWeed,
  77.      sSeeds
  78. };
  79. new PlayerInfo[MAX_PLAYERS][pInfo];
  80. //==============================================================================
  81. enum weedInfo
  82. {
  83.     WeedPlanter[MAX_PLAYER_NAME],
  84.     Float:WeedX,
  85.     Float:WeedY,
  86.     Float:WeedZ,
  87.     WeedTime,
  88.     WeedPlanted,
  89. };
  90. new WeedInfo[MAX_WEED][weedInfo];
  91. new WEEDS[MAX_PLAYERS];
  92. new WATER[MAX_PLAYERS];
  93. new WATERS[MAX_PLAYERS];
  94. new Weeder[MAX_PLAYERS];
  95. new weedObject[MAX_WEED];
  96. new plantou;
  97. //==============================================================================
  98. public TimerPlantou()
  99. {
  100.    plantou = 0;
  101.    return 1;
  102. }
  103. //==============================================================================
  104. public InitPlayer(playerid) {
  105.     PlayerInfo[playerid][sWeed] = 0;
  106.     WATERS[playerid] = 0;
  107.     WEEDS[playerid] = 0;
  108.     WATER[playerid] = 0;
  109.     Weeder[playerid] = 0;
  110.     return 1;
  111. }
  112. //==============================================================================
  113. public WeedTimer()
  114. {
  115.     foreach (Player,i)
  116.     {
  117.         if(Weeder[i] > 0)
  118.         {
  119.             Weeder[i] --;
  120.         }
  121.     }
  122.     return 1;
  123. }
  124. //==============================================================================
  125. public Plantation()
  126. {
  127.     for(new b = 0; b < sizeof(WeedInfo); b++)
  128.     {
  129.         if(WeedInfo[b][WeedTime] > 0 && WeedInfo[b][WeedPlanted] == 1)
  130.         {
  131.             WeedInfo[b][WeedTime] -= 1;
  132.         }
  133.     }
  134.     return 1;
  135. }
  136. //==============================================================================
  137. public OnFilterScriptInit()
  138. {
  139.     AddStaticPickup(1239, 2, 2454.9827,-1708.3074,13.613);
  140.     Create3DTextLabel("[/Comprar]",0xFF9F40FF,2454.9827,-1708.3074,13.613+0.75,20.0,0,1);
  141.     SetTimer("Plantation", 80000, 1);
  142.     CreateObject(3439,2542.60009766,-1587.80004883,22.00000000,0.00000000,0.00000000,0.00000000);
  143.  
  144.     {
  145.     print(" Scarface/Titanic's Drug System 2010         ");
  146.     return 1;
  147.     }
  148. }
  149. //==============================================================================
  150. public OnFilterScriptExit()
  151. {
  152.     return 1;
  153. }
  154. //==============================================================================
  155. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  156. {
  157.     if(IsPlayerInRangeOfPoint(playerid, radi, x, y, z))
  158.     {
  159.         return 1;
  160.     }
  161.     return 0;
  162. }
  163. //==============================================================================
  164. public SaveDrugs(playerid)
  165. {
  166.     if(IsPlayerConnected(playerid) == 1)
  167.     {
  168.         new string[64];
  169.         format(string, sizeof(string), "LARP/Drugs/%s.ini", PlayerName(playerid));
  170.  
  171.         if(dini_Create(string))
  172.         {
  173.             dini_IntSet(string, "Cannabis", PlayerInfo[playerid][sWeed]);
  174.         }
  175.     }
  176.     return 1;
  177. }
  178. //==============================================================================
  179. public LoadDrugs(playerid)
  180. {
  181.     new string2[64];
  182.     format(string2, sizeof(string2), "LARP/Drugs/%s.ini", PlayerName(playerid));
  183.     new playername2[MAX_PLAYER_NAME];
  184.     GetPlayerName(playerid, playername2, sizeof(playername2));
  185.     {
  186.  
  187.         PlayerInfo[playerid][sWeed] = dini_Int(string2,"Cannabis");
  188.     }
  189.     return 1;
  190. }
  191.  
  192. //==============================================================================
  193. public OnPlayerConnect(playerid)
  194. {
  195.     LoadDrugs(playerid);
  196.     ResetPlayerWeapons(playerid);
  197.     return 1;
  198. }
  199. //==============================================================================
  200. public OnPlayerDisconnect(playerid, reason)
  201. {
  202.     SaveDrugs(playerid);
  203.     ResetPlayerWeapons(playerid);
  204.     return 1;
  205. }
  206. //==============================================================================
  207. public OnPlayerCommandText(playerid, cmdtext[])
  208. {
  209.     new playername[MAX_PLAYER_NAME];
  210.     new tmp[256];
  211.     new string[64];
  212.     new cmd[256];
  213.     new idx;
  214.     new sendername[MAX_PLAYER_NAME];
  215.     cmd = strtok(cmdtext, idx);
  216. //==============================================================================
  217.     if(strcmp("/plantarsemente", cmd, true) == 0)
  218.      if (IsPlayerInRangeOfPoint(playerid, 5.0,2542.60009766,-1587.80004883,22.00000000))
  219.     {
  220.         tmp = strtok(cmdtext, idx);
  221.         if (!WEEDS[playerid]) return SendClientMessage(playerid, COLOR_GREY," Você não tem nenhuma semente.");
  222.         if (!WATER[playerid]) return SendClientMessage(playerid, COLOR_GREY," Você não tem água.");
  223.         if(plantou == 1) return SendClientMessage(playerid, COLOR_GREY, " Parece que alguem já plantou, aguarde mais um pouco."); // Começo do Comando
  224. plantou = 1;
  225.         if (strcmp("Cannabis", tmp, true) == 0)
  226.         {
  227.             for(new weed = 0; weed < sizeof(WeedInfo); weed++)
  228.             {
  229.                 if(WeedInfo[weed][WeedPlanted] == 0 && WeedInfo[weed][WeedTime] == 0)
  230.                 {
  231.                     if (GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, COLOR_GRAD2, "Você não deve estar dentro de um carro!");
  232.                     new Float:X,Float:Y,Float:Z;
  233.                     GetPlayerPos(playerid, X, Y, Z);
  234.                     GetPlayerName(playerid, playername, 24);
  235.                     ApplyAnimation(playerid, "BOMBER","BOM_Plant_In",4.0,0,0,0,0,0);
  236.                     weedObject[weed] = CreateObject(3409, X, Y, Z-2, 0, 0, 0);
  237.                     Weeder[playerid] = 120;
  238.                     WeedInfo[weed][WeedX] = X;
  239.                     WeedInfo[weed][WeedY] = Y;
  240.                     WeedInfo[weed][WeedZ] = Z;
  241.                     WeedInfo[weed][WeedTime] = 2;
  242.                     WeedInfo[weed][WeedPlanted] = 1;
  243.                     strmid(WeedInfo[weed][WeedPlanter], playername, 0, strlen(playername), 50);
  244.                     SendClientMessage(playerid,COLOR_FADE1,"Você plantou uma semente, espere 2 minutos para poder apanha-la.");
  245.                     SendClientMessage(playerid,COLOR_FADE1,"Lembre-se de apanhar a sua droga antes que alguem o faça!");
  246.                     WEEDS[playerid] = 0;
  247.                     WATER[playerid] = 0;
  248.                     SetTimer("TimerPlantou",300000,false);
  249.                     return 1;
  250.                 }
  251.             }
  252.         }
  253.         else SendClientMessage(playerid, COLOR_GRAD1,"Cmd certo: /plantarsemente");
  254.         return 1;
  255.     }
  256. //==============================================================================
  257.     if(strcmp(cmdtext, "/apanharcannabis", true)==0)
  258.     if (IsPlayerInRangeOfPoint(playerid, 5.0,2542.60009766,-1587.80004883,22.00000000))
  259.      {
  260.         for(new i = 0; i < sizeof(WeedInfo); i++)
  261.         {
  262.             if (PlayerToPoint(9.0,playerid,WeedInfo[i][WeedX],WeedInfo[i][WeedY],WeedInfo[i][WeedZ]))
  263.             {
  264.                 if(WeedInfo[i][WeedTime] > 0)
  265.                 {
  266.                     format(string, sizeof(string), "A planta ainda não está pronta. %d Minutos restantes até estar pronta", WeedInfo[i][WeedTime]);
  267.                     SendClientMessage(playerid,COLOR_GRAD1,string);
  268.                     return 1;
  269.                 }
  270.                 ApplyAnimation(playerid, "BOMBER","BOM_Plant_In",4.0,0,0,0,0,0);
  271.                 SendClientMessage(playerid,COLOR_GRAD2,"Você apanhou 20 gramas de cannabis.");
  272.                 PlayerInfo[playerid][sWeed] += 20;
  273.                 DestroyObject(weedObject[i]);
  274.                 WeedInfo[i][WeedX] = 0.0;
  275.                 WeedInfo[i][WeedY] = 0.0;
  276.                 WeedInfo[i][WeedZ] = 0.0;
  277.                 WeedInfo[i][WeedPlanted] = 0;
  278.                 strmid(WeedInfo[i][WeedPlanter], "[NONE]", 0, strlen("[NONE]"), 128);
  279.                 return 1;
  280.             }
  281.         }
  282.         return 1;
  283.     }
  284. //==============================================================================
  285.     if(strcmp(cmd, "/comprar", true) == 0) //
  286.     {
  287.         if(IsPlayerConnected(playerid))
  288.         {
  289.             if (PlayerToPoint(5.0, playerid, 2454.9827,-1708.3074,13.6137))
  290.             {
  291.                 new x_nr[256];
  292.                 x_nr = strtok(cmdtext, idx);
  293.                 if(!strlen(x_nr))
  294.                 {
  295.                     SendClientMessage(playerid, COLOR_FADE3, "USO: /comprar [ 1 / 2 ]");
  296.                     SendClientMessage(playerid, COLOR_FADE2, "|_______Drug Nest_______|");
  297.                     SendClientMessage(playerid, COLOR_FADE1, "| 1: Seed $10    2: Water $5");
  298.                     return 1;
  299.                 }
  300.                 if(strcmp(x_nr,"1",true) == 0 && GetPlayerMoney(playerid)>=10)
  301.                 {
  302.                 if(WEEDS[playerid] == 1)
  303.                     {
  304.                         SendClientMessage(playerid,COLOR_GREY,"Você já tem uma semente!");
  305.                         return 1;
  306.                     }
  307.                     GivePlayerMoney(playerid, - 10);
  308.                     SendClientMessage(playerid,COLOR_GRAD1,"[INFO]: Você comprou uma semente.");
  309.                     WEEDS[playerid] = 1;
  310.                 }
  311.                 else if(strcmp(x_nr,"2",true) == 0 && GetPlayerMoney(playerid)>=5)
  312.                 {
  313.                 if(WATER[playerid] == 1)
  314.                     {
  315.                         SendClientMessage(playerid,COLOR_GREY,"Você já tem água!");
  316.                         return 1;
  317.                     }
  318.                     GivePlayerMoney(playerid, - 5);
  319.                     SendClientMessage(playerid,COLOR_GRAD1,"[INFO]: Você comprou água.");
  320.                     WATER[playerid] = 1;
  321.                 } else {
  322.                     SendClientMessage(playerid,COLOR_GRAD2,"Você não tem tanto dinheiro!");
  323.                     return 1;
  324.                 }
  325.             }
  326.             else
  327.             {
  328.                 SendClientMessage(playerid, COLOR_GRAD3, "Você não está nas traseiras da casa do Ryder!");
  329.                 return 1;
  330.             }
  331.         }
  332.         return 1;
  333.     }
  334. //==============================================================================
  335.     if(strcmp(cmd, "/minhaerva", true) == 0)
  336.     {
  337.         if(IsPlayerConnected(playerid))
  338.         {
  339.         format(string, sizeof(string), "* %s abre a sua mala e olha lá para dentro.", sendername);
  340.         ShowDrugs(playerid,playerid);
  341.         }
  342.         return 1;
  343.     }
  344.     if(strcmp(cmd, "/savedrugs", true) == 0)
  345.     {
  346.         if(IsPlayerConnected(playerid))
  347.         {
  348.         GetPlayerName(playerid, playername, sizeof(playername));
  349.         format(string, sizeof(string), "LARP/Drugs/%s.ini", playername);
  350.         }
  351.         return 1;
  352.     }
  353.     return 0;
  354. }
  355. //==============================================================================
  356. public ShowDrugs(playerid,targetid)
  357. {
  358.     if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
  359.     {
  360.         new weed = PlayerInfo[targetid][sWeed];
  361.  
  362.  
  363.         new name[MAX_PLAYER_NAME];
  364.         GetPlayerName(targetid, name, sizeof(name));
  365.         GiveNameSpace(name);
  366.         new coordsstring[256];
  367.         format(coordsstring, sizeof(coordsstring),"___________________|Mala de %s  |___________________",name);
  368.         SendClientMessage(playerid, COLOR_GRAD2,coordsstring);
  369.         format(coordsstring, sizeof(coordsstring), "[Drogas]: Cannabis:[%d]", weed);
  370.         SendClientMessage(playerid, COLOR_GRAD1,coordsstring);
  371.     }
  372. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top