10.09.2011, 15:53
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:
Note that I wrote this from bare hand and without any compiler, so don't expect it to be perfect :P
Hope this helps ^^
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!");
}
}
}
Hope this helps ^^