Advertisement
Guest User

by andmeida10

a guest
Oct 18th, 2012
1,226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.47 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. //--------------Porta Malas-----------------
  4. new PortaMalasNome[MAX_VEHICLES][6][128];
  5. new PortaMalasIdent[MAX_VEHICLES][6];
  6. new PortaMalasQuant[MAX_VEHICLES][6];
  7. new bool: PortaMalasUsado[MAX_VEHICLES][6];
  8.  
  9. /*
  10. Sistema de Informacao do Player:
  11.  
  12.     PI[playerid][pInfo] (para quem conhece GodFather: PlayerInfo[playerid][pInfo])
  13. */
  14.    
  15.  
  16.  
  17.  
  18. public OnPlayerCommandText(playerid, cmdtext[])
  19. {
  20.  
  21. // ---------------- Porta Malas---------------------------
  22.     if(strcmp(cmd, "/portamalas", true) == 0)
  23.         {
  24.        
  25.         new vehicleid = GetNearestVehicle(playerid, 10);
  26.        
  27.         new Float: Pos[3];
  28.        
  29.         GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]);
  30.        
  31.         if(vehicleid == 0)// se GetNearestVehicle n encontrar nenhum, a funcao retorna 0, dai essa linha ai :D
  32.             return Aviso(playerid, "Nenhum veiculo perto de você");
  33.        
  34.         tmp = strtok(cmdtext, idx);
  35.         if(strlen(tmp) == 0)
  36.             return Aviso(playerid, "USO: /portamalas [colocar/retirar/ver]");  
  37.        
  38.         new text[52];
  39.         strmid(text, tmp, 0, strlen(tmp));
  40.        
  41.         new engine,lights,alarm,doors,bonnet,boot,objective;
  42.         GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  43.         SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,1,objective);
  44.        
  45.         if(strcmp(text, "colocar", true) == 0)
  46.             {
  47.            
  48.             tmp = strtok(cmdtext, idx);
  49.            
  50.             new slotlivre, slotsusados;
  51.             for(new slotid = 0; slotid < 6; slotid ++)
  52.                 {
  53.                 if(PortaMalasUsado[vehicleid][slotid] == false)
  54.                     {
  55.                     slotlivre = slotid;
  56.                     goto colocar_next;
  57.                     }
  58.                 if(PortaMalasUsado[vehicleid][slotid] == true)
  59.                     {
  60.                     slotsusados++;
  61.                     }
  62.                 }
  63.            
  64.             colocar_next:
  65.             if(slotsusados == 6)
  66.                 {
  67.                 Aviso(playerid, "Porta Malas Cheio");
  68.                
  69.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  70.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  71.                 return 1;
  72.                 }
  73.            
  74.             if(strlen(tmp) == 0)
  75.                 {
  76.                 Aviso(playerid, "USO: /portamalas Colocar [Drogas/Materiais/Arma]");
  77.                
  78.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  79.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  80.                 return 1;
  81.                 }
  82.            
  83.             new Coloca[52];
  84.             strmid(Coloca, tmp, 0, strlen(tmp));
  85.            
  86.             if(strcmp(Coloca, "Drogas", true) == 0)
  87.                 {
  88.                 if(PI[playerid][pDrogas] == 0)
  89.                     {
  90.                     Aviso(playerid, "Você não tem Drogas");
  91.                    
  92.                     GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  93.                     SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  94.                     return 1;
  95.                     }
  96.                    
  97.                 tmp = strtok(cmdtext, idx);
  98.                 if(strlen(tmp) == 0)
  99.                     {
  100.                     Aviso(playerid, "USO: /portamalas Colocar Drogas [quantidade]");
  101.                    
  102.                     GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  103.                     SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  104.                     return 1;
  105.                     }
  106.                    
  107.                 new quant;
  108.                 quant = strval(tmp);
  109.                
  110.                 if(quant > PI[playerid][pDrogas])
  111.                     {
  112.                     Aviso(playerid, "Você não tem essas drogas no Bolso");
  113.                    
  114.                     GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  115.                     SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  116.                     return 1;
  117.                     }
  118.                
  119.                 PI[playerid][pDrogas] -= quant;
  120.                 PortaMalasQuant[vehicleid][slotlivre] += quant;
  121.                
  122.                 PortaMalasNome[vehicleid][slotlivre] = "Drogas";
  123.                 PortaMalasIdent[vehicleid][slotlivre] = 0;
  124.                 PortaMalasUsado[vehicleid][slotlivre] = true;
  125.                
  126.                 format(string, sizeof(string), "Você Depositou %s Drogas. O veiculo tem agora %s", quant, PortaMalasQuant[vehicleid][slotlivre]);
  127.                 SendClientMessage(playerid, 0xEE82EEFF, string);
  128.                
  129.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  130.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  131.                 return 1;
  132.                 }
  133.            
  134.             if(strcmp(Coloca, "Materiais", true) == 0)
  135.                 {
  136.                
  137.                 if(PI[playerid][pMaterial] == 0)
  138.                     {
  139.                     Aviso(playerid, "Você não tem Materiais");
  140.                    
  141.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  142.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  143.                 return 1;
  144.                 }
  145.                    
  146.                 tmp = strtok(cmdtext, idx);
  147.                 if(strlen(tmp) == 0)
  148.                     {
  149.                     Aviso(playerid, "USO: /portamalas Colocar Materiais [quantidade]");
  150.                    
  151.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  152.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  153.                 return 1;
  154.                 }
  155.                    
  156.                 new quant;
  157.                 quant = strval(tmp);
  158.                
  159.                 if(quant > PI[playerid][pMaterial])
  160.                     {
  161.                     Aviso(playerid, "Você não tem essas drogas no Bolso");
  162.                    
  163.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  164.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  165.                 return 1;
  166.                 }
  167.                
  168.                 PI[playerid][pMaterial] -= quant;
  169.                 PortaMalasQuant[vehicleid][slotlivre] += quant;
  170.                
  171.                 PortaMalasNome[vehicleid][slotlivre] = "Materiais";
  172.                 PortaMalasIdent[vehicleid][slotlivre] = 0;
  173.                 PortaMalasUsado[vehicleid][slotlivre] = true;
  174.                
  175.                 format(string, sizeof(string), "Você Depositou %s Materiais. O veiculo tem agora %s", quant, PortaMalasQuant[vehicleid][slotlivre]);
  176.                 SendClientMessage(playerid, 0xEE82EEFF, string);
  177.                
  178.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  179.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  180.                 return 1;
  181.                 }
  182.                
  183.             if(strcmp(Coloca, "Arma", true) == 0)
  184.                 {
  185.                
  186.                 tmp = strtok(cmdtext, idx);
  187.                 if(strlen(tmp) == 0)
  188.                     {
  189.                     Aviso(playerid, "USO: /portamalas Colocar Arma");
  190.                    
  191.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  192.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  193.                 return 1;
  194.                 }
  195.                
  196.                 new colArma = GetPlayerWeapon(playerid);
  197.                 if(colArma < 16)
  198.                     {
  199.                     Aviso(playerid, "Você nao pode guardar essa arma");
  200.                    
  201.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  202.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  203.                 return 1;
  204.                 }
  205.                    
  206.                 new ammo = GetPlayerAmmo(playerid);
  207.                    
  208.                 SetPlayerAmmo(playerid, colArma, 0);//Remove a Arma
  209.                
  210.                 PortaMalasNome[vehicleid][slotlivre] = "Arma";
  211.                 PortaMalasIdent[vehicleid][slotlivre] = colArma;
  212.                 PortaMalasQuant[vehicleid][slotlivre] = ammo;
  213.                 PortaMalasUsado[vehicleid][slotlivre] = true;
  214.                
  215.                 new nomearma[32];
  216.                 GetWeaponName(colArma, nomearma, sizeof(nomearma));
  217.                
  218.                 format(string, sizeof(string), "Você colocou %d balas de %s", ammo, nomearma);
  219.                 SendClientMessage(playerid, 0xEE82EEFF, string);
  220.                
  221.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  222.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);            
  223.                 return 1;
  224.                 }
  225.            
  226.            
  227.             return 1;
  228.             }
  229.        
  230.         if(strcmp(text, "retirar", true) == 0)
  231.             {
  232.            
  233.             tmp = strtok(cmdtext, idx);
  234.             if(strlen(tmp) == 0)
  235.                 {
  236.                 Aviso(playerid, "USO: /portamalas Retirar [Slot]");
  237.                
  238.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  239.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  240.                 return 1;
  241.                 }
  242.            
  243.             new slotid;
  244.             slotid = strval(tmp);
  245.            
  246.             if(slotid < 0 || slotid > 5)
  247.                 {
  248.                 Aviso(playerid, "Slot entre 0 e 5");
  249.                
  250.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  251.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  252.                 return 1;
  253.                 }
  254.  
  255.             if(PortaMalasUsado[vehicleid][slotid] == false)
  256.                 {
  257.                 Aviso(playerid, "Slot Vazio");
  258.                
  259.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  260.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  261.                 return 1;
  262.                 }
  263.            
  264.                
  265.             if(strcmp(PortaMalasNome[vehicleid][slotid], "Drogas", true) == 0)
  266.                 {
  267.                 PI[playerid][pDrogas] += PortaMalasQuant[vehicleid][slotid];
  268.                
  269.                 format(string, sizeof(string), "Você retirou %d drogas do veiculo", PortaMalasQuant[vehicleid][slotid]);
  270.                 SendClientMessage(playerid, 0xFF8C69FF, string);
  271.                
  272.                 PortaMalasNome[vehicleid][slotid] = " ";
  273.                 PortaMalasIdent[vehicleid][slotid] = 0;
  274.                 PortaMalasQuant[vehicleid][slotid] = 0;
  275.                 PortaMalasUsado[vehicleid][slotid]  = false;
  276.                
  277.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  278.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  279.                 return 1;
  280.                 }
  281.                
  282.             if(strcmp(PortaMalasNome[vehicleid][slotid], "Materiais", true) == 0)
  283.                 {
  284.                 PI[playerid][pMaterial] += PortaMalasQuant[vehicleid][slotid];
  285.                
  286.                 format(string, sizeof(string), "Você retirou %d materiais do veiculo", PortaMalasQuant[vehicleid][slotid]);
  287.                 SendClientMessage(playerid, 0xFF8C69FF, string);
  288.                
  289.                 PortaMalasNome[vehicleid][slotid] = " ";
  290.                 PortaMalasIdent[vehicleid][slotid] = 0;
  291.                 PortaMalasQuant[vehicleid][slotid] = 0;
  292.                 PortaMalasUsado[vehicleid][slotid]  = false;
  293.                
  294.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  295.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  296.                 return 1;
  297.                 }
  298.                
  299.             if(strcmp(PortaMalasNome[vehicleid][slotid], "Arma", true) == 0)
  300.                 {
  301.                 GivePlayerWeapon(playerid, PortaMalasIdent[vehicleid][slotid], PortaMalasQuant[vehicleid][slotid]);
  302.                
  303.                 new ArmaName[32];
  304.                 GetWeaponName(PortaMalasIdent[vehicleid][slotid], ArmaName, sizeof(ArmaName));
  305.                
  306.                 format(string, sizeof(string), "Você retirou uma %s com %d balas", ArmaName, PortaMalasQuant[vehicleid][slotid]);
  307.                 SendClientMessage(playerid, 0xFF8C69FF, string);
  308.                
  309.                 PortaMalasNome[vehicleid][slotid] = " ";
  310.                 PortaMalasIdent[vehicleid][slotid] = 0;
  311.                 PortaMalasQuant[vehicleid][slotid] = 0;
  312.                 PortaMalasUsado[vehicleid][slotid]  = false;
  313.                
  314.                 GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  315.                 SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  316.                 return 1;
  317.                 }
  318.  
  319.             return 1;
  320.             }
  321.        
  322.         if(strcmp(text, "ver", true) == 0)
  323.             {
  324.            
  325.             new slotid = 0;
  326.            
  327.             while(slotid < 6)
  328.                 {
  329.                 if(PortaMalasUsado[vehicleid][slotid] == true)
  330.                     {
  331.                     new Name[52];
  332.                     strmid(Name, PortaMalasNome[vehicleid][slotid], 0, strlen(PortaMalasNome[vehicleid][slotid]));
  333.                    
  334.                     if(strcmp(Name, "Arma", true) == 0)
  335.                         {
  336.                         new armaName[32];
  337.                         GetWeaponName(PortaMalasIdent[vehicleid][slotid], armaName, sizeof(armaName));
  338.                         format(string, sizeof(string), "Slot %d: %s %s : %d Balas", slotid, PortaMalasNome[vehicleid][slotid], armaName, PortaMalasQuant[vehicleid][slotid]);
  339.                         SendClientMessage(playerid, 0xF0FFFFFF, string);
  340.                         }
  341.                        
  342.                     else if(strcmp(Name, "Materiais", true) == 0)
  343.                         {
  344.                         format(string, sizeof(string), "Slot %d: %s : %d Materiais", slotid, PortaMalasNome[vehicleid][slotid], PortaMalasQuant[vehicleid][slotid]);
  345.                         SendClientMessage(playerid, 0xF0FFFFFF, string);
  346.                         }
  347.                        
  348.                     else if(strcmp(Name, "Drogas", true) == 0)
  349.                         {
  350.                         format(string, sizeof(string), "Slot %d: %s : %d Drogas", slotid, PortaMalasNome[vehicleid][slotid], PortaMalasQuant[vehicleid][slotid]);
  351.                         SendClientMessage(playerid, 0xF0FFFFFF, string);
  352.                         }
  353.                     }
  354.                
  355.                
  356.                 slotid++;
  357.                 }
  358.            
  359.            
  360.             GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  361.             SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
  362.             return 1;
  363.             }
  364.        
  365.        
  366.        
  367.        
  368.        
  369.         return 1;
  370.         }
  371.  
  372.        
  373.        
  374.     return 1;//Fim Public OnPlayerCommandText
  375. }
  376.  
  377.  
  378.  
  379. stock GetNearestVehicle(playerid, Float:range)//Creditos a alguem do Forum SAMP, n lembro o nome
  380. {
  381.     new     Float:p_X;
  382.     new     Float:p_Y;
  383.     new     Float:p_Z;
  384.  
  385.     new     Float:Distance;
  386.     new     Float:PretendentDistance = range +1;
  387.     new     Pretendent;
  388.  
  389.     GetPlayerPos(playerid, p_X, p_Y, p_Z);
  390.  
  391.     for(new vehicleid=1; vehicleid < MAX_VEHICLES; vehicleid++)
  392.     {
  393.         Distance = GetVehicleDistanceFromPoint(vehicleid, p_X, p_Y, p_Z);
  394.  
  395.         if(Distance <= range && Distance <= PretendentDistance)
  396.         {
  397.             Pretendent = vehicleid;
  398.             PretendentDistance = Distance;
  399.         }
  400.     }
  401.  
  402.     return Pretendent;
  403. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement