Can different checks be converted into single check?
#1

Hello, a question just popped in my mind to make my script a bit more efficient(I guess so xd), but have no idea how to do this. I know the topic name isn't self explanatory so here's what Im thinking:
for example, in my script I have many teleports, and for each of them I have to check the player condition one by one like this;
Код:
	if (InDM[playerid] == 1)
        {
		return ErrorMessages(playerid, 12);
		}
        else

        if(AccInfo[playerid][Frozen] == 1)
        {
        	return ErrorMessages(playerid, 14);
        }
        else

        if(AccInfo[playerid][Jailed] == 1)
        {
        	return ErrorMessages(playerid, 15);
        }
        else

	if(AccInfo[playerid][pCaged] == 1)
	{
		return ErrorMessages(playerid, 16);
	}
	else
	
        if(InDuel[playerid] == 1)
	{
		return ErrorMessages(playerid, 17);
	}
	else
              
        {
                 //main function here
        }
that means if I add something new, I would have to go add new piece of code in each of the teleport code lines. What I want is I make something like
Код:
TeleportRestrictions
containing all of the above checks and use it in the code(where ever these checks are required) so I'll just have to update this when a new thing is added, and all the teleports will be updated. Ofcourse, these kinds of checks ar not only used in teleports, they're almost everywhere. Im sure this can be done in one way or another, but I don't exactly know how?
Any help would be appreciated and thanks.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)