Comanda /TempBan

Started by _Mihai_, Apr 14, 2013, 10:45 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Apr 14, 2013, 10:45 AM Last Edit: Sep 05, 2013, 02:03 PM by Gireada
                                                      Script  /TempBan
if(strcmp(cmd, "/tempban", true) == 0)
   {
      new name[MAX_PLAYER_NAME];
      new giveplayer[MAX_PLAYER_NAME];
      new giveplayerid;

      if(PlayerInfo[playerid][pAdmin] >= 10);
      {
         tmp = strtok(cmdtext,idx);
         if(!strlen(tmp))
         {
              SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /tempban [playerid] [Day(s)] [Reason]");
            SendClientMessage(playerid, COLOR_ORANGE, "Function: Temporarily bans a player for specified Days");
            return 1;
         }
         giveplayerid = ReturnUser(tmp);
         if(IsPlayerConnected(giveplayerid))
         {
             tmp = strtok(cmdtext, idx);
             if (!strlen(tmp))
             {
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /tempban [playerID] [Day(s)] [Reason]");
            SendClientMessage(playerid, COLOR_ORANGE, "Function: Temporarily bans a player for specified Days");
            return 1;
            }
            new days = strval(tmp);
            if(!IsNumeric(tmp))
            return SendClientMessage(playerid, COLOR_LIGHTRED, "ERROR: Invalid Day! Only Numbers!");

            if(strval(tmp) <= 0 || strval(tmp) > 1000)
            return SendClientMessage(playerid, COLOR_LIGHTRED, "ERROR: Invalid Day! (1-1000)");

            new reason[128];
            reason = strtok2(cmdtext,idx);
            if (!strlen(reason))
            return SendClientMessage(playerid, COLOR_LIGHTRED, "ERROR: Reason not Specified!");

            if (strlen(reason) <= 0 || strlen(reason) > 100)
            return SendClientMessage(playerid, COLOR_LIGHTRED, "ERROR: Invalid Reason length!");

            new ip[15];
            GetPlayerIp(giveplayerid,ip,15);
            GetPlayerName(playerid, name, sizeof name);
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            new File:tempban = fopen("LuxAdmin/Config/TempBans.ban", io_append);
            if (tempban)
            {
                new year,month,day;
                getdate(year, month, day);
                day += days;
                if (IsMonth31(month))
                {
                    if (day > 31)
                    {
                        month += 1;
                        if (month > 12)
                        {
                            year += 1;
                            while(day > 31) day -= 31;
                        }
                        else while(day > 31) day -= 31;
                    }
                }
                else if (!IsMonth31(month))
                {
                    if (day > 30)
                    {
                        month += 1;
                        if (month > 12)
                        {
                            year += 1;
                            while(day > 30) day -= 30;
                        }
                        else while(day > 30) day -= 30;
                    }
                }
                else if (!IsMonth31(month) && IsMonth29(year) && month == 2)
                {
                    if (day > 29)
                    {
                        month += 1;
                        if (month > 12)
                        {
                            year += 1;
                            while(day > 29) day -= 29;
                        }
                        else while(day > 29) day -= 29;
                    }
                }
                else if (!IsMonth31(month) && !IsMonth29(year) && month == 2)
                {
                    if (day > 28)
                    {
                        month += 1;
                        if (month > 12)
                        {
                            year += 1;
                            while(day > 28) day -= 28;
                        }
                        else while(day > 28) day -= 28;
                    }
                }
                format(string, sizeof string, "%d|%d|%d|%s\n", day, month, year, ip);
                fwrite(tempban, string);
                fclose(tempban);
            }
            format(string,128,"|- Administrator %s Temporarily Banned %s for %d day(s) | Reason: %s -|",name,giveplayer,days,reason);
            SendClientMessageToAll(grey,string);
            Kick(giveplayerid);

             format(string, sizeof string, "Admin %s Temporarily Banned %s for %d day(s) | Reason: %s",name,giveplayer,days,reason);
             SaveIn("TempBansLog",string);
         }
         else
         {
         ErrorMessages(playerid, 2);
         }
      }
      else ErrorMessages(playerid, 1);
   }
      return true;
   }
[shadow=red,left]E mai bine sa taci si sa fii luat drept prost, decat sa vorbesti si sa inlaturi orice dubii[/shadow]

Quote from: _Mihai_ on Apr 14, 2013, 10:45 AM
                                                      Script  /TempBan
