Jump to content
  • 0

Problema Trunk


Invizion

Question

Problema intalnita (descriere):Problema este ca functioneaza doar pe prima masina si apare la toate acelasi portbagaj.
Ero(area / rile) / warning-(ul / urile):
Liniile de cod / sursa / script-ul(obligatoriu):

CMD:bput(playerid, params[])
	{
    new const vehicleid = GetClosestVehicle( playerid );
    new const cID = vPersonal[vehicleid];
	if( !vPersonal[ vehicleid ] ) return 1;
	if( !CheckIfIsOwner( playerid, vehicleid ) ) return Server( playerid, "You aren't the Owner of this car!");

	for(new y=1; y < MAX_PCARS; y++)
	{
	new name[32], info2[256];
  	cartrunk[cID] = troaca[playerid][y];
    new model = GetVehicleModel(cartrunk[cID]);
    for(new t=0; t < 6; t++)
	{
	    if(IsPlayerInRangeOfVehicle(playerid, cartrunk[cID], 5.0))
		{
	    	tWeapon[cartrunk[cID]][t] = g_Weaps[t];
	    	tAmmo[cartrunk[cID]][t] = g_Ammo[t];
  }
	}
	if(IsPlayerConnected(playerid))
	{
			if(IsPlayerInRangeOfVehicle(playerid, cartrunk[cID], 5.0))
			{
				if(model!=448 && model!=461 && model!=462 && model!=463 && model!=468 && model!=471 && model!=481 && model!=509 && model!=510 && model!=521 && model!=522 && model!=523 && model!=581 && model!=586 && model!=481 && model!=509 && model!=510)
				{
					for(new t=0; t < 6; t++)
					{
						if(tWeapon[cartrunk[cID]][t] != 0)
						{
	 						GetWeaponName(tWeapon[cartrunk[cID]][t], name, sizeof(name));
							format(info2, sizeof(info2), "%s%d. %s\n", info2, t+1, name);
						}
						else
						{
						format(info2, sizeof(info2), "%s%d. Empty\n", info2, t+1);
						}
					}
					ShowPlayerDialog(playerid, DIALOG_BPUT, DIALOG_STYLE_LIST, "Trunk Weapon", info2, "Select", "Cancel");
				}
				else
				{
 				SendClientMessage(playerid, COLOR_YELLOW, "  This is vehicle not have trunk!");
				}
			}
  		}
	}
return 1;
}


Imagini / Video (optional):
Ati incercat sa rezolvati singur?: Codul de mai sus este exact ce am incercat.

 

cID = este idul masinii din baza de date.

Masinile cand sunt create asa

stock incarcaPersonale( playerid )
{
	for( new i; i < MAX_PCARS; ++i )
	{
	    if( !pVData[ i ][ cExist ] ) continue;
	    if( !strcmp( pData[ playerid ][ pNormalName ], pVData[ i ][ cOwner ], true ) )
	    {
     	   	troaca[playerid][i] = CreateVehicle(  pVData[ i ][ cModel ], pVData[ i ][ cLocation ][ 0 ], pVData[ i ][ cLocation ][ 1 ], pVData[ i ][ cLocation ][ 2 ], pVData[ i ][ cLocation ][ 3 ], pVData[ i ][ cColor1 ], pVData[ i ][ cColor2 ], -1 );
	        vPersonal[ troaca[playerid][i] ] = pVData [ i ][ cDBID ];
	        SetVehicleNumberPlate( troaca[playerid][i], pVData [ i ][ cPlate ] );
	        for( new comp; comp < 14; ++comp )
	        {
	             AddVehicleComponent( troaca[playerid][i] , pVData[ i ][ cMod ][ comp ] );
	        }
	    }
	}
	printf( "Loaded PCars for %s", pData[ playerid ][ pNormalName ] );
	return 1;
}

eu am gandit asa troaca[playerid] troaca = vehicleid --> playerid masina playerului iar i = masina cu nr 1..2...3....MAX_PCARS

si in functie la /bput 

cartrunk[cID] = troaca[playerid][y]; cartrunk[cid] portbagajul cu id masinii iar troaca masina playerului 1..2...3 etc..

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Incearca asa, nu garantez ca o sa mearaga. Si nu mai folosi "const" daca nu stii ce face.

