SA-MP Forums Archive
help with "if" and && / || - 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: help with "if" and && / || (/showthread.php?tid=554436)



help with "if" and && / || - Stoyanov - 03.01.2015

Код:
if(DmID[playerid] == 2 && Dead[playerid] == 1 && GangLvl[playerid] <= 0 || DmID[playerid] == 7 && Dead[playerid] == 1 && GangLvl[playerid] > 0)
When i am IN gang and in DM if someone kill me it doesn't spawn me in the DM zone, but if i am not in a gang it spawns me inside.


Re : help with "if" and && / || - MCZOFT - 03.01.2015

give the whole code .... why you're afraid ..


NOT the whole script .. just the part of the IF


Re: help with "if" and && / || - Stoyanov - 03.01.2015

i am not afraid. Just don't know what code to post and i post only the "if".

Whole if:

Код:
if(DmID[playerid] == 2 && Dead[playerid] == 1 && GangLvl[playerid] <= 0 || DmID[playerid] == 7 && Dead[playerid] == 1 && GangLvl[playerid] > 0)
	{
		SetPlayerVirtualWorld(playerid, 6);
		SetPlayerPos(playerid, -1615.9468, -393.3749, 273.4801);
		SetPlayerHealth(playerid, 100);
		SetPlayerArmour(playerid, 100);
		GivePlayerWeapon(playerid, 30, 1500);
		GivePlayerWeapon(playerid, 29, 1500);
		GivePlayerWeapon(playerid, 17, 40);
		GivePlayerWeapon(playerid, 34, 250);
		GivePlayerWeapon(playerid, 39, 100);
		GivePlayerWeapon(playerid, 40, 1);
		GotoDisabled[playerid] = 1;
		Dead[playerid] = 0;
	}
OTHER DEATH MATCH ZONE. Same thing. if u are in gang, will spawn u outside.

Код:
if(DmID[playerid] == 5 && Dead[playerid] == 1 && GangLvl[playerid] <= 0 || DmID[playerid] == 7 && Dead[playerid] == 1 && GangLvl[playerid] > 0)
	{
		SetPlayerVirtualWorld(playerid, 6);
		SetPlayerHealth(playerid, 100);
		SetPlayerArmour(playerid, 100);
		ResetPlayerWeapons(playerid);
		GivePlayerWeapon(playerid, 22, 600);
		GivePlayerWeapon(playerid, 16, 40);
		GivePlayerWeapon(playerid, 31, 1200);
		GivePlayerWeapon(playerid, 29, 1000);
		GotoDisabled[playerid] = 1;
		new Random = random(sizeof(sawnoffdm));
		SetPlayerPos(playerid, sawnoffdm[Random][0], sawnoffdm[Random][1], sawnoffdm[Random][2]);
		Dead[playerid] = 0;
	}



Re: help with "if" and && / || - Vince - 03.01.2015

Well this is some really obscure piece of code because it can be interpreted in different ways. I think it is to be interpreted like this:
pawn Код:
if((DmID[playerid] == 5 && Dead[playerid] == 1 && GangLvl[playerid] <= 0) || (DmID[playerid] == 7 && Dead[playerid] == 1 && GangLvl[playerid] > 0))
But the Pawn parser may just as well interpret it as
pawn Код:
if(DmID[playerid] == 5 && Dead[playerid] == 1 && (GangLvl[playerid] <= 0 || DmID[playerid] == 7) && Dead[playerid] == 1 && GangLvl[playerid] > 0)
When in doubt, use brackets.


Re: help with "if" and && / || - Stoyanov - 03.01.2015

Quote:
Originally Posted by Vince
Посмотреть сообщение
Well this is some really obscure piece of code because it can be interpreted in different ways. I think it is to be interpreted like this:
pawn Код:
if((DmID[playerid] == 5 && Dead[playerid] == 1 && GangLvl[playerid] <= 0) || (DmID[playerid] == 7 && Dead[playerid] == 1 && GangLvl[playerid] > 0))
But the Pawn parser may just as well interpret it as
pawn Код:
if(DmID[playerid] == 5 && Dead[playerid] == 1 && (GangLvl[playerid] <= 0 || DmID[playerid] == 7) && Dead[playerid] == 1 && GangLvl[playerid] > 0)
When in doubt, use brackets.
i've test them. Still doesn't work. Now if u are in gang spawn u outside.

btw: OnPlayerSpawn i have this code from gang system:

Код:
if((DmID[playerid] == 1 && Dead[playerid] == 1 && GangLvl[playerid] <= 0) || (DmID[playerid] == 1 && Dead[playerid] == 1 && GangLvl[playerid] > 0))
	{
		SetPlayerVirtualWorld(playerid, 6);
		SetPlayerPos(playerid, 2024.3439, 2444.2454, 367.7574);
		SetPlayerHealth(playerid, 100);
		SetPlayerArmour(playerid, 100);
		GivePlayerWeapon(playerid, 31, 6000);
		GivePlayerWeapon(playerid, 32, 6000);
		GotoDisabled[playerid] = 1;
		Dead[playerid] = 0;
	}
	if((DmID[playerid] == 2 && Dead[playerid] == 1 && GangLvl[playerid] <= 0) || (DmID[playerid] == 2 && Dead[playerid] == 1 && GangLvl[playerid] > 0))
	{
		SetPlayerVirtualWorld(playerid, 6);
		SetPlayerPos(playerid, -1615.9468, -393.3749, 273.4801);
		SetPlayerHealth(playerid, 100);
		SetPlayerArmour(playerid, 100);
		GivePlayerWeapon(playerid, 30, 1500);
		GivePlayerWeapon(playerid, 29, 1500);
		GivePlayerWeapon(playerid, 17, 40);
		GivePlayerWeapon(playerid, 34, 250);
		GivePlayerWeapon(playerid, 39, 100);
		GivePlayerWeapon(playerid, 40, 1);
		GotoDisabled[playerid] = 1;
		Dead[playerid] = 0;
	}
	if((DmID[playerid] == 3 && Dead[playerid] == 1 && GangLvl[playerid] <= 0) || (DmID[playerid] == 3 && Dead[playerid] == 1 && GangLvl[playerid] > 0))
	{
		SetPlayerVirtualWorld(playerid, 6);
		SetPlayerPos(playerid, -1560.0950, -302.5780, 272.1163);
		SetPlayerHealth(playerid, 100);
		SetPlayerArmour(playerid, 100);
		GivePlayerWeapon(playerid, 31, 1600);
		GivePlayerWeapon(playerid, 32, 1600);
		GivePlayerWeapon(playerid, 18, 40);
		GivePlayerWeapon(playerid, 34, 250);
		GivePlayerWeapon(playerid, 39, 100);
		GivePlayerWeapon(playerid, 40, 1);
		GotoDisabled[playerid] = 1;
		Dead[playerid] = 0;
	}
	if((DmID[playerid] == 4 && Dead[playerid] == 1 && GangLvl[playerid] <= 0) || (DmID[playerid] == 4 && Dead[playerid] == 1 && GangLvl[playerid] > 0))
	{
		SetPlayerVirtualWorld(playerid, 6);
		SetPlayerHealth(playerid, 100);
		SetPlayerArmour(playerid, 100);
		GivePlayerWeapon(playerid, 31, 1600);
		GivePlayerWeapon(playerid, 32, 1600);
		GivePlayerWeapon(playerid, 18, 200);
		GivePlayerWeapon(playerid, 34, 250);
		GivePlayerWeapon(playerid, 39, 100);
		GivePlayerWeapon(playerid, 40, 1);
		GivePlayerWeapon(playerid, 38, 700);
		GotoDisabled[playerid] = 1;
		new Random = random(sizeof(judm));
		SetPlayerPos(playerid, judm[Random][0], judm[Random][1], judm[Random][2]);
		Dead[playerid] = 0;
	}
	if((DmID[playerid] == 5 && Dead[playerid] == 1 && GangLvl[playerid] <= 0) || (DmID[playerid] == 5 && Dead[playerid] == 1 && GangLvl[playerid] > 0))
	{
		SetPlayerVirtualWorld(playerid, 6);
		SetPlayerHealth(playerid, 100);
		SetPlayerArmour(playerid, 100);
		ResetPlayerWeapons(playerid);
		GivePlayerWeapon(playerid, 22, 600);
		GivePlayerWeapon(playerid, 16, 40);
		GivePlayerWeapon(playerid, 31, 1200);
		GivePlayerWeapon(playerid, 29, 1000);
		GotoDisabled[playerid] = 1;
		new Random = random(sizeof(sawnoffdm));
		SetPlayerPos(playerid, sawnoffdm[Random][0], sawnoffdm[Random][1], sawnoffdm[Random][2]);
		Dead[playerid] = 0;
	}
	if((DmID[playerid] == 6 && Dead[playerid] == 1 && GangLvl[playerid] <= 0) || (DmID[playerid] == 6 && Dead[playerid] == 1 && GangLvl[playerid] > 0))
	{
		SetPlayerVirtualWorld(playerid, 6);
		SetPlayerHealth(playerid, 100);
		SetPlayerArmour(playerid, 100);
		GivePlayerWeapon(playerid, 16, 10);
		GivePlayerWeapon(playerid, 34, 500);
		GotoDisabled[playerid] = 1;
		new Random = random(sizeof(sniperdm));
		SetPlayerPos(playerid, sniperdm[Random][0], sniperdm[Random][1], sniperdm[Random][2]);
		Dead[playerid] = 0;
		return 1;
	}
	if((DmID[playerid] == 7 && Dead[playerid] == 1 && GangLvl[playerid] <= 0) || (DmID[playerid] == 7 && Dead[playerid] == 1 && GangLvl[playerid] > 0))
	{
		SetPlayerVirtualWorld(playerid, 6);
		SetPlayerHealth(playerid, 100);
		SetPlayerArmour(playerid, 100);
		GivePlayerWeapon(playerid, 18, 15);
		GivePlayerWeapon(playerid, 24, 1250);
		GotoDisabled[playerid] = 1;
		new Random = random(sizeof(deagledm));
		SetPlayerPos(playerid, deagledm[Random][0], deagledm[Random][1], deagledm[Random][2]);
		Dead[playerid] = 0;
	}
////////////////////////////// GANG //////////////////////////////////// GANG //////////////////////////////
	if(GSkin[PGang[playerid]][GangLvl[playerid]-1] > 0)
	{
		SetPlayerSkin(playerid, GSkin[PGang[playerid]][GangLvl[playerid]-1]);
	}
	if(GSpawnX[PGang[playerid]] != 0.0 && GSpawnY[PGang[playerid]] != 0.0 && GSpawnZ[PGang[playerid]] != 0.0)
	{
		SetPlayerPos(playerid, GSpawnX[PGang[playerid]], GSpawnY[PGang[playerid]], GSpawnZ[PGang[playerid]]);
	}
	new hex[MAX_PLAYERS];
	hex[playerid] = HexToInt(GColor[PGang[playerid]]);
	SetPlayerColor(playerid, hex[playerid]);



Re: help with "if" and && / || - Stoyanov - 05.01.2015

bump.