if(strcmp(cmd, "/tempban", true) == 0)
   {
      new name[MAX_PLAYER_NAME];
      new giveplayer[MAX_PLAYER_NAME];
      new giveplayerid;

      if(PlayerInfo[playerid][pAdmin] >= 10);
      {
         tmp = strtok(cmdtext,idx);
         if(!strlen(tmp))
         {
              SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /tempban [playerid] [Day(s)] [Reason]");
            SendClientMessage(playerid, COLOR_ORANGE, "Function: Temporarily bans a player for specified Days");
            return 1;
         }
         giveplayerid = ReturnUser(tmp);
         if(IsPlayerConnected(giveplayerid))
         {
             tmp = strtok(cmdtext, idx);
             if (!strlen(tmp))
             {
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /tempban [playerID] [Day(s)] [Reason]");
            SendClientMessage(playerid, COLOR_ORANGE, "Function: Temporarily bans a player for specified Days");
            return 1;
            }
            new days = strval(tmp);
            if(!IsNumeric(tmp))
            return SendClientMessage(playerid, COLOR_LIGHTRED, "ERROR: Invalid Day! Only Numbers!");

            if(strval(tmp) <= 0 || strval(tmp) > 1000)
            return SendClientMessage(playerid, COLOR_LIGHTRED, "ERROR: Invalid Day! (1-1000)");

            new reason[128];
            reason = strtok2(cmdtext,idx);
            if (!strlen(reason))
            return SendClientMessage(playerid, COLOR_LIGHTRED, "ERROR: Reason not Specified!");

            if (strlen(reason) <= 0 || strlen(reason) > 100)
            return SendClientMessage(playerid, COLOR_LIGHTRED, "ERROR: Invalid Reason length!");

            new ip[15];
            GetPlayerIp(giveplayerid,ip,15);
            GetPlayerName(playerid, name, sizeof name);
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            new File:tempban = fopen("LuxAdmin/Config/TempBans.ban", io_append);
            if (tempban)
            {
                new year,month,day;
                getdate(year, month, day);
                day += days;
                if (IsMonth31(month))
                {
                    if (day > 31)
                    {
                        month += 1;
                        if (month > 12)
                        {
                            year += 1;
                            while(day > 31) day -= 31;
                        }
                        else while(day > 31) day -= 31;
                    }
                }
                else if (!IsMonth31(month))
                {
                    if (day > 30)
                    {
                        month += 1;
                        if (month > 12)
                        {
                            year += 1;
                            while(day > 30) day -= 30;
                        }
                        else while(day > 30) day -= 30;
                    }
                }
                else if (!IsMonth31(month) && IsMonth29(year) && month == 2)
                {
                    if (day > 29)
                    {
                        month += 1;
                        if (month > 12)
                        {
                            year += 1;
                            while(day > 29) day -= 29;
                        }
                        else while(day > 29) day -= 29;
                    }
                }
                else if (!IsMonth31(month) && !IsMonth29(year) && month == 2)
                {
                    if (day > 28)
                    {
                        month += 1;
                        if (month > 12)
                        {
                            year += 1;
                            while(day > 28) day -= 28;
                        }
                        else while(day > 28) day -= 28;
                    }
                }
                format(string, sizeof string, "%d|%d|%d|%s\n", day, month, year, ip);
                fwrite(tempban, string);
                fclose(tempban);
            }
            format(string,128,"|- Administrator %s Temporarily Banned %s for %d day(s) | Reason: %s -|",name,giveplayer,days,reason);
            SendClientMessageToAll(grey,string);
            Kick(giveplayerid);

             format(string, sizeof string, "Admin %s Temporarily Banned %s for %d day(s) | Reason: %s",name,giveplayer,days,reason);
             SaveIn("TempBansLog",string);
         }
         else
         {
         ErrorMessages(playerid, 2);
         }
      }
      else ErrorMessages(playerid, 1);
   }
      return true;
   }

Nui Buna:|
Trebe sa mai aibe niste public stock .

@ [SLG]Johnny...
La asta ce ii lipseste?
:)


#include <a_samp>

forward SaveIn(filename[],text[]);
new tmp[256],idx,string[256];

