SA-MP Forums Archive
/tempban using dini in days - 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: /tempban using dini in days (/showthread.php?tid=363971)



/tempban using dini in days - mrsamp - 29.07.2012

So I want a tempban cmd for my server. /tempban <playerid> <days> <reason>
Could someone help me?


Really need it I'm not so pro so i can make it by myself
Код:
forward LoadPlayerData(playerid, name[], value[]);

enum pData
{
    pPassword,
    pAdmin,
    pMoney,
    pScore,
    pMute,
    pFrozen,
    pSpecating,
    pSkin,
    pWarn,
    pSpam,
    pDuty,
    VIP,
    pBan,
}
new P_Data[MAX_PLAYERS][pData];

public LoadPlayerData(playerid, name[], value[])
{
    INI_Int("Password", P_Data[playerid][pPassword]);
    INI_Int("Admin", P_Data[playerid][pAdmin]);
    INI_Int("Money", P_Data[playerid][pMoney]);
    INI_Int("Score", P_Data[playerid][pScore]);
    INI_Int("Skin", P_Data[playerid][pSkin]);
    INI_Int("Warn", P_Data[playerid][pWarn]);
    INI_Int("VIP", P_Data[playerid][VIP]);
    return 1;
}
stock GetName(playerid)
{
    new
        pName[MAX_PLAYER_NAME];

    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    return pName;
}

if(P_Data[playerid][pAdmin] < 1) return SCM(playerid, COLOR_RED, "You aren't an admin!");

//On my makeadmin command am i using this: (I want someting similiar to this but /tempban instead if you know that i mean... and the time: 1 day (24 hours) is 60 * 60 * 24 = 86400
YCMD:setadmin(playerid, params[], help)
{
        #pragma unused help
        if(P_Data[playerid][pAdmin] < 5 && !IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, "You need to be admin level 4/RCON to use this!");
        new
			string[128],pplayerid,level,pFile[35];
	    format(pFile, 35, Player_File, GetName(pplayerid));
        if(sscanf(params, "ui", pplayerid,level)) return SCM(playerid, COLOR_RED, "Usage: /setadmin [Player ID/Player Name] [Admin Level]");
        if(level > 5 || level <= 0) return SCM(playerid,COLOR_RED,"Max level is 5");
        if(pplayerid == IPI) return SCM(playerid, COLOR_RED, "Wrong playerid!");
        format(string,sizeof(string),""COL_RED"Admin "COL_WHITE"%s "COL_RED"has given you admin level"COL_WHITE" %d",GetName(playerid),level);
        SCM(pplayerid,-1,string);
        format(string,sizeof(string),""COL_RED"Player "COL_WHITE"%s "COL_RED"now have admin level"COL_WHITE" %d",GetName(pplayerid),level);
        SCM(playerid,-1,string);
    	new
    	INI:UserFile = INI_Open(pFile);
		INI_WriteInt(UserFile, "Admin", P_Data[pplayerid][pAdmin]);
		P_Data[pplayerid][pAdmin] = level;
  		INI_Close(UserFile);
        return 1;
}
The time:Here


Re: /tempban using dini in days - doreto - 29.07.2012

https://sampforum.blast.hk/showthread.php?tid=187229


Re: /tempban using dini in days - [MM]RoXoR[FS] - 29.07.2012

I will give you a tutorial on making a temp ban.



Re: /tempban using dini in days - mrsamp - 29.07.2012

I still need more help I think I failed at the connect...

Here's my OnPlayerConnect.
Код:
public OnPlayerConnect(playerid)
{
  new dialog[128],string[150],stringconsole[150],ip[16],name[20],country[20];
  format(string, 35, Player_File, GetName(playerid));

    if(!INI_Exists(string))
    {
        format(dialog, sizeof(dialog),""COL_BLUE"Name "COL_WHITE"%s "COL_YELLOW"isn't registered\n\nPlease typepassword", GetName(playerid));
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_RED"Welcome on my server", dialog, "Register", "Exit");
    }
    else
    {
        format(dialog, sizeof(dialog),""COL_YELLOW"Name "COL_WHITE"%s "COL_YELLOW"is registered\n\nPlease login", GetName(playerid));
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""COL_YELLOW"Welcome To Paradise City",dialog, "Login", "Exit");
 }
	SetPVarInt(playerid, "Join", 1);
	GetPlayerIp(playerid, ip, sizeof(ip));
	GetPlayerName(playerid,name,sizeof(name));
	GetPlayerCountry(playerid,country,sizeof(country));
	format(string, 150, "%s has Connected with ip: %s ", name, ip);	if(P_Data[playerid][pAdmin] < 1)
	format(stringconsole, 150, "[info]%s has Connected with ip: %s ", name, ip);	if(P_Data[playerid][pAdmin] < 1)
	printf(stringconsole);
	for(new i=0;i<MAX_PLAYERS;i++)
	{
 	if(P_Data[i][pAdmin] >= 1)
	 {
	SCM(i,COLOR_RED,string);
	 }
	}
  return 1;
}



Re: /tempban using dini in days - [MM]RoXoR[FS] - 29.07.2012

pawn Код:
public OnPlayerConnect(playerid)
{
  new dialog[128],string[150],stringconsole[150],ip[16],name[20],country[20];
  format(string, 35, Player_File, GetName(playerid));

    if(!INI_Exists(string))
    {
        format(dialog, sizeof(dialog),""COL_BLUE"Name "COL_WHITE"%s "COL_YELLOW"isn't registered\n\nPlease typepassword", GetName(playerid));
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_RED"Welcome on my server", dialog, "Register", "Exit");
    }
    else
    {
    //LOAD PLAYER DATA HERE maybe like   INI_ParseFile(string, "LoadPlayerData", .bExtra = true, .extra = playerid);
        new time = gettime();
        if((time - P_Data[playerid][B_Time]) < P_Data[playerid][B_Till] || P_Data[playerid][B_Till] == -1)
        {
            SendClientMessage(playerid,-1,"You are banned");
            Kick(playerid);
        }
        format(dialog, sizeof(dialog),""COL_YELLOW"Name "COL_WHITE"%s "COL_YELLOW"is registered\n\nPlease login", GetName(playerid));
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""COL_YELLOW"Welcome To Paradise City",dialog, "Login", "Exit");
    }
    SetPVarInt(playerid, "Join", 1);
    GetPlayerIp(playerid, ip, sizeof(ip));
    GetPlayerName(playerid,name,sizeof(name));
    GetPlayerCountry(playerid,country,sizeof(country));
    format(string, 150, "%s has Connected with ip: %s ", name, ip); if(P_Data[playerid][pAdmin] < 1)
    format(stringconsole, 150, "[info]%s has Connected with ip: %s ", name, ip);    if(P_Data[playerid][pAdmin] < 1)
    printf(stringconsole);
    for(new i=0;i<MAX_PLAYERS;i++)
    {
    if(P_Data[i][pAdmin] >= 1)
     {
    SCM(i,COLOR_RED,string);
     }
    }
  return 1;
}



Re: /tempban using dini in days - mrsamp - 29.07.2012

Thank you!
It seems like it's working now! But if I get any problems so will I contact you via pm!