Temp Ban Command Mysql [+REP]
#1

PHP код:
CMD:tban(playerid,params[]) 

    if(
pInfo[playerid][pAdminLevel] < 2)return SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!"); 
    new 
targetid,reason[105],string[145],time
    if(
sscanf(params,"uis[105",targetid,time,reason))return SendClientMessage(playerid,-1,""chat" /tban [playerid][times(minutes)][reason]"); 
    if(!
IsPlayerConnected(targetid))return SendClientMessage(playerid,-1,""chat" Player is not online"); 
    
format(string,sizeof string,""chat""COL_WHITE" [{B3432B}ADMIN{FFFFFF}]%s {EEC900}banned{FFFFFF} [player:%s] [reason:%s] for %d minutes",PlayerName(playerid),PlayerName(targetid),reason,time); 
    
SendClientMessageToAll(-1,string); 
    
printf("%s %s has banned %s for %i minutes [Reason: %s]",GetAdminName(playerid),PlayerName(playerid),PlayerName(targetid),time,reason); 
    
format(string,sizeof string,""COL_WHITE"["COL_CADMIN"ADMIN"COL_WHITE"]"COL_CGREY" %s > banned > %s > %i minutes",PlayerName(playerid),PlayerName(targetid),time); 
    
SendMessageToAllAduty(-1,string); 
    
TBanPlayer(targetid,playerid,reason,GetAdminName(playerid),time); 
    
format(string,sizeof string,"%s(%d) /tban %s(%d) %i minutes (Reason: %s)",GetName(playerid),playerid,GetName(targetid),targetid,time,reason); 
    new 
File:log fopen("CommandsUsed.txt",io_append); 
    
fwrite(log,string); 
    
fwrite(log,"\r\n"); 
    
fclose(log); 
    return 
1