public OnPlayerCommandText(playerid,cmdtext[])
{
if(strcmp(cmdtext,"/tempban",true)==0)
{
new name[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new giveplayerid;
if(IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, -1, "[Folosire corecta:] /tempban [ID Player] [Zile] [Motiv]");
SendClientMessage(playerid, -1, "[Ce face comanda?:] Baneaza un player timp de un numar specificat de zile.");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
tmp = strtok(cmdtext, idx);
if (!strlen(tmp))
{
SendClientMessage(playerid, -1, "[Folosire corecta:] /tempban [ID Player] [Zile] [Motiv]");
SendClientMessage(playerid, -1, "[Ce face comanda?:] Baneaza un player timp de un numar specificat de zile.");
return 1;
}
new days = strval(tmp);
if(!IsNumeric(tmp))
return SendClientMessage(playerid, -1, "[EROARE:] Zi invalida! La aceasta comanda se specifica zilele doar in numere!");

if(strval(tmp) <= 0 || strval(tmp) > 1000)
return SendClientMessage(playerid, -1, "[EROARE:] Zi invalida! (1-1000)");

new reason[128];
reason = strtok2(cmdtext,idx);
if (!strlen(reason))
return SendClientMessage(playerid, -1, "[EROARE:] Playerul nu a fost specificat!");

if (strlen(reason) <= 0 || strlen(reason) > 100)
return SendClientMessage(playerid, -1, "[EROARE:] Marime motiv incorecta!");

new ip[15];
GetPlayerIp(giveplayerid,ip,15);
GetPlayerName(playerid, name, sizeof name);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
new File:tempban = fopen("LuxAdmin/Config/TempBans.ban", io_append);
if (tempban)
{
new year,month,day;
getdate(year, month, day);
day += days;
if (IsMonth31(month))
{
if (day > 31)
{
month += 1;
if (month > 12)
{
year += 1;
while(day > 31) day -= 31;
}
else while(day > 31) day -= 31;
}
}
else if (!IsMonth31(month))
{
if (day > 30)
{
month += 1;
if (month > 12)
{
year += 1;
while(day > 30) day -= 30;
}
else while(day > 30) day -= 30;
}
}
else if (!IsMonth31(month) && IsMonth29(year) && month == 2)
{
if (day > 29)
{
month += 1;
if (month > 12)
{
year += 1;
while(day > 29) day -= 29;
}
else while(day > 29) day -= 29;
}
}
else if (!IsMonth31(month) && !IsMonth29(year) && month == 2)
{
if (day > 28)
{
month += 1;
if (month > 12)
{
year += 1;
while(day > 28) day -= 28;
}
else while(day > 28) day -= 28;
}
}
format(string, sizeof string, "%d|%d|%d|%s\n", day, month, year, ip);
fwrite(tempban, string);
fclose(tempban);
}
format(string,128,"|- Administratorul [%s] L-a banat temporar pe [%s] timp de [%d] zile | Motiv: %s -|",name,giveplayer,days,reason);
SendClientMessageToAll(-1,string);
Kick(giveplayerid);

format(string, sizeof string, "Admin [%s] L-a banat pe [%s] timp de [%d] Zile | Motiv: %s",name,giveplayer,days,reason);
SaveIn("TempBansLog",string);
}
else
{
ErrorMessages(playerid, 2);
}
}
else ErrorMessages(playerid, 1);
}
//return true;
//}
return 0;
}
stock IsMonth29(year)
{
new y = 2000;
for(new i = 4; i < 3000; i += 4) if ((y+i) == year) return 1;
return 0;
}
stock strtok2(const string6[], &idx2)
{
new length = strlen(string6);
while ((idx2 < length) && (string6[idx2] <= ' '))
{
idx2++;
}
new offset = idx2;
new result[128];
while ((idx2 < length) && ((idx2 - offset) < (sizeof(result) - 1)))
{
result[idx2 - offset] = string6[idx2];
idx2++;
}
result[idx2 - offset] = EOS;
return result;
}
stock IsMonth31(month)
{
switch (month)
{
case 1: return 1;
case 3: return 1;
case 5: return 1;
case 7: return 1;
case 8: return 1;
case 10: return 1;
case 12: return 1;
default: return 0;
}
return 0;
}
stock strtok(const string3[], &index)
{
new length = strlen(string3);
while ((index < length) && (string3[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string3[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string3[index];
index++;
}
result[index - offset] = EOS;
return result;
}

ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
new pos = 0;
while (text[pos] < 0x21)
{
if (text[pos] == 0) return INVALID_PLAYER_ID;
pos++;
}
new userid = INVALID_PLAYER_ID;
if (IsNumeric(text[pos]))
{
userid = strval(text[pos]);
if (userid >=0 && userid < MAX_PLAYERS)
{
if(!IsPlayerConnected(userid))
userid = INVALID_PLAYER_ID;
else return userid;
}
}
new len = strlen(text[pos]);
new count = 0;
new pname[MAX_PLAYER_NAME];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i, pname, sizeof (pname));
if (strcmp(pname, text[pos], true, len) == 0)
{
if (len == strlen(pname)) return i;
else
{
count++;
userid = i;
}
}
}
}
if (count != 1)
{
if (playerid != INVALID_PLAYER_ID)
{
if (count) SendClientMessage(playerid, -1, "[EROARE:] Sunt utilizatori multiplii, te rog introdu intregul nume.");
}
userid = INVALID_PLAYER_ID;
}
return userid;
}

