SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 10/08/2012, 12:28 AM   #1
davi54723
Gangsta
 
Join Date: Jul 2012
Posts: 916
Reputation: 10
Default Porta-malas

Olá galera, estou com um [FS] aqui, só que preciso de ajuda.
Ele funciona corretamente só que quero melhorar ele, mais não sei como.

Oque eu quero é, quando digitar /portamalas vai abrir o porta malas, quando forem pega as arma o porta malas fecha.
Igual /portamalas(abre)
/portamalas colocararma(abre, depois de um tempo fecha)
/portamalas pegararma(abre depois de um tempo fecha)

Comandos: - Porta-Malas -

Comandos:

/portamalas
/portamalas info
/portamalas colocararma
/portamalas pegararma
/portamalas colocarcolete
/portamalas pegarcolete



[FS]:
Code:
#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(playerid, cmdtext[])
{
	new cmd[128], idx, string[128];
	cmd = strtok(cmdtext, idx);

    if(!strcmp(cmd, "/portamalas", true))
	{
	    new x_nr[64], pname[20];
		x_nr = strtok(cmdtext, idx);

		GetPlayerName(playerid, pname, sizeof(pname));

		if(!strlen(x_nr))
		{
			SendClientMessage(playerid, WHITE, "DICA: /portamalas [name]");
   			SendClientMessage(playerid, WHITE, "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; i != MAX_VEHICLES; i++)
		    {
      			new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
      			if(dist)
      			{
      				result = i;
      				counter++;
      			}
		    }

			switch(counter)
		    {
      			case 0:
				{
      				SendClientMessage(playerid, GREY, "Nenhum carro com o porta malas perto de você");
				}

				case 1:
				{
    				if(IsPlayerInAnyVehicle(playerid))
					{
    					SendClientMessage(playerid, GREY, "  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(playerid, LIGHTBLUE, "|_______ Porta-Malas _______|");
					for(new slot = 1; slot != MAX_TRUNK_SLOTS; slot++)
					{
	    				new gunname[100];
	    				if(vehTrunk[result][slot] != 0)
					    {
	        				GetWeaponName(vehTrunk[result][slot], gunname, sizeof(gunname));
					        format(string, sizeof(string), "| Slot %i: %s (Munição: %i)", slot, gunname, vehTrunkAmmo[result][slot]);
					        SendClientMessage(playerid, WHITE, string);
					    }
					    else
					    {
	        				format(string, sizeof(string), "| Slot %i: Livre (Munição: N/A)", slot);
	        				SendClientMessage(playerid, WHITE, string);
					    }
					}

					format(string, sizeof(string), "| Colete: %f%", vehTrunkArmour[result]);
					SendClientMessage(playerid, WHITE, string);

					format(string, sizeof(string), "* %s abre o porta-malas e checa o que há dentro.", pname);
   					ProxDetector(30.0, playerid, string, CHAT1, CHAT1, CHAT1, CHAT1, CHAT1);

					return 1;
 				}

				default:
    			{
       				SendClientMessage(playerid, GREY, "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; i != MAX_VEHICLES; i++)
   			{
      			new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
      			if(dist)
      			{
      				result = i;
      				counter++;
      			}
		    }

			switch(counter)
			{
   				case 0:
   				{
   					SendClientMessage(playerid, GREY, "Nenhum carro com o Porta-Malas perto de você");
   				}

				case 1:
    			{
       				if(vehTrunkCounter[result] != (MAX_TRUNK_SLOTS-1))
       				{
				   		if(IsPlayerInAnyVehicle(playerid))
         				{
             				SendClientMessage(playerid, GREY, "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 != 0 && gunAmmo != 0)
						{
							GetWeaponName(gunID, gunname, sizeof(gunname));
       						vehTrunkCounter[result]++;
       						vehTrunk[result][vehTrunkCounter[result]] = gunID;
       						vehTrunkAmmo[result][vehTrunkCounter[result]] = gunAmmo;

	   						format(buffer, sizeof(buffer), "Você colocou um(a) %s (Munição: %i) no porta-malas do carro.", gunname, gunAmmo);
       						SendClientMessage(playerid, WHITE, buffer);

	   						RemovePlayerWeapon(playerid, gunID);

							format(string, sizeof(string), "* %s Abre o porta-mala do carro e coloca uma arma lá.", pname);
       						ProxDetector(30.0, playerid, string, CHAT1, CHAT1, CHAT1, CHAT1, CHAT1);
       						return 1;
             			}
	            	}
		            else
		            {
              			SendClientMessage(playerid, GREY, "porta-mala do carro está cheio");
              			return 1;
		            }
				}

				default:
    			{
       				SendClientMessage(playerid, GREY, "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; i != MAX_VEHICLES; i++)
   			{
   				new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
   				if(dist)
   				{
   					result = i;
   					counter++;
   				}
   			}

			switch(counter)
   			{
      			case 0:
      			{
      				SendClientMessage(playerid, GREY, "Nenhum carro com porta-malas perto de você!");
      				return 1;
      			}

				case 1:
    			{
       				if(IsPlayerInAnyVehicle(playerid))
       				{
       					SendClientMessage(playerid, GREY, " 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(playerid, vehTrunk[result][vehTrunkCounter[result]], vehTrunkAmmo[result][vehTrunkCounter[result]]);

						GetWeaponName(vehTrunk[result][vehTrunkCounter[result]], gunName, sizeof(gunName));

						format(buffer, sizeof(buffer), "Voce retirou um(a) %s (Ammo: %i) do veículo.", gunName, vehTrunkAmmo[result][vehTrunkCounter[result]]);
      					SendClientMessage(playerid, WHITE, buffer);

						vehTrunk[result][vehTrunkCounter[result]] = '\0';
      					vehTrunkAmmo[result][vehTrunkCounter[result]] = '\0';
      					vehTrunkCounter[result]--;

						format(string, sizeof(string), "* %s Abre A mala do carro e Retirar uma arma.", pname);
      					ProxDetector(30.0, playerid, string, CHAT1, CHAT1, CHAT1, CHAT1, CHAT1);
      					return 1;
      				}
          			else
           			{
              			SendClientMessage(playerid, GREY, "porta-mala está vazio! ");
              			return 1;
		            }
      			}

				default:
    			{
       				SendClientMessage(playerid, GREY, "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; i != MAX_VEHICLES; i++)
   			{
      			new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
      			if(dist)
      			{
      				result = i;
      				counter++;
      			}
			}

			switch(counter)
   			{
				case 0:
    			{
       				SendClientMessage(playerid, GREY, "Nenhum carro com o porta-malas perto de você");
       				return 1;
       			}

				case 1:
				{
    				if(IsPlayerInAnyVehicle(playerid))
        			{
           				SendClientMessage(playerid, GREY, "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(playerid, plyArmour);

					if(plyArmour != 0)
					{
     					SafeSetPlayerArmour(playerid, 0);
          				vehTrunkArmour[result] = plyArmour;

						format(string, sizeof(string), "* %s Retira seu colete do corpo e coloca no porta-mala.", pname);
      					ProxDetector(30.0, playerid, string, CHAT1, CHAT1, CHAT1, CHAT1, CHAT1);
           				return 1;
       				}
       				else
           			{
           				SendClientMessage(playerid, GREY, " Você não tem nenhum Coletes à prova de bala");
           				return 1;
		            }
  				}

				default:
    			{
       				SendClientMessage(playerid, GREY, "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; i != MAX_VEHICLES; i++)
	    	{
      			new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
      			if(dist)
      			{
      				result = i;
      				counter++;
  				}
		    }

			switch(counter)
   			{
      			case 0:
      			{
      				SendClientMessage(playerid, GREY, "Nenhum carro com o porta-malas perto de você");
      				return 1;
      			}

				case 1:
    			{
       				if(IsPlayerInAnyVehicle(playerid))
       				{
       					SendClientMessage(playerid, GREY, "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(playerid, vehTrunkArmour[result]);
         				vehTrunkArmour[result] = 0;

						format(string, sizeof(string), "* %s Retira o Coletes à prova de bala do porta-malas.", pname);
						ProxDetector(30.0, playerid, string, CHAT1, CHAT1, CHAT1, CHAT1, CHAT1);
						return 1;
      				}
          			else
	            	{
             			SendClientMessage(playerid, GREY, "Não há nenhuma Coletes à prova de bala no porta-mala! ");
             			return 1;
		            }
		        }

				default:
    			{
    				SendClientMessage(playerid, GREY, "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; i != MAX_VEHICLES; i++)
			    {
       				new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
  	    			if(dist)
      				{
     					result = i;
      					counter++;
      				}
    			}

				switch(counter)
   				{
   					case 0:
   					{
   						SendClientMessage(playerid, GREY, "Nenhum carro com o Porto-Malas perto de você");
   					}

					case 1:
					{
    					if(IsPlayerInAnyVehicle(playerid))
						{
    						SendClientMessage(playerid, GREY, "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(playerid, LIGHTBLUE, "|_______ Porta-Malas _______|");

						for(new slot = 1; slot != MAX_TRUNK_SLOTS; slot++)
						{
		    				new gunname[100];
		    				if(vehTrunk[result][slot] != 0)
		    				{
      							GetWeaponName(vehTrunk[result][slot], gunname, sizeof(gunname));

		 						format(string, sizeof(string), "| Slot %i: %s (Munição: %i)", slot, gunname, vehTrunkAmmo[result][slot]);
 								SendClientMessage(playerid, WHITE, string);
	    					}
					    	else
					    	{
	        					format(string, sizeof(string), "| Slot %i: Livre (Munição: N/A)", slot);
	        					SendClientMessage(playerid, WHITE, string);
					    	}
						}

						format(string, sizeof(string), "| Colete: %f%", vehTrunkArmour[result]);
						SendClientMessage(playerid, WHITE, string);

						format(string, sizeof(string), "* %s abre o porta-malas e checa o que há dentro.", pname);
    					ProxDetector(30.0, playerid, string, CHAT1, CHAT1, CHAT1, CHAT1, CHAT1);
						return 1;
     				}

					default:
					{
						SendClientMessage(playerid, GREY, "Foi encontrado mais de um carro na área.");
						return 1;
					}
   				}
			}
			else
			{
				SendClientMessage(playerid, GREY, "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:radi, playerid, vehicleid)
{
	if(IsPlayerConnected(playerid))
	{
	    new Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z;
	    GetPlayerPos(playerid,PX,PY,PZ);
	    GetVehiclePos(vehicleid, X,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:radi, playerid, string[],col1,col2,col3,col4,col5);
public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
	if(IsPlayerConnected(playerid))
	{
		new Float:posx, Float:posy, Float:posz;
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		//radi = 2.0; //Trigger Radius
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
			{
				if(!BigEar[i])
				{
					GetPlayerPos(i, posx, posy, posz);
					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(i, col1, string);
					}
					else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
					{
						SendClientMessage(i, col2, string);
					}
					else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
					{
						SendClientMessage(i, col3, string);
					}
					else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
					{
						SendClientMessage(i, col4, string);
					}
					else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
					{
						SendClientMessage(i, col5, string);
					}
				}
				else
				{
					SendClientMessage(i, col1, string);
				}
			}
		}
	}//not connected
	return 1;
}

forward RemovePlayerWeapon(playerid, weaponid);
public RemovePlayerWeapon(playerid, weaponid)
{
	new plyWeapons[12] = 0;
	new plyAmmo[12] = 0;
	for(new slot = 0; slot != 12; slot++)
	{
		new wep, ammo;
		GetPlayerWeaponData(playerid, slot, wep, ammo);

		if(wep != weaponid && ammo != 0)
		{
			GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]);
		}
	}

	SafeResetPlayerWeapons(playerid);
	for(new slot = 0; slot != 12; slot++)
	{
	    if(plyAmmo[slot] != 0)
	    {
			SafeGivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot]);
		}
	}
	return 1;
}

forward SafeGivePlayerWeapon(plyid, weaponid, ammo);
public SafeGivePlayerWeapon(plyid, weaponid, ammo)
{
	new curHour, curMinute, curSecond;
	gettime(curHour, curMinute, curSecond);
	ScriptWeaponsUpdated[plyid] = 1;
	GivePlayerWeapon(plyid, weaponid, ammo);
	UpdateWeaponSlots(plyid);
	return 1;
}

forward SafeSetPlayerArmour(playerid, Float:armour);
public SafeSetPlayerArmour(playerid, Float:armour)
{
	SetPlayerArmour(playerid, armour);
	return 1;
}

forward SafeResetPlayerWeapons(plyid);
public SafeResetPlayerWeapons(plyid)
{
	new curHour, curMinute, curSecond;
	gettime(curHour, curMinute, curSecond);
	ScriptWeaponsUpdated[plyid] = 1;
	ResetPlayerWeapons(plyid);
	UpdateWeaponSlots(plyid);
	return 1;
}

forward split(const strsrc[], strdest[][], delimiter);
public split(const strsrc[], strdest[][], delimiter)
{
	new i, li;
	new aNum;
	new len;
	while(i <= strlen(strsrc)){
	    if(strsrc[i]==delimiter || i==strlen(strsrc)){
	        len = strmid(strdest[aNum], strsrc, li, i, 128);
	        strdest[aNum][len] = 0;
	        li = i+1;
	        aNum++;
		}
		i++;
	}
	return 1;
}

forward UpdateWeaponSlots(plyid);
public UpdateWeaponSlots(plyid)
{
	new weaponid, ammo;
	for (new i=0; i<13; i++)
	{
		GetPlayerWeaponData(plyid, i, weaponid, ammo);
		ScriptWeapons[plyid][i] = weaponid;
	}
	ScriptWeaponsUpdated[plyid] = 0;
	return 1;
}
davi54723 is offline   Reply With Quote
Old 10/08/2012, 12:39 AM   #2
Adriano_MQD
Big Clucker
 
Join Date: Mar 2012
Posts: 170
Reputation: 18
Default Re: Porta-malas

http://wiki.sa-mp.com/wiki/SetVehicleParamsEx
__________________

*Projetos*

[Map] Garagem em LS
Adriano_MQD is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS]Porta-malas Quarda Armas e Colete brunogysin Lançamentos/Releases 20 28/07/2011 11:26 PM
[ajuda]porta-malas brunogysin Português/Portuguese 3 09/06/2010 08:32 PM
[ajuda] Porta Malas brunogysin Português/Portuguese 7 09/06/2010 12:42 AM
[Ajuda]Porta do SV Flavinho153 Português/Portuguese 4 09/04/2010 09:07 PM


All times are GMT. The time now is 04:04 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.