When a player try to join then it shows box in which we should write the server password.
Or go to your server. Login as RCON. Type /rcon password [whatever you want it to be]. Then you can look at the SA-MP Client and see that the server is unlocked. To disable the password type /rcon password 0.
pawn Код:
new locked = 0;
new passerver = 0;
public OnPlayerConnect...
{
if(locked == 1)
{
//Make the dialog!
return 1;
}
}
//dialogresponse
if(dialogid == ID_DIALOG)
{
if(strval(inputtext) == passerver)
{
//if is right, do what you wanna.
}
else
{
SendClientMessage(playerid, 0xFFFFFFAA, "Wrong server password!");
Kick(playerid);
return 1;
}
}
//the command
if(strcmp(cmd,"/lockserver", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(locked == 0)
{
locked = 1;
//message...
}
else
{
locked = 0;
//message unlocked.
}
}
return 1;
}
if(strcmp(cmd, "/serverpassword", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USE: /serverpassword [password]");
return 1;
}
new passwordx = strval(tmp)
GetPlayerName(playerid, sendername, sizeof(sendername));
passerver = passwordx;
format(string, sizeof(string), "New server password %d.", passwordx);
SendClientMessage(playerid, 0xFFFFFFAA, string);
return 1;
}
I don't test this.