IsNumeric(const string4[])
{
for (new i = 0, j = strlen(string4); i < j; i++)
{
if (string4[i] > '9' || string4[i] < '0') return 0;
}
return 1;
}

stock ErrorMessages(playerid, errorID)
{
if(errorID == 2) return SendClientMessage(playerid,-1,"[EROARE:] Playerul nu e conectat!");
return 1;
}
public SaveIn(filename[],text[])
{
new File:Lfile;
new filepath[256];
new year,month,day;
new hour,minute,second;
getdate(year,month,day);
gettime(hour,minute,second);
format(filepath,sizeof(filepath),"LuxAdmin/Logs/%s.txt",filename);
Lfile = fopen(filepath,io_append);
format(string,sizeof(string),"[%02d/%02d/%02d | %02d:%02d:%02d] %s\r\n",day,month,year,hour,minute,second,text);
fwrite(Lfile,string);
fclose(Lfile);
return 1;
}


http://www.solidfiles.com/d/881fe17e9c/tempban2.pwn

Daca merge, comanda e folositoare ;)

Quote from: Corey on May 03, 2014, 11:35 PM
@ [SLG]Johnny...
La asta ce ii lipseste?
:)


#include <a_samp>

forward SaveIn(filename[],text[]);
new tmp[256],idx,string[256];

