Ban Command - 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: Ban Command (
/showthread.php?tid=535435)
Ban Command -
Frankin - 03.09.2014
Hello,
I'm trying to create admin script for my server, I tried to make ban command many times but I failed :/.
Could somebody Create Ban command for me =)
Command in zcommand
Thanks
Note : Sorry for my bad english ^^
Quote:
if(pInfo[playerid][Adminlevel] >= 1)
|
Edit : +repp for the helper
Re: Ban Command -
TonyNames - 03.09.2014
Well, depends on the saving system. Give us more information like is the saving system MySQL or djson something like that
Re: Ban Command -
LeroyII - 03.09.2014
First go to the script files and add text document named "BanLog"
And here is command:
pawn Код:
CMD:ban(playerid,params[]) {
if(pInfo[playerid][LoggedIn] == 1) {
if(pInfo[playerid][Adminlevel] >= 1) {
new tmp[128], tmp2[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]");
if(isnull(tmp2)) return SendClientMessage(playerid, red, "ERROR: You must give a reason");
new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
player1 = strval(tmp);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
new year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second);
format(string,sizeof(string),"%s has been banned by Administrator %s [Reason: %s] [Date: %d/%d/%d] [Time: %d:%d]",playername,adminname,params[2],day,month,year,hour,minuite);
SendClientMessageToAll(grey,string);
SaveToFile("BanLog",string);
aresetpall(player1);
print(string);
format(string,sizeof(string),"banned by Administrator %s. Reason: %s", adminname, params[2] );
return BanEx(player1, string);
} else return SendClientMessage(playerid, red, "Player is not connected or is yourself or is the highest level admin");
} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
} else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
It works on my script, but if you get any errors message me or post back here..
Re: Ban Command -
Frankin - 03.09.2014
Quote:
Originally Posted by TonyNames
Well, depends on the saving system. Give us more information like is the saving system MySQL or djson something like that
|
This is the tutorial i have followed :
https://sampforum.blast.hk/showthread.php?tid=352703
Quote:
Originally Posted by LeroyII
First go to the script files and add text document named "BanLog"
And here is command:
pawn Код:
CMD:ban(playerid,params[]) { if(pInfo[playerid][LoggedIn] == 1) { if(pInfo[playerid][Adminlevel] >= 1) { new tmp[128], tmp2[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index); if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]"); if(isnull(tmp2)) return SendClientMessage(playerid, red, "ERROR: You must give a reason"); new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128]; player1 = strval(tmp); if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) { GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname)); new year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second); format(string,sizeof(string),"%s has been banned by Administrator %s [Reason: %s] [Date: %d/%d/%d] [Time: %d:%d]",playername,adminname,params[2],day,month,year,hour,minuite); SendClientMessageToAll(grey,string); SaveToFile("BanLog",string); aresetpall(player1); print(string); format(string,sizeof(string),"banned by Administrator %s. Reason: %s", adminname, params[2] ); return BanEx(player1, string); } else return SendClientMessage(playerid, red, "Player is not connected or is yourself or is the highest level admin"); } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command"); } else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands"); }
It works on my script, but if you get any errors message me or post back here..
|
PHP код:
if(pInfo[playerid][LoggedIn] == 1)
This won't work
Re: Ban Command -
Fred1993 - 03.09.2014
Atleast tell your enums so helpers can provide some help related to your script!
Re: Ban Command -
Frankin - 03.09.2014
Quote:
Originally Posted by Fred1993
Atleast tell your enums so helpers can provide some help related to your script!
|
my enums
PHP код:
enum PlayerInfo
{
Pass[129],
Adminlevel,
Muted,
VIPLevel,
Money,
Scores,
Kills,
Deaths
}
Re: Ban Command -
Fred1993 - 03.09.2014
Quote:
enum PlayerInfo
{
Pass[129],
Adminlevel,
Muted,
VIPLevel,
Money,
Scores,
Kills,
ban,
Deaths
}
CMD:ban(playerid, params[]) {
new playa;
new reason[128],msg[128];
if (!sscanf(params, "ds[128]", playa, reason))
{
if(!IsPlayerConnect(playa)) {
SendClientMessage(playerid, -1 ,"User not found.");
return 1;
}
format(msg,sizeof(msg),"[AMSG] %s has been banned by %s: %s",GetPlayerName(playa),GetPlayerName(playerid),r eason);
// use your type of msg here, that you want to send
pInfo[playerid][ban] = 1; // this will add 1 in ban enum and you have to check this onplayerconnect
} else {
SendClientMessage(playerid, -1, "USAGE: /ban [playerid/name] [reason]");
}
return 1;
}
|
you need to edit things in your game mode if you want this code to work, there are many ways to ban a player but im telling you my way
Re: Ban Command -
LeroyII - 03.09.2014
Quote:
Originally Posted by Frankin
|
Then try to remove it!