CMD:bput( playerid, params[] )
{
    new vehicleid = GetClosestVehicle( playerid ), cID = vPersonal[vehicleid];
	if( !vPersonal[ vehicleid ] ) return true;
	if( !CheckIfIsOwner( playerid, vehicleid ) ) return Server( playerid, "You aren't the Owner of this car!");

	for( new y=1; y < MAX_PCARS; y++ )
	{
		new name[ 32 ], info2[ 256 ];
	  	cartrunk[ cID ] = troaca[ playerid ][ y ];
	    new model = GetVehicleModel( cartrunk[ cID ] );
	    for( new t=0; t < 6; t++ )
		{
		    if( IsPlayerInRangeOfVehicle( playerid, cartrunk[cID], 5.0 ) )
			{
		    	tWeapon[ cartrunk[ cID ] ][ t ] = g_Weaps[ t ];
		    	tAmmo[ cartrunk[ cID ] ][ t ] = g_Ammo[ t ];
		  	}
		}
		if( IsPlayerInRangeOfVehicle( playerid, cartrunk[cID], 5.0 ) )
		{
			if( model == 448 || model == 461 ||  model == 462 ||  model ==463 ||  model == 468 || model == 471 || model == 481 || model == 509 ||  model == 510 ||  model == 521 ||  model==522 ||  model==523 ||  model==581 ||  model==586 )
				return SendClientMessage(playerid, COLOR_YELLOW, "  This is vehicle not have trunk!" );

			for( new t=0; t < 6; t++ )
			{
				if( tWeapon[cartrunk[ cID ]][ t ] != 0 )
				{
					etWeaponName( tWeapon[ cartrunk[ cID ] ][ t ], name, sizeof( name ) );
					format( info2, sizeof( info2 ), "%s%d. %s\n", info2, t+1, name );
				}
				else format( info2, sizeof( info2 ), "%s%d. Empty\n", info2, t+1) ;
			}
			ShowPlayerDialog( playerid, DIALOG_BPUT, DIALOG_STYLE_LIST, "Trunk Weapon", info2, "Select", "Cancel" );
		}
	}
	return true;
}

 

Sinner.png

Link to comment
Share on other sites

  • 0
5 hours ago, Invizion said:

Acum functioneaza pe toate masinile care le cumperi deci e bine. Dar acuma problema e alta daca pun o arma intr-o masina apare pe toate masinile mele dar si pe a altui player.(PE SCURT O ARMA PUSA INTR-O MASINA APARE IN TOATE MASINILE PERSONALE DE PE SV).

Arată cum pui arma în mașină.

**********************************

Servicii Scripting de calitate:

*********************************

Future Project: ExpertGame

*********************************

Link to comment
Share on other sites

  • 0
