onplayerweapon shot car?
#1

hey guys is possible to check if the shoted car is the good one or not ?

Код HTML:
if(hittype == BULLET_HIT_TYPE_VEHICLE)
                {
					if(MissionCar[4])
					{
	                    Step = 0;
	                    MisiuneActiva = 0;
						DestroyActor(Actorr[0]);
						DestroyActor(Actorr[1]);
						OwnerMisiune[playerid] = 0;
		                PlayAudioStreamForPlayer(playerid, "http://k003.kiwi6.com/hotlink/ppuz6duc8e/Mission_Passed.mp3");
						SendClientMessage(playerid, -1, "Ai distrus servieta cu bani, acum nu isi mai pot incheia afacerea ilegala.");
						GameTextForPlayer(playerid, "~y~mission passed!", 5000, 3);
					}
					else return SendClientMessage(playerid, -1, "Nu aia este masina ce trebuie distrusa.");
				}
Reply
#2

Can you explain more please what you mean with car is good one or not?
Reply
#3

Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
	if(hittype == 2)
        {
		new bool: isany_incar = false;

		for(new i = 0; i < MAX_PLAYERS; ++i)
		{
			if(IsPlayerInVehicle(i, hitid))
			{
				isany_incar = true;
				break;
			}
		}

		if(isany_incar != true)//You hit a vehicle with noone sitting inside.
		{
                        //the vehicle's ID you've hit is hitid
			new Float:vHealth;
			GetVehicleHealth(hitid, vHealth);
			SetVehicleHealth(hitid, vHhealth - 50);
		}
    }
    return 1;
}
I hope this helps. If you need more details or an explanation somewhere just tell me, should be clear as you read the code with the comments.
Reply
#4

yea so i want to shot a car with no one inside only that car called MissionCar[4] and if he didn't hit that car called MissionCar[4] he will get a message like "that car you shot is the wrong one"
Reply
#5

Then compare the vehicle ID he hit with the mission car, if they don't match make the script send that message.
Reply
#6

that is the problem i don't know how...
Reply
#7

Код:
if(hitid != MissionCar[4])
SendClientMessage(playerid, color, "that car you shot is the wrong one");
Try to use this together the way I showed. Let's see if you get somewhere, come back if you couldn't make it. :P
Reply
#8

Try this

PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    if(
hittype == BULLET_HIT_TYPE_VEHICLE)
    {
        new 
vehicleid hitid;
        
        if(
vehicleid == MissionCar[4])
        {
            
SendClientMessage(playerid, -1"You've hitted correct car");
        }
        else
        {
            
SendClientMessage(playerid, -1"You've hitted wrong car");
        }
    }
    return 
1;

Reply
#9

thx all of you , corect script IceBilizard
Reply
#10

Quote:
Originally Posted by IceBilizard
Посмотреть сообщение
Try this

PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    if(
hittype == BULLET_HIT_TYPE_VEHICLE)
    {
        new 
vehicleid hitid;
        
        if(
vehicleid == MissionCar[4])
        {
            
SendClientMessage(playerid, -1"You've hitted correct car");
        }
        else
        {
            
SendClientMessage(playerid, -1"You've hitted wrong car");
        }
    }
    return 
1;

hitted isn't a word...

There's no need to create a variable, just use hitid.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)