If player is banned - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: If player is banned (
/showthread.php?tid=274992)
If player is banned -
Kingunit - 07.08.2011
<fixed>
Re: If player is banned -
Tee - 07.08.2011
pawn Код:
public OnPlayerSpawn(playerid)
{
if(Player[playerid][Banned] == 1)
{
Kick(playerid)
SendClientMessage(playerid,-1,"You are banned have a good life :P.");
}
return 1;
}
Re: If player is banned -
Kingunit - 07.08.2011
<fixed>
Re : If player is banned -
Soumi - 07.08.2011
You need to read the user file and check if he is banned or not, what include are you using to read and write .ini files?
Re: If player is banned -
Kingunit - 07.08.2011
<fixed>
Re: If player is banned -
Tee - 07.08.2011
Well you can either load it into the var when the player logs in or us, y_ini, dini or DJson.
Re: If player is banned -
Kingunit - 07.08.2011
Honestly, I've never read a file before the players logs in. Can someone give it a try? So I can learn something new?
Re : If player is banned -
Soumi - 08.08.2011
pawn Код:
public OnPlayerConnect(playerid)
{
new file[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(file, sizeof(file), "Users/%s.ini", pName);
if(!fexist(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Please Register", "Enter Your Password Below", "Register", "Cancel");
}
else
{
Player[playerid][Banned] = dini_Int(file, "Banned");
if(Player[playerid][Banned] == 0)
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please Login", "Enter Your Password Below", "Login", "Cancel");
}
else
{
SendClientMessage(playerid, RED, "You are banned gtfo");
Kick(playerid);
}
}
return 1;
}
try this.
Re: If player is banned -
Tee - 08.08.2011
pawn Код:
new file[32],Name[32];//Variable declaration, don't declare it here, just make a new one at the top of the script, this is just for the purpose of helping you.
GetPlayerName(playerid,Name,sizeof(Name));// Getting the player's name.
format(file,sizeof(file),"Accounts/%s.ini",Name);//You can see where I have 'Accounts' change that to the name of the folder in which the files are stored.
PlayerData[playerid][Banned] = dini_Int(file, "Banned");//This is storing what's in the file, into the Player[playerid][Banned] variable.
I explained in that above.
EDIT: You need to use the edit button and put the Banned check under OnPlayerSpawn.
Re : If player is banned -
Soumi - 08.08.2011
Why checking if player is banned Must be under OnPlayerSpawn?