if(dialogid == DIALOG_BPUT)
	{
	    if(response)
	    {
	        new vehicleid = GetClosestVehicle( playerid ), cID = vPersonal[vehicleid];
			if( !vPersonal[ vehicleid ] ) return true;
			if( !CheckIfIsOwner( playerid, vehicleid ) ) return Server( playerid, "You aren't the Owner of this car!");

			for( new y=1; y < MAX_PCARS; y++ )
			{
				new name[ 32 ], info2[ 256 ];
			  	cartrunk[ cID ] = troaca[ playerid ][ y ];
			    new model = GetVehicleModel( cartrunk[ cID ] );

				new gunid = GetPlayerWeapon(playerid);
				new ammo = GetPlayerAmmo(playerid);
	       
			if (listitem == 0 && gunid != 0)
			{
				if(IsPlayerInRangeOfVehicle(playerid, cartrunk[ cID ], 3.0))
				{
			    if(tWeapon[cartrunk[ cID ]][0] != 0)
				{
					SendClientMessage(playerid,COLOR_RED," There are already guns!");
					return 1;
				}
				if(gunid == 0)
				{
					SendClientMessage(playerid,COLOR_GREEN," First choose which weapons you want to put in the trunk");
					return 1;
				}
        		tWeapon[cartrunk[ cID ]][0] = gunid;
				tAmmo[cartrunk[ cID ]][0] = ammo;
    			RemovePlayerWeaponT(playerid,gunid);
				RemovePlayerFromVehicle(playerid);
				SendClientMessage(playerid,COLOR_GREEN," You have successfully put your weapon in the trunk");
				}
			}
			if (listitem == 1 && gunid != 0)
			{
				if(IsPlayerInRangeOfVehicle(playerid, cartrunk[ cID ], 3.0))
				{
			    if(tWeapon[cartrunk[ cID ]][1] != 0)
				{
					SendClientMessage(playerid,COLOR_RED," There are already guns!");
					return 1;
				}
				if(gunid == 0)
				{
					SendClientMessage(playerid,COLOR_GREEN," First choose which weapons you want to put in the trunk");
					return 1;
				}
 			    tWeapon[cartrunk[ cID ]][1] = gunid;
				tAmmo[cartrunk[ cID ]][1] = ammo;
    			RemovePlayerWeaponT(playerid,gunid);
				RemovePlayerFromVehicle(playerid);
				SendClientMessage(playerid,COLOR_GREEN," You have successfully put your weapon in the trunk");
				}
			}
			if (listitem == 2 && gunid != 0)
			{
				if(IsPlayerInRangeOfVehicle(playerid, cartrunk[ cID ], 3.0))
				{
			    if(tWeapon[cartrunk[ cID ]][2] != 0)
				{
					SendClientMessage(playerid,COLOR_RED," There are already guns!");
					return 1;
				}
				if(gunid == 0)
				{
					SendClientMessage(playerid,COLOR_GREEN," First choose which weapons you want to put in the trunk");
					return 1;
				}
 			    tWeapon[cartrunk[ cID ]][2] = gunid;
				tAmmo[cartrunk[ cID ]][2] = ammo;
    			RemovePlayerWeaponT(playerid,gunid);
				RemovePlayerFromVehicle(playerid);
				SendClientMessage(playerid,COLOR_GREEN," You have successfully put your weapon in the trunk");
				}
			}
			if (listitem == 3 && gunid != 0)
			{
				if(IsPlayerInRangeOfVehicle(playerid, cartrunk[ cID ], 3.0))
				{
			    if(tWeapon[cartrunk[ cID ]][3] != 0)
				{
					SendClientMessage(playerid,COLOR_RED," There are already guns!");
					return 1;
				}
				if(gunid == 0)
				{
					SendClientMessage(playerid,COLOR_GREEN," First choose which weapons you want to put in the trunk");
					return 1;
				}
 			    tWeapon[cartrunk[ cID ]][3] = gunid;
				tAmmo[cartrunk[ cID ]][3] = ammo;
    			RemovePlayerWeaponT(playerid,gunid);
				RemovePlayerFromVehicle(playerid);
				SendClientMessage(playerid,COLOR_GREEN," You have successfully put your weapon in the trunk");
				}
			}
			if (listitem == 4 && gunid != 0)
			{
				if(IsPlayerInRangeOfVehicle(playerid, cartrunk[ cID ], 3.0))
				{
			    if(tWeapon[cartrunk[ cID ]][4] != 0)
				{
					SendClientMessage(playerid,COLOR_RED," There are already guns!");
					return 1;
				}
				if(gunid == 0)
				{
					SendClientMessage(playerid,COLOR_GREEN," First choose which weapons you want to put in the trunk");
					return 1;
				}
 			    tWeapon[cartrunk[ cID ]][4] = gunid;
				tAmmo[cartrunk[ cID ]][4] = ammo;
    			RemovePlayerWeaponT(playerid,gunid);
				RemovePlayerFromVehicle(playerid);
				SendClientMessage(playerid,COLOR_GREEN," You have successfully put your weapon in the trunk");
				}
			}
			if (listitem == 5 && gunid != 0)
			{
				if(IsPlayerInRangeOfVehicle(playerid, cartrunk[ cID ], 3.0))
				{
			    if(tWeapon[cartrunk[ cID ]][5] != 0)
				{
					SendClientMessage(playerid,COLOR_RED," There are already guns!");
					return 1;
				}
				if(gunid == 0)
				{
					SendClientMessage(playerid,COLOR_GREEN," First choose which weapons you want to put in the trunk");
					return 1;
				}
 			    tWeapon[cartrunk[ cID ]][5] = gunid;
				tAmmo[cartrunk[ cID ]][5] = ammo;
				RemovePlayerWeaponT(playerid,gunid);
				RemovePlayerFromVehicle(playerid);
				SendClientMessage(playerid,COLOR_GREEN," You have successfully put your weapon in the trunk");
				}
			}
			for(new t=0; t < 6; t++)
			{
			    if(IsPlayerInRangeOfVehicle(playerid, cartrunk[ cID ], 5.0))
				{
			    	g_Weaps[t] = tWeapon[cartrunk[ cID ]][t];
			    	g_Ammo[t] = tAmmo[cartrunk[cID]][t];

				}
			}
			}
        }
        else
		{
			SendClientMessage(playerid,COLOR_RED," You're close Trunk.");
		}

        return 1;
	}

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.