SA-MP Forums Archive
OnPlayerWeaponShot - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerWeaponShot (/showthread.php?tid=621736)



OnPlayerWeaponShot - StR_MaRy - 14.11.2016

hey guys i have a mission system but i have just a problem with a next step

HTML Code:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(OwnerMisiune[playerid] == 1)
    {
		if(weaponid == 34)
		{
		    if(hittype == BULLET_HIT_TYPE_OBJECT)
			{
    			CreateMisiuneActor();
				DestroyObject(MisiuneSpeciala[0]);
				SendClientMessage(playerid, -1, "Ai distrus obiectul, du-te acum aici pentru a omori acea persoana cu tricou negru.");
			}
			else if(hittype == BULLET_HIT_TYPE_OBJECT)
			{
				MisiuneActiva = 0;
				DestroyActor(Actorr[0]);
				DestroyActor(Actorr[1]);
				OwnerMisiune[playerid] = 0;
				SendClientMessage(playerid, -1, "Ai omorit persoana in tricou negru.");
			}
		}
	}
	return 1;
}
first step from here is ok , but after i am doing first step i want to change it to the next one "else if etc..." how can i do it ? some ideas?


Re: OnPlayerWeaponShot - Sanady - 14.11.2016

Put debugs into every if and every line of code, so you will see where is code stucking.


Re: OnPlayerWeaponShot - StR_MaRy - 14.11.2016

no bro is working but i don't know how to make the next step to activate after first step is ending


Re: OnPlayerWeaponShot - IceBilizard - 14.11.2016

use a simple variable

PHP Code:
new step=0;
public 
OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    if(
OwnerMisiune[playerid] == 1)
    {
        if(
weaponid == 34)
        {
            if(
hittype == BULLET_HIT_TYPE_OBJECT)
            {
                if(
step == 0)
                {
                    
CreateMisiuneActor();
                    
DestroyObject(MisiuneSpeciala[0]);
                    
SendClientMessage(playerid, -1"Ai distrus obiectul, du-te acum aici pentru a omori acea persoana cu tricou negru.");
                    
step 1;
                }
                if(
step == 1)
                {
                    
MisiuneActiva 0;
                    
DestroyActor(Actorr[0]);
                    
DestroyActor(Actorr[1]);
                    
OwnerMisiune[playerid] = 0;
                    
SendClientMessage(playerid, -1"Ai omorit persoana in tricou negru.");
                    
step 0;
                }
            }
        }
    }
    return 
1;




Re: OnPlayerWeaponShot - StR_MaRy - 14.11.2016

is not working , now both are destroyed in the same time with step 1


Re: OnPlayerWeaponShot - SickAttack - 14.11.2016

Change "if(step == 1)" to "else if(step == 1)".


Re: OnPlayerWeaponShot - StR_MaRy - 14.11.2016

works , thx