stock TBanPlayer(targetid,playerid,reason[],admin[],time

    new 
playerIP,Hour,Minute,Second,Year,Month,Day,timeBanned[80],bannedstring[256],Query[256]; 
    
GetPlayerIp(playerid,playerIP,sizeof playerIP); 
    
gettime(Hour,Minute,Second); 
    
getdate(Year,Month,Day); 
    
format(timeBanned,sizeof timeBanned,"%02d:%02d:%02d on %02d/%02d/%d",Hour,Minute,Second,Day,Month,Year); 
    
mysql_format(mysql,Query,sizeof Query,"INSERT INTO `tbanlog` (`Name`,`pBannedReason`,`pBannedBy`,`pTime`,`pIPBanned`,`pAccountLock`,`pTBanEnd`) VALUES ('%s','%s','%s','%s','%s',1,'%s')"
    
PlayerName(targetid),reason,PlayerName(playerid),timeBanned,playerIP,gettime() + (time*60)); 
    
mysql_tquery(mysql,Query); 
    
format(bannedstring,sizeof bannedstring,"You are currently banned from this server.\r\nUser: %s \r\nIP: %s  \r\nTime: %s \r\nAdmin: %s\r\nReason: %s\r\nTBan End: in %i minutes"
    
PlayerName(targetid),playerIP,timeBanned,PlayerName(playerid),reason,time); 
    
ShowPlayerDialog(playerid,DIALOG_BANNED,DIALOG_STYLE_MSGBOX,"You have been banned!",bannedstring,"Leave",""); 
    return 
Kick(playerid); 

stock CheckBan(playerid

    new 
Query[256],playerIP[16],largestringtwo[256]; 
    
GetPlayerIp(playerid,playerIP,sizeof playerIP); 
    
mysql_format(mysql,Query,sizeof Query,"SELECT * FROM `banlog` WHERE `Name`='%e' OR `pIPBanned`='%e'",PlayerName(playerid),playerIP); 
    
mysql_tquery(mysql,Query,"OnPlayerBanned","i",playerid); 
    
mysql_format(mysql,Query,sizeof Query,"SELECT * FROM `tbanlog` WHERE `Name`='%e' OR `pIPBanned`='%e'",PlayerName(playerid),playerIP); 
    
mysql_tquery(mysql,Query,"OnPlayerTBanned","i",playerid); 
    return 
1

forward OnPlayerTBanned(playerid); 
public 
OnPlayerTBanned(playerid

    if(
cache_num_rows()) 
    { 
        new 
timeget cache_get_field_content_int(0,"pTBanEnd",mysql); 
        if(
gettime() < timeget
        { 
            new 
string[145]; 
            
format(string,sizeof string,"You are banned for another %i minutes!",timeget-gettime()); 
            return 
SendClientMessage(playerid,-1,string),Kick(playerid); 
        } 
        
mysql_format(mysql,Query,sizeof Query,"DELETE FROM `tbanlog` WHERE `Name`='%e'",PlayerName(playerid)); 
        
mysql_tquery(mysql,Query,"",""); 
    } 
    return 
1

Okk Hello
This is my script of temporary ban system
I am try to create the tBanEnd but it is not working

The tBanEnd ggot created as 0

What is wrong ?

Here is and the photo of my structure



But the tBanEnd stay 0

Thank you

EDIT:
An phooto of save also:



Please help meee fast
THank you
Reply
#2

Replace
PHP код:
if(sscanf(params,"uis[105",targetid,time,reason))return SendClientMessage(playerid,-1,""chat" /tban [playerid][times(minutes)][reason]"); 
with
PHP код:
if(sscanf(params,"uis[105]",targetid,time,reason))return SendClientMessage(playerid,-1,""chat" /tban [playerid][times(minutes)][reason]"); 
Reply
#3

Never mind.
Reply
#4

Still not work
Reply
#5

Hello!

TBanEnd must not be a string, but it must be an integer.

Mencent
Reply
#6

What is interger mencent bro ?

INT?
Reply
#7

PHP код:
stock TBanPlayer(targetid,playerid,reason[],admin[],time)
{
    new 
playerIP,Hour,Minute,Second,Year,Month,Day,timeBanned[80],bannedstring[256],Query[256];
    
GetPlayerIp(playerid,playerIP,sizeof playerIP);
    
gettime(Hour,Minute,Second);
    
getdate(Year,Month,Day);
    
format(timeBanned,sizeof timeBanned,"%02d:%02d:%02d on %02d/%02d/%d",Hour,Minute,Second,Day,Month,Year);
    
mysql_format(mysql,Query,sizeof Query,"INSERT INTO `tbanlog` (`Name`,`pBannedReason`,`pBannedBy`,`pTime`,`pIPBanned`,`pAccountLock`,`pTBanEnd`) VALUES ('%s','%s','%s','%s','%s',1,'%i')",
    
PlayerName(targetid),reason,PlayerName(playerid),timeBanned,playerIP,gettime() + (time*60));
    
mysql_tquery(mysql,Query);
    
format(bannedstring,sizeof bannedstring,"You are currently banned from this server.\r\nUser: %s \r\nIP: %s  \r\nTime: %s \r\nAdmin: %s\r\nReason: %s\r\nTBan End: in %i minutes",
    
PlayerName(targetid),playerIP,timeBanned,PlayerName(playerid),reason,time);
    
ShowPlayerDialog(playerid,DIALOG_BANNED,DIALOG_STYLE_MSGBOX,"You have been banned!",bannedstring,"Leave","");
    return 
Kick(playerid);

Like this: (%i)

Mencent
Reply
#8

Quote:
Originally Posted by Mencent
Посмотреть сообщение
PHP код:
stock TBanPlayer(targetid,playerid,reason[],admin[],time)
{
    new 
playerIP,Hour,Minute,Second,Year,Month,Day,timeBanned[80],bannedstring[256],Query[256];
    
GetPlayerIp(playerid,playerIP,sizeof playerIP);
    
gettime(Hour,Minute,Second);
    
getdate(Year,Month,Day);
    
format(timeBanned,sizeof timeBanned,"%02d:%02d:%02d on %02d/%02d/%d",Hour,Minute,Second,Day,Month,Year);
    
mysql_format(mysql,Query,sizeof Query,"INSERT INTO `tbanlog` (`Name`,`pBannedReason`,`pBannedBy`,`pTime`,`pIPBanned`,`pAccountLock`,`pTBanEnd`) VALUES ('%s','%s','%s','%s','%s',1,'%i')",
    
PlayerName(targetid),reason,PlayerName(playerid),timeBanned,playerIP,gettime() + (time*60));
    
mysql_tquery(mysql,Query);
    
format(bannedstring,sizeof bannedstring,"You are currently banned from this server.\r\nUser: %s \r\nIP: %s  \r\nTime: %s \r\nAdmin: %s\r\nReason: %s\r\nTBan End: in %i minutes",
    
PlayerName(targetid),playerIP,timeBanned,PlayerName(playerid),reason,time);
    
ShowPlayerDialog(playerid,DIALOG_BANNED,DIALOG_STYLE_MSGBOX,"You have been banned!",bannedstring,"Leave","");
    return 
Kick(playerid);

Like this: (%i)

Mencent
I used this!
But when i ban myself ro 1 min it ban mee 20 min
Reply
#9

What does it say now in the database?
And print this, what show this?
PHP код:
stock TBanPlayer(targetid,playerid,reason[],admin[],time)
{
    new 
playerIP,Hour,Minute,Second,Year,Month,Day,timeBanned[80],bannedstring[256],Query[256];
    
GetPlayerIp(playerid,playerIP,sizeof playerIP);
    
gettime(Hour,Minute,Second);
    
getdate(Year,Month,Day);
    
format(timeBanned,sizeof timeBanned,"%02d:%02d:%02d on %02d/%02d/%d",Hour,Minute,Second,Day,Month,Year);
    
mysql_format(mysql,Query,sizeof Query,"INSERT INTO `tbanlog` (`Name`,`pBannedReason`,`pBannedBy`,`pTime`,`pIPBanned`,`pAccountLock`,`pTBanEnd`) VALUES ('%s','%s','%s','%s','%s',1,'%i')",
    
PlayerName(targetid),reason,PlayerName(playerid),timeBanned,playerIP,gettime() + (time*60));
    
mysql_tquery(mysql,Query);
    
format(bannedstring,sizeof bannedstring,"You are currently banned from this server.\r\nUser: %s \r\nIP: %s  \r\nTime: %s \r\nAdmin: %s\r\nReason: %s\r\nTBan End: in %i minutes",
    
PlayerName(targetid),playerIP,timeBanned,PlayerName(playerid),reason,time);
    
ShowPlayerDialog(playerid,DIALOG_BANNED,DIALOG_STYLE_MSGBOX,"You have been banned!",bannedstring,"Leave","");
    
printf("gettime(): %i",gettime());
    
printf("gettime() + (%i*60): %i",gettime() + (time*60));
    return 
Kick(playerid);

Mencent
Reply
#10

Quote:
Originally Posted by Mencent
Посмотреть сообщение
What does it say now in the database?
And print this, what show this?
PHP код:
stock TBanPlayer(targetid,playerid,reason[],admin[],time)
{
    new 
playerIP,Hour,Minute,Second,Year,Month,Day,timeBanned[80],bannedstring[256],Query[256];
    
GetPlayerIp(playerid,playerIP,sizeof playerIP);
    
gettime(Hour,Minute,Second);
    
getdate(Year,Month,Day);
    
format(timeBanned,sizeof timeBanned,"%02d:%02d:%02d on %02d/%02d/%d",Hour,Minute,Second,Day,Month,Year);
    
mysql_format(mysql,Query,sizeof Query,"INSERT INTO `tbanlog` (`Name`,`pBannedReason`,`pBannedBy`,`pTime`,`pIPBanned`,`pAccountLock`,`pTBanEnd`) VALUES ('%s','%s','%s','%s','%s',1,'%i')",
    
PlayerName(targetid),reason,PlayerName(playerid),timeBanned,playerIP,gettime() + (time*60));
    
mysql_tquery(mysql,Query);
    
format(bannedstring,sizeof bannedstring,"You are currently banned from this server.\r\nUser: %s \r\nIP: %s  \r\nTime: %s \r\nAdmin: %s\r\nReason: %s\r\nTBan End: in %i minutes",
    
PlayerName(targetid),playerIP,timeBanned,PlayerName(playerid),reason,time);
    
ShowPlayerDialog(playerid,DIALOG_BANNED,DIALOG_STYLE_MSGBOX,"You have been banned!",bannedstring,"Leave","");
    
printf("gettime(): %i",gettime());
    
printf("gettime() + (%i*60): %i",gettime() + (time*60));
    return 
Kick(playerid);

Mencent
[14:38:15] Tiered has banned Tiered for 4 minutes [Reason: Test]
[14:38:15] gettime(): 1429965495
[14:38:15] gettime() + (1429965735*60):
[14:38:15] [part] Tiered has left the server (0:2)

It is print this
Reply


Forum Jump:


Users browsing this thread: