[Help] Gate - 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] Gate (
/showthread.php?tid=282319)
[Help] Gate -
Nick. - 10.09.2011
Need help how to make gate with password and /changegatepass
Re: [Help] Gate -
judothijs - 10.09.2011
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 ^^
Re: [Help] Gate -
Nick. - 10.09.2011
Will it work on all the gates of the organization and gangs
?
Re: [Help] Gate -
judothijs - 12.09.2011
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.