SA-MP Forums Archive
Help with "if" restriction :S. - 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" restriction :S. (/showthread.php?tid=367016)



Help with "if" restriction :S. - Mataaltedi - 08.08.2012

Hey guys, sorry for my english spelling faults.

My question is this, i would like to add to this

Код HTML:
if(strcmp(cmd, "/Trabajoilegal", true) == 0) /*Check*/
	{
	    if(IsPlayerConnected(playerid))
	    {
			if (!PlayerToPoint(5, playerid,1688.7321,-1974.2430,8.8203))//centerpoint 24-7
			{
				SendClientMessage(playerid, COLOR_GRAD2, "   No estбs en un lugar para obtener trabajo нlegal !");
				return 1;
			}
			ShowPlayerDialog(playerid,JOBS_CONTRATO, DIALOG_STYLE_MSGBOX, "Contrato para trabajo нlegal", "Para formar parte de un trabajo нlegal sea cual sea el trabajo que vayas a tomar tendrбs que firmar un contrato\nEl contrato es de 5 horas y al elegir el trabajo no hay vuelta atrбs y no podrбs salirte ((/Quitjob)) antes de las 5 horas\n їDeseas firmar el contrato?" , "Si", "No");
			}
		return 1;
	}
Retriction if, that only players with this configs
Код HTML:
if(PlayerInfo[playerid][pMember] == 5 || PlayerInfo[playerid][pLeader] == 5)
if(PlayerInfo[playerid][pMember] == 15 || PlayerInfo[playerid][pLeader] == 15)
if(PlayerInfo[playerid][pMember] == 17 || PlayerInfo[playerid][pLeader] == 17)
if(PlayerInfo[playerid][pMember] == 18 || PlayerInfo[playerid][pLeader] == 18)
if(PlayerInfo[playerid][pMember] == 5 || PlayerInfo[playerid][pLeader] == 5)
if(PlayerInfo[playerid][pMember] == 15 || PlayerInfo[playerid][pLeader] == 14)
if(PlayerInfo[playerid][pMember] == 6 || PlayerInfo[playerid][pLeader] == 6)
if(PlayerInfo[playerid][pMember] == 12 || PlayerInfo[playerid][pLeader] == 12)
if(PlayerInfo[playerid][pMember] == 21 || PlayerInfo[playerid][pLeader] == 21)
Only this players could see the command dialogue... how i can do it ?


Re: Help with "if" restriction :S. - AndreT - 08.08.2012

You'll have to do it similarly to that.

Now for quicker access, it is better to store the value of pMember and pLeader in variables of their own. I have done tests on this before and storing an array value in a variable is faster than accessing the array constantly (large speed difference even on 3-5 calls).

pawn Код:
new membership = PlayerInfo[playerid][pMember],
    leadership = PlayerInfo[playerid][pLeader];
if(membership == 5 || leadership == 5
|| membership == 15 || leadership == 15
|| membership == 17 || leadership == 17
|| membership == 18 || leadership == 18
|| membership == 14 || leadership == 14
|| membership == 6 || leadership == 6
|| membership == 12 || leadership == 12
|| membership == 21 || leadership == 21)
{
    // Show the dialog
}



Re: Help with "if" restriction :S. - Vince - 08.08.2012

I never quite understood this gf system. Surely, if the player is the leader of a clan/group/faction, aren't they in that group as well? Therefore, the pLeader check is redundant.


Re: Help with "if" restriction :S. - StreetGT - 08.08.2012

or you can make by this way

pawn Код:
new faction;
if(PlayerInfo[playerid][pMember] >0)
{
    faction = PlayerInfo[playerid][pMember];
}
else if(PlayerInfo[playerid][pLeader] >0)
{
    faction = PlayerInfo[playerid][pLeader];
}
then you can make

pawn Код:
if(faction == 1 || faction == 2) ....