Make only specific players can join - 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: Make only specific players can join (
/showthread.php?tid=651994)
Make only specific players can join -
PowerF - 01.04.2018
Hey, my server is currently on beta version and i want to allow players with nicknames that i already write inside a file or sql.
any example how can I do it?
so for example I create a file or sql table called 'betatesters' and if a players connect and their nicknames aren't in the list they can't join.
thanks.
Re: Make only specific players can join -
Gameluner - 01.04.2018
You can use this:
Код:
stock pName(playerid)
{
new n[25];
GetPlayerName(playerid,n,sizeof(n));
return n;
}
public OnPlayerConnect(playerid)
{
if(strcmp(pName(playerid),"Nick1") ||
strcmp(pName(playerid),"Nick2") ||
strcmp(pName(playerid),"Nick3") )
{
Kick(playerid);
}
return 1;
}
Or make a whitelist using news.
Re: Make only specific players can join -
PowerF - 01.04.2018
Thanks,but I don't want to reupload my gamemode just to add 1 beta tester.
I want to make it more dynamic,so I only add 1 line in sql or ini file.
anyone?
Re: Make only specific players can join -
Gameluner - 01.04.2018
You can make it with files.
Код:
stock pName(playerid)
{
new n[25];
GetPlayerName(playerid,n,sizeof(n));
return n;
}
CMD:whiteadd(playerid,params[])
{
new player,string[50];
if(sscanf(params,"u",player)) return SendClientMessage(playerid,-1,"Usage: /whiteadd [PlayerNick/PlayerID]");
if(!IsPlayerConnected(player) || player == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Player is not connected);
format(string,50,"Whitelist/%s.ini",pName(player));
new File:LogFile = fopen(string,io_read);
fclose(LogFile);
return 1;
}
public OnPlayerConnect(playerid)
{
new string[50];
format(string,50,"Whitelist/%s.ini",pName(player));
if(!fexist(string))
{
Kick(playerid);
}
else
{}
return 1;
}
This should work.
Re: Make only specific players can join -
PowerF - 01.04.2018
/whiteadd doesn't work,it don't add file
Re: Make only specific players can join -
Gameluner - 02.04.2018
You can edit that code of course. I made it within 3 minutes so I didn't look for mistakes.