[Help] Gate
#1

Need help how to make gate with password and /changegatepass
Reply
#2

Well, first make a gate.
Then, we want it to move with the command /opengate Your_Password.

Then, you can compare the password the player wrote with a text file.
We'll use dini for that.

So put #include <dini> on top of your script.

Also, for the command and the compare we will be using ZCMD and Scanff.

So also add #include <sscanf> and #include <zcmd> to your include list.

I assume you've already scripted the gate object, so we'll skip that part.

The command:
pawn Код:
CMD:opengate(playerid, params[])
{
      new password1[35];
      if(sscanf(params, "s", password1)) return SendClientMessage(playerid, 0x00FF0000, "/opengate Password");
      else
      {
      if(!dini_Exists("password.txt"))
      {
          dini_Create("password.txt");
          dini_Set("password.txt", "password", password);
      }
      if(dini_Exists("password.txt"))  
      {
           dini_Get("password.txt", password);
           if(!strcmp(password, password1) == 0)
           {
                // Move object function
           }
           else
           {
              SendClientMessage(playerid, 0x00FF0000, "Wrong password!");
           }
      }
   }
}

CMD:setpassword(playerid, params[])
{
    new password1[35];
    if(sscanf(params, "s", password1)) return SendClientMessage(playerid, 0x00FF0000, "Enter a password!");
    else
    {
        if(dini_Exists("password.txt");
        {
             dini_Set("password.txt", "password", password1);
             SendClientMessage(playerid, 0x00FF0000, "Done!");
        }
     }
}
Note that I wrote this from bare hand and without any compiler, so don't expect it to be perfect :P
Hope this helps ^^
Reply
#3

Will it work on all the gates of the organization and gangs?
Reply
#4

It will work on every gate you script this way.
If you want it to only work for a specified team/gang, simply add a if-statement on top, checking the player's team.

So for example:
pawn Код:
if(PlayerInfo[playerid][pMember] == 1) // or, if you're working with SetPlayerTeam, simply add: if(GetPlayerTeam(playerid == TEAM_ID)) //or
if(gTeam[playerid] == YOUR_TEAM)
Since I don't know what Team system you're using, I can't really make a working statement that fits your script.
Although the idea seems clear I think.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)