I need some help with an entrance.
#1

Hello,

How do I make an entrance to be locked for all the players on the server?

Let's say we've door A which's a faction door. Only the leader can lock the door.
I tried doing:
PHP код:
doorLockedMAX_PLAYERS ]; 
and for example:
PHP код:
CMD:lockdoorplayeridcmdtext[] ) {
    if(
IsPlayerConnected(playerid))
    {
        new 
string[128]; // the if player is leader etc I know how to do it this is just an example
        
format(stringsizeof(string), "%s has locked door A"GetOOCName(playerid));
        
SendMessageToAll(exampleredstring);
        foreach( new 
Player )
        {
            
doorLocked 1;
        }
        return 
1;
    }
    return 
0;

How do I check if the door's locked & if it is to unlock it, I think I got an idea how to do that but the real question's:
If I do it that way, wouldn't the players that just connect have doorLocked = 0; meaning they can enter the specified door?

To sum it all up, I want someone to show me how to make a door be locked & unlocked for everyone on the server and when it's locked to be locked on those that join too.
Reply
#2

pawn Код:
new doorlocked;

public OnGameModeInit()
{
   doorlocked = 0;
   return 1;
}

public OnGameModeExit()
{
   doorlocked = 0;
   return 1;
}


CMD:lockdoor(playerid, params[])
{
   if(doorlocked == 0)
   {
      new string[128];
      format(string, sizeof(string), "%s has locked door A", GetOOCName(playerid));
      SendMessageToAll(example, red, string);
      doorlocked = 1;
   }
   else if(doorlocked == 1)
   {
      new string[128];
      format(string, sizeof(string), "%s has unlocked door A", GetOOCName(playerid));
      SendMessageToAll(example, red, string);
      doorlocked = 0;
   }
   return 1;
}

//On Enter Door
   if(doorlocked == 0) return SendClientMessage(playerid, 0xFF0000AA, "Door A is locked");
Reply
#3

Thank you, I'll try it later but as it seems it looks like it'll work. You received +rep.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)