public OnPlayerCommandText(playerid,cmdtext[])
{
if(strcmp(cmdtext,"/tempban",true)==0)
{
new name[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new giveplayerid;
if(IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, -1, "[Folosire corecta:] /tempban [ID Player] [Zile] [Motiv]");
SendClientMessage(playerid, -1, "[Ce face comanda?:] Baneaza un player timp de un numar specificat de zile.");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
tmp = strtok(cmdtext, idx);
if (!strlen(tmp))
{
SendClientMessage(playerid, -1, "[Folosire corecta:] /tempban [ID Player] [Zile] [Motiv]");
SendClientMessage(playerid, -1, "[Ce face comanda?:] Baneaza un player timp de un numar specificat de zile.");
return 1;
}
new days = strval(tmp);
if(!IsNumeric(tmp))
return SendClientMessage(playerid, -1, "[EROARE:] Zi invalida! La aceasta comanda se specifica zilele doar in numere!");

if(strval(tmp) <= 0 || strval(tmp) > 1000)
return SendClientMessage(playerid, -1, "[EROARE:] Zi invalida! (1-1000)");

new reason[128];
reason = strtok2(cmdtext,idx);
if (!strlen(reason))
return SendClientMessage(playerid, -1, "[EROARE:] Playerul nu a fost specificat!");

if (strlen(reason) <= 0 || strlen(reason) > 100)
return SendClientMessage(playerid, -1, "[EROARE:] Marime motiv incorecta!");

new ip[15];
GetPlayerIp(giveplayerid,ip,15);
GetPlayerName(playerid, name, sizeof name);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
new File:tempban = fopen("LuxAdmin/Config/TempBans.ban", io_append);
if (tempban)
{
new year,month,day;
getdate(year, month, day);
day += days;
if (IsMonth31(month))
{
if (day > 31)
{
month += 1;
if (month > 12)
{
year += 1;
while(day > 31) day -= 31;
}
else while(day > 31) day -= 31;
}
}
else if (!IsMonth31(month))
{
if (day > 30)
{
month += 1;
if (month > 12)
{
year += 1;
while(day > 30) day -= 30;
}
else while(day > 30) day -= 30;
}
}
else if (!IsMonth31(month) && IsMonth29(year) && month == 2)
{
if (day > 29)
{
month += 1;
if (month > 12)
{
year += 1;
while(day > 29) day -= 29;
}
else while(day > 29) day -= 29;
}
}
else if (!IsMonth31(month) && !IsMonth29(year) && month == 2)
{
if (day > 28)
{
month += 1;
if (month > 12)
{
year += 1;
while(day > 28) day -= 28;
}
else while(day > 28) day -= 28;
}
}
format(string, sizeof string, "%d|%d|%d|%s\n", day, month, year, ip);
fwrite(tempban, string);
fclose(tempban);
}
format(string,128,"|- Administratorul [%s] L-a banat temporar pe [%s] timp de [%d] zile | Motiv: %s -|",name,giveplayer,days,reason);
SendClientMessageToAll(-1,string);
Kick(giveplayerid);

format(string, sizeof string, "Admin [%s] L-a banat pe [%s] timp de [%d] Zile | Motiv: %s",name,giveplayer,days,reason);
SaveIn("TempBansLog",string);
}
else
{
ErrorMessages(playerid, 2);
}
}
else ErrorMessages(playerid, 1);
}
//return true;
//}
return 0;
}
stock IsMonth29(year)
{
new y = 2000;
for(new i = 4; i < 3000; i += 4) if ((y+i) == year) return 1;
return 0;
}
stock strtok2(const string6[], &idx2)
{
new length = strlen(string6);
while ((idx2 < length) && (string6[idx2] <= ' '))
{
idx2++;
}
new offset = idx2;
new result[128];
while ((idx2 < length) && ((idx2 - offset) < (sizeof(result) - 1)))
{
result[idx2 - offset] = string6[idx2];
idx2++;
}
result[idx2 - offset] = EOS;
return result;
}
stock IsMonth31(month)
{
switch (month)
{
case 1: return 1;
case 3: return 1;
case 5: return 1;
case 7: return 1;
case 8: return 1;
case 10: return 1;
case 12: return 1;
default: return 0;
}
return 0;
}
stock strtok(const string3[], &index)
{
new length = strlen(string3);
while ((index < length) && (string3[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string3[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string3[index];
index++;
}
result[index - offset] = EOS;
return result;
}

ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
new pos = 0;
while (text[pos] < 0x21)
{
if (text[pos] == 0) return INVALID_PLAYER_ID;
pos++;
}
new userid = INVALID_PLAYER_ID;
if (IsNumeric(text[pos]))
{
userid = strval(text[pos]);
if (userid >=0 && userid < MAX_PLAYERS)
{
if(!IsPlayerConnected(userid))
userid = INVALID_PLAYER_ID;
else return userid;
}
}
new len = strlen(text[pos]);
new count = 0;
new pname[MAX_PLAYER_NAME];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i, pname, sizeof (pname));
if (strcmp(pname, text[pos], true, len) == 0)
{
if (len == strlen(pname)) return i;
else
{
count++;
userid = i;
}
}
}
}
if (count != 1)
{
if (playerid != INVALID_PLAYER_ID)
{
if (count) SendClientMessage(playerid, -1, "[EROARE:] Sunt utilizatori multiplii, te rog introdu intregul nume.");
}
userid = INVALID_PLAYER_ID;
}
return userid;
}

IsNumeric(const string4[])
{
for (new i = 0, j = strlen(string4); i < j; i++)
{
if (string4[i] > '9' || string4[i] < '0') return 0;
}
return 1;
}

stock ErrorMessages(playerid, errorID)
{
if(errorID == 2) return SendClientMessage(playerid,-1,"[EROARE:] Playerul nu e conectat!");
return 1;
}
public SaveIn(filename[],text[])
{
new File:Lfile;
new filepath[256];
new year,month,day;
new hour,minute,second;
getdate(year,month,day);
gettime(hour,minute,second);
format(filepath,sizeof(filepath),"LuxAdmin/Logs/%s.txt",filename);
Lfile = fopen(filepath,io_append);
format(string,sizeof(string),"[%02d/%02d/%02d | %02d:%02d:%02d] %s\r\n",day,month,year,hour,minute,second,text);
fwrite(Lfile,string);
fclose(Lfile);
return 1;
}


http://www.solidfiles.com/d/881fe17e9c/tempban2.pwn
Nimic.