[Pedido] Sistema de Porta Malas
#1

Olha eu tenho um sistema de porta malas aqui, mas so tem como pegar e retirar armas e colete, queria adicionar materiais para o player pode colocar e retirar materiais do porta malas, QUERIA muito que vocкs me ajudasse jб tentei fazer isso de varias formas e nгo consegui

O cуdigo do porta malas completo '-' >>
PHP код:
#include <a_samp>
#if defined MAX_VEHICLES
    #undef     MAX_VEHICLES
    #define MAX_VEHICLES 700 //change to your vehicles number
#endif
#if defined MAX_PLAYERS
    #undef     MAX_PLAYERS
    #define MAX_PLAYERS 50 //change to your player slot number
#endif
#define GREY                 0xAFAFAFAA
#define WHITE                  0xFFFFFFAA
#define CHAT1                 0xF9B7FFAA
#define LIGHTBLUE             0xA9C4E4FF
#define MAX_TRUNK_SLOTS     5 // trunk slots
new vehTrunkCounter[MAX_VEHICLES] = 1;
new 
vehTrunk[MAX_VEHICLES][MAX_TRUNK_SLOTS];
new 
vehTrunkAmmo[MAX_VEHICLES][MAX_TRUNK_SLOTS];
new 
Float:vehTrunkArmour[MAX_VEHICLES];
new 
BigEar[MAX_PLAYERS];
new 
ScriptWeaponsUpdated[MAX_PLAYERS];
new 
ScriptWeapons[MAX_PLAYERS][13];
public 
OnPlayerCommandText(playeridcmdtext[])
{
    new 
cmd[128], idxstring[128];
    
cmd strtok(cmdtextidx);
    if(!
strcmp(cmd"/portamalas"true))
    {
        new 
x_nr[64], pname[20];
        
x_nr strtok(cmdtextidx);
        
GetPlayerName(playeridpnamesizeof(pname));
        if(!
strlen(x_nr))
        {
            
SendClientMessage(playeridWHITE"DICA: /portamalas [name]");
               
SendClientMessage(playeridWHITE"nomes Disponнvel: info, colocararma, pegararma, colocarcolete, pegarcolete");
            
/*if(IsPlayerAdmin(playerid))
            {
                  SendClientMessage(playerid, WHITE, "Vocк pode revistar '/portamalas frisk' como um administrador.");
            }*/
              
return 1;
        }
        if(
strcmp(x_nr,"info",true) == 0)
        {
              new 
counter 0;
              new 
result;
            for(new 
i!= MAX_VEHICLESi++)
            {
                  new 
dist CheckPlayerDistanceToVehicle(3.5playeridi);
                  if(
dist)
                  {
                      
result i;
                      
counter++;
                  }
            }
            switch(
counter)
            {
                  case 
0:
                {
                      
SendClientMessage(playeridGREY"Nenhum carro com o porta malas perto de vocк");
                }
                case 
1:
                {
                    if(
IsPlayerInAnyVehicle(playerid))
                    {
                        
SendClientMessage(playeridGREY"  Vocк nгo pode abrir o porta malas, enquanto vocк estб no carro");
                           return 
1;
                    }
                     
/*if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 440 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 456 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 498)
                      {
                        SendClientMessage(playerid, GREY, "  This vehicle doesn't have the trunk !");
                        return 1;
                    }*/
                    
SendClientMessage(playeridLIGHTBLUE"|_______ Porta-Malas _______|");
                    for(new 
slot 1slot != MAX_TRUNK_SLOTSslot++)
                    {
                        new 
gunname[100];
                        if(
vehTrunk[result][slot] != 0)
                        {
                            
GetWeaponName(vehTrunk[result][slot], gunnamesizeof(gunname));
                            
format(stringsizeof(string), "| Slot %i: %s (Muniзгo: %i)"slotgunnamevehTrunkAmmo[result][slot]);
                            
SendClientMessage(playeridWHITEstring);
                        }
                        else
                        {
                            
format(stringsizeof(string), "| Slot %i: Livre (Muniзгo: N/A)"slot);
                            
SendClientMessage(playeridWHITEstring);
                        }
                    }
                    
format(stringsizeof(string), "| Colete: %f%"vehTrunkArmour[result]);
                    
SendClientMessage(playeridWHITEstring);
                    
format(stringsizeof(string), "* %s abre o porta-malas e checa o que hб dentro."pname);
                       
ProxDetector(30.0playeridstringCHAT1CHAT1CHAT1CHAT1CHAT1);
                    return 
1;
                 }
                default:
                {
                       
SendClientMessage(playeridGREY"Foi encontrado mais de um carro na бrea.");
                       return 
1;
                   }
            }
            return 
1;
        }
        else if(!
strcmp(x_nr,"colocararma",true))
        {
              new 
counter 0;
              new 
result;
            for(new 
i!= MAX_VEHICLESi++)
               {
                  new 
dist CheckPlayerDistanceToVehicle(3.5playeridi);
                  if(
dist)
                  {
                      
result i;
                      
counter++;
                  }
            }
            switch(
counter)
            {
                   case 
0:
                   {
                       
SendClientMessage(playeridGREY"Nenhum carro com o Porta-Malas perto de vocк");
                   }
                case 
1:
                {
                       if(
vehTrunkCounter[result] != (MAX_TRUNK_SLOTS-1))
                       {
                           if(
IsPlayerInAnyVehicle(playerid))
                         {
                             
SendClientMessage(playeridGREY"Vocк nгo pode abrir o Porta-Malas, enquanto vocк estб no carro");
                             return 
1;
                        }
                        
/*if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 440 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 456 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 498)
                          {
                            SendClientMessage(playerid, GREY, "  This vehicle doesn't have the trunk !");
                            return 1;
                        }*/
                        
new buffer[512];
                          new 
gunname[100];
                          new 
gunID GetPlayerWeapon(playerid);
                          new 
gunAmmo GetPlayerAmmo(playerid);
                        if(
gunID != && gunAmmo != 0)
                        {
                            
GetWeaponName(gunIDgunnamesizeof(gunname));
                               
vehTrunkCounter[result]++;
                               
vehTrunk[result][vehTrunkCounter[result]] = gunID;
                               
vehTrunkAmmo[result][vehTrunkCounter[result]] = gunAmmo;
                               
format(buffersizeof(buffer), "Vocк colocou um(a) %s (Muniзгo: %i) no porta-malas do carro."gunnamegunAmmo);
                               
SendClientMessage(playeridWHITEbuffer);
                               
RemovePlayerWeapon(playeridgunID);
                            
format(stringsizeof(string), "* %s Abre o porta-mala do carro e coloca uma arma lб."pname);
                               
ProxDetector(30.0playeridstringCHAT1CHAT1CHAT1CHAT1CHAT1);
                               return 
1;
                         }
                    }
                    else
                    {
                          
SendClientMessage(playeridGREY"porta-mala do carro estб cheio");
                          return 
1;
                    }
                }
                default:
                {
                       
SendClientMessage(playeridGREY"Foi encontrado mais de um carro na Яrea.");
                       return 
1;
                   }
             }
            return 
1;
        }
        else if(
strcmp(x_nr,"pegararma",true) == 0)
        {
              new 
counter 0;
              new 
result;
            for(new 
i!= MAX_VEHICLESi++)
               {
                   new 
dist CheckPlayerDistanceToVehicle(3.5playeridi);
                   if(
dist)
                   {
                       
result i;
                       
counter++;
                   }
               }
            switch(
counter)
               {
                  case 
0:
                  {
                      
SendClientMessage(playeridGREY"Nenhum carro com porta-malas perto de vocк!");
                      return 
1;
                  }
                case 
1:
                {
                       if(
IsPlayerInAnyVehicle(playerid))
                       {
                           
SendClientMessage(playeridGREY" Vocк nгo pode abrir o porta-malas de dentro do carro.");
                           return 
1;
                       }
                    
/*if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 440 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 456 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 498)
                      {
                        SendClientMessage(playerid, GREY, "  This vehicle doesn't have the trunk !");
                        return 1;
                    }*/
                    
if(vehTrunkCounter[result] != 0)
                     {
                         new 
buffer[512];
                           new 
gunName[100];
                        
SafeGivePlayerWeapon(playeridvehTrunk[result][vehTrunkCounter[result]], vehTrunkAmmo[result][vehTrunkCounter[result]]);
                        
GetWeaponName(vehTrunk[result][vehTrunkCounter[result]], gunNamesizeof(gunName));
                        
format(buffersizeof(buffer), "Voce retirou um(a) %s (Ammo: %i) do veнculo."gunNamevehTrunkAmmo[result][vehTrunkCounter[result]]);
                          
SendClientMessage(playeridWHITEbuffer);
                        
vehTrunk[result][vehTrunkCounter[result]] = '\0';
                          
vehTrunkAmmo[result][vehTrunkCounter[result]] = '\0';
                          
vehTrunkCounter[result]--;
                        
format(stringsizeof(string), "* %s Abre A mala do carro e Retirar uma arma."pname);
                          
ProxDetector(30.0playeridstringCHAT1CHAT1CHAT1CHAT1CHAT1);
                          return 
1;
                      }
                      else
                       {
                          
SendClientMessage(playeridGREY"porta-mala estб vazio! ");
                          return 
1;
                    }
                  }
                default:
                {
                       
SendClientMessage(playeridGREY"Foi encontrado mais de um carro na бrea.");
                       return 
1;
                   }
             }
            return 
1;
        }
        else if(
strcmp(x_nr,"colocarcolete",true) == 0)
        {
              new 
counter 0;
              new 
result;
            for(new 
i!= MAX_VEHICLESi++)
               {
                  new 
dist CheckPlayerDistanceToVehicle(3.5playeridi);
                  if(
dist)
                  {
                      
result i;
                      
counter++;
                  }
            }
            switch(
counter)
               {
                case 
0:
                {
                       
SendClientMessage(playeridGREY"Nenhum carro com o porta-malas perto de vocк");
                       return 
1;
                   }
                case 
1:
                {
                    if(
IsPlayerInAnyVehicle(playerid))
                    {
                           
SendClientMessage(playeridGREY"Vocк nгo pode abrir o porta-malas, enquanto vocк estб no carro");
                           return 
1;
                       }
                    
/*if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 440 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 456 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 498)
                      {
                        SendClientMessage(playerid, GREY, "  This vehicle doesn't have the trunk !");
                        return 1;
                    }*/
                    
new Float:plyArmour;
                    
GetPlayerArmour(playeridplyArmour);
                    if(
plyArmour != 0)
                    {
                         
SafeSetPlayerArmour(playerid0);
                          
vehTrunkArmour[result] = plyArmour;
                        
format(stringsizeof(string), "* %s Retira seu colete do corpo e coloca no porta-mala."pname);
                          
ProxDetector(30.0playeridstringCHAT1CHAT1CHAT1CHAT1CHAT1);
                           return 
1;
                       }
                       else
                       {
                           
SendClientMessage(playeridGREY" Vocк nгo tem nenhum Coletes а prova de bala");
                           return 
1;
                    }
                  }
                default:
                {
                       
SendClientMessage(playeridGREY"Foi encontrado mais de um carro na бrea.");
                       return 
1;
                   }
            }
               return 
1;
        }
        else if(
strcmp(x_nr,"pegarcolete",true) == 0)
        {
              new 
counter 0;
              new 
result;
              for(new 
i!= MAX_VEHICLESi++)
            {
                  new 
dist CheckPlayerDistanceToVehicle(3.5playeridi);
                  if(
dist)
                  {
                      
result i;
                      
counter++;
                  }
            }
            switch(
counter)
               {
                  case 
0:
                  {
                      
SendClientMessage(playeridGREY"Nenhum carro com o porta-malas perto de vocк");
                      return 
1;
                  }
                case 
1:
                {
                       if(
IsPlayerInAnyVehicle(playerid))
                       {
                           
SendClientMessage(playeridGREY"Vocк nгo pode abrir o Porta-Malas, enquanto vocк estб no carro");
                           return 
1;
                       }
                    
/*if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 440 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 456 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 498)
                      {
                        SendClientMessage(playerid, GREY, "  This vehicle doesn't have the trunk !");
                        return 1;
                    }*/
                    
if(vehTrunkArmour[result] != 0)
                     {
                         
SafeSetPlayerArmour(playeridvehTrunkArmour[result]);
                         
vehTrunkArmour[result] = 0;
                        
format(stringsizeof(string), "* %s Retira o Coletes а prova de bala do porta-malas."pname);
                        
ProxDetector(30.0playeridstringCHAT1CHAT1CHAT1CHAT1CHAT1);
                        return 
1;
                      }
                      else
                    {
                         
SendClientMessage(playeridGREY"Nгo hб nenhuma Coletes а prova de bala no porta-mala! ");
                         return 
1;
                    }
                }
                default:
                {
                    
SendClientMessage(playeridGREY"Foi encontrado mais de um carro na бrea.");
                    return 
1;
                }
            }
            return 
1;
        }
        else if(
strcmp(x_nr,"olhar",true) == 0)
        {
              if(
IsPlayerAdmin(playerid))
              {
                 new 
counter 0;
                new 
result;
                for(new 
i!= MAX_VEHICLESi++)
                {
                       new 
dist CheckPlayerDistanceToVehicle(3.5playeridi);
                      if(
dist)
                      {
                         
result i;
                          
counter++;
                      }
                }
                switch(
counter)
                   {
                       case 
0:
                       {
                           
SendClientMessage(playeridGREY"Nenhum carro com o Porto-Malas perto de vocк");
                       }
                    case 
1:
                    {
                        if(
IsPlayerInAnyVehicle(playerid))
                        {
                            
SendClientMessage(playeridGREY"Vocк nгo pode abrir o porta-malas, enquanto vocк estб no carro");
                               return 
1;
                          }
                        
/*if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 440 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 456 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 498)
                          {
                            SendClientMessage(playerid, GREY, "  This vehicle doesn't have the trunk !");
                            return 1;
                        }*/
                        
SendClientMessage(playeridLIGHTBLUE"|_______ Porta-Malas _______|");
                        for(new 
slot 1slot != MAX_TRUNK_SLOTSslot++)
                        {
                            new 
gunname[100];
                            if(
vehTrunk[result][slot] != 0)
                            {
                                  
GetWeaponName(vehTrunk[result][slot], gunnamesizeof(gunname));
                                 
format(stringsizeof(string), "| Slot %i: %s (Muniзгo: %i)"slotgunnamevehTrunkAmmo[result][slot]);
                                 
SendClientMessage(playeridWHITEstring);
                            }
                            else
                            {
                                
format(stringsizeof(string), "| Slot %i: Livre (Muniзгo: N/A)"slot);
                                
SendClientMessage(playeridWHITEstring);
                            }
                        }
                        
format(stringsizeof(string), "| Colete: %f%"vehTrunkArmour[result]);
                        
SendClientMessage(playeridWHITEstring);
                        
format(stringsizeof(string), "* %s abre o porta-malas e checa o que hб dentro."pname);
                        
ProxDetector(30.0playeridstringCHAT1CHAT1CHAT1CHAT1CHAT1);
                        return 
1;
                     }
                    default:
                    {
                        
SendClientMessage(playeridGREY"Foi encontrado mais de um carro na бrea.");
                        return 
1;
                    }
                   }
            }
            else
            {
                
SendClientMessage(playeridGREY"Vocк nгo й um administrador!");
                return 
1;
            }
               return 
1;
        }
        return 
1;
    }
    return 
0;
}
strtok(const string[], &index)
{
    new 
length strlen(string);
    while ((
index length) && (string[index] <= ' '))
    {
        
index++;
    }
    new 
offset index;
    new 
result[20];
    while ((
index length) && (string[index] > ' ') && ((index offset) < (sizeof(result) - 1)))
    {
        
result[index offset] = string[index];
        
index++;
    }
    
result[index offset] = EOS;
    return 
result;
}
stock CheckPlayerDistanceToVehicle(Float:radiplayeridvehicleid)
{
    if(
IsPlayerConnected(playerid))
    {
        new 
Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z;
        
GetPlayerPos(playerid,PX,PY,PZ);
        
GetVehiclePos(vehicleidX,Y,Z);
        new 
Float:Distance = (X-PX)*(X-PX)+(Y-PY)*(Y-PY)+(Z-PZ)*(Z-PZ);
        if(
Distance <= radi*radi)
        {
            return 
1;
        }
    }
    return 
0;
}
forward ProxDetector(Float:radiplayeridstring[],col1,col2,col3,col4,col5);
public 
ProxDetector(Float:radiplayeridstring[],col1,col2,col3,col4,col5)
{
    if(
IsPlayerConnected(playerid))
    {
        new 
Float:posxFloat:posyFloat:posz;
        new 
Float:oldposxFloat:oldposyFloat:oldposz;
        new 
Float:tempposxFloat:tempposyFloat:tempposz;
        
GetPlayerPos(playeridoldposxoldposyoldposz);
        
//radi = 2.0; //Trigger Radius
        
for(new 0MAX_PLAYERSi++)
        {
            if(
IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
            {
                if(!
BigEar[i])
                {
                    
GetPlayerPos(iposxposyposz);
                    
tempposx = (oldposx -posx);
                    
tempposy = (oldposy -posy);
                    
tempposz = (oldposz -posz);
                    
//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
                    
if (((tempposx radi/16) && (tempposx > -radi/16)) && ((tempposy radi/16) && (tempposy > -radi/16)) && ((tempposz radi/16) && (tempposz > -radi/16)))
                    {
                        
SendClientMessage(icol1string);
                    }
                    else if (((
tempposx radi/8) && (tempposx > -radi/8)) && ((tempposy radi/8) && (tempposy > -radi/8)) && ((tempposz radi/8) && (tempposz > -radi/8)))
                    {
                        
SendClientMessage(icol2string);
                    }
                    else if (((
tempposx radi/4) && (tempposx > -radi/4)) && ((tempposy radi/4) && (tempposy > -radi/4)) && ((tempposz radi/4) && (tempposz > -radi/4)))
                    {
                        
SendClientMessage(icol3string);
                    }
                    else if (((
tempposx radi/2) && (tempposx > -radi/2)) && ((tempposy radi/2) && (tempposy > -radi/2)) && ((tempposz radi/2) && (tempposz > -radi/2)))
                    {
                        
SendClientMessage(icol4string);
                    }
                    else if (((
tempposx radi) && (tempposx > -radi)) && ((tempposy radi) && (tempposy > -radi)) && ((tempposz radi) && (tempposz > -radi)))
                    {
                        
SendClientMessage(icol5string);
                    }
                }
                else
                {
                    
SendClientMessage(icol1string);
                }
            }
        }
    }
//not connected
    
return 1;
}
forward RemovePlayerWeapon(playeridweaponid);
public 
RemovePlayerWeapon(playeridweaponid)
{
    new 
plyWeapons[12] = 0;
    new 
plyAmmo[12] = 0;
    for(new 
slot 0slot != 12slot++)
    {
        new 
wepammo;
        
GetPlayerWeaponData(playeridslotwepammo);
        if(
wep != weaponid && ammo != 0)
        {
            
GetPlayerWeaponData(playeridslotplyWeapons[slot], plyAmmo[slot]);
        }
    }
    
SafeResetPlayerWeapons(playerid);
    for(new 
slot 0slot != 12slot++)
    {
        if(
plyAmmo[slot] != 0)
        {
            
SafeGivePlayerWeapon(playeridplyWeapons[slot], plyAmmo[slot]);
        }
    }
    return 
1;
}
forward SafeGivePlayerWeapon(plyidweaponidammo);
public 
SafeGivePlayerWeapon(plyidweaponidammo)
{
    new 
curHourcurMinutecurSecond;
    
gettime(curHourcurMinutecurSecond);
    
ScriptWeaponsUpdated[plyid] = 1;
    
GivePlayerWeapon(plyidweaponidammo);
    
UpdateWeaponSlots(plyid);
    return 
1;
}
forward SafeSetPlayerArmour(playeridFloat:armour);
public 
SafeSetPlayerArmour(playeridFloat:armour)
{
    
SetPlayerArmour(playeridarmour);
    return 
1;
}
forward SafeResetPlayerWeapons(plyid);
public 
SafeResetPlayerWeapons(plyid)
{
    new 
curHourcurMinutecurSecond;
    
gettime(curHourcurMinutecurSecond);
    
ScriptWeaponsUpdated[plyid] = 1;
    
ResetPlayerWeapons(plyid);
    
UpdateWeaponSlots(plyid);
    return 
1;
}
forward split(const strsrc[], strdest[][], delimiter);
public 
split(const strsrc[], strdest[][], delimiter)
{
    new 
ili;
    new 
aNum;
    new 
len;
    while(
<= strlen(strsrc)){
        if(
strsrc[i]==delimiter || i==strlen(strsrc)){
            
len strmid(strdest[aNum], strsrclii128);
            
strdest[aNum][len] = 0;
            
li i+1;
            
aNum++;
        }
        
i++;
    }
    return 
1;
}
forward UpdateWeaponSlots(plyid);
public 
UpdateWeaponSlots(plyid)
{
    new 
weaponidammo;
    for (new 
i=0i<13i++)
    {
        
GetPlayerWeaponData(plyidiweaponidammo);
        
ScriptWeapons[plyid][i] = weaponid;
    }
    
ScriptWeaponsUpdated[plyid] = 0;
    return 
1;

Reply
#2

Ops: Se me ajudar com as drogas tambйm ficaria grato!
Reply
#3

Alguem poderia me ajudar me mostrar o caminho por favor
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)