[Include] KickEx
#1

KickEx(playerid, reason[]);

So KickEx(); is basically the same thing as BanEx(); except it creates a .txt file in your scriptfiles, named KickEx.txt, and displays the date, name of the player that got kicked, and the reason.

Here's an example.

Код:
[23/10/2010] John_Doe kicked for: Test
The file will be located in:

Код:
Server/scriptfiles/KickEx.txt
So you can see all the kicks that were called by using KickEx();

How to use:
Add this at the top of your script:

pawn Код:
#include KickEx
Then use the KickEx(); function in a callback or a command like this.

pawn Код:
#include <KickEx>
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        KickEx(playerid, "Test");
        return 1;
    }
    return 0;
}
or

pawn Код:
#include <KickEx>
public OnPlayerUpdate(playerid)
{
    if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK) // Checks if they are using jetpack.
    {
        KickEx(playerid, "Jetpack"); // Kick the player using KickEx();
    }
    return 1;
}
Download the example filterscript and include below If you want to.

Quick Preview:

pawn Код:
/* KickEx Function
 *
 * © Copyright 2009-2010, TheHoodRat SA:MP
 * This file is provided as is (no warranties).
 */


#include <a_samp>
#include <file>

#if defined _KickEx_included
#endinput
#endif
#define _KickEx_included

forward NewLine();

stock KickEx(playerid, reason[]) // KickEx is our handy function.
{//Let's see the code then!
   #pragma tabsize 0
    new PlayerName[24]; // Define the player's name.
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    new year, month, day; // We want to know the date that the user got kicked, right?
    getdate(year, month, day); // Now we know the real date because of this handy function.
    { // Then...
    new text[128]; // Length of the text (128 characters)
    new File:log = fopen("KickEx.txt", io_write); // Open the file.
    format(text, sizeof(text), "[%d/%d/%d] %s kicked for: %s\r\n",day,month,year,PlayerName,reason); // Displayed in the file.
    fwrite(log, text); // Write to the file.
    fclose(log); // Close the file.
    NewLine();
    Kick(playerid); // Kick the player.
} // Curly brace to close the script.
    return 1;
}

public NewLine()
{
    new File:hFile;
    hFile = fopen("KickEx.txt", io_append);
    fwrite(hFile, "\n");
    fclose(hFile);
}
DOWNLOAD USING SOLIDFILES!
DOWNLOAD USING PASTEBIN!
Reply
#2

You could easily use "gettime" and then blah, blah...

pawn Код:
#pragma tabsize 0
/facepalm
Reply
#3

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
You could easily use "gettime" and then blah, blah...

pawn Код:
#pragma tabsize 0
/facepalm
Actually I had to do that for a reason. I couldn't find where the loose indentation, I even went on the right line and nothing wrong... It's retarded.

/facepalm = gtfo.
Reply
#4

Nice. It's funny, I just wanted to make one too, but I see you already made it :P
And btw, you can save diskspace. Remove the '#include <file>' -> It's already included in 'a_samp'

Maybe you can better use this one

pawn Код:
/* KickEx Function
 *
 * © Copyright 2009-2010, TheHoodRat SA:MP
 * This file is provided as is (no warranties).
*/


#include <a_samp>

#if defined _KickEx_included
#endinput
#endif
#define _KickEx_included

stock KickEx(playerid, const reason[])
{
    if(!IsPlayerConnected(playerid) || playerid == INVALID_PLAYER_ID) return 0;
    new pName[MAX_PLAYER_NAME], Year, Month, Day, Hour, Minutes, Seconds, string[288], File:kicklog;
    gettime(Hour, Minutes, Seconds); getdate(Year, Month, Date);
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(string, sizeof(string), "[%d-%d-%d %d:%d:%d] %s - %s\r\n", Day, Month, Year, Hours, Minutes, Seconds, pName, reason);
    kicklog = fopen("KickEx.txt", io_append); //IO_APPEND!
    fwrite(kicklog, string); fclose(kicklog);
    Kick(playerid);
    return true;
}
And btw sorry.
This script isn't really good.

1) You had 'io_write' -> This will now only write one line. So you don't see older kicks
2) includes A_SAMP + FILE -> Diskspace :O
3) Only date. Date+Time = handier
4) No check for invalid player.

If you don't matter, I am gonna place one too, a better one.
And btw, Are you new in scripting, or not? Thanks in advance (for answering)

Kind Regards,
Kevin aka Kwarde
Reply
#5

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
Nice. It's funny, I just wanted to make one too, but I see you already made it :P
And btw, you can save diskspace. Remove the '#include <file>' -> It's already included in 'a_samp'
/facepalm.

I know, I was just... tired... again...

Like always. I don't know much about a_samp.
Reply
#6

Sorry man. I wished I could say it was good. By what way, here's my version
http://forum.sa-mp.com/showthread.ph...543#post882543

This forum requires that you wait 120 seconds between posts. Please try again in 87 seconds.
Owkeuj
Reply
#7

Quote:
Originally Posted by TheHoodRat
Посмотреть сообщение
Actually I had to do that for a reason. I couldn't find where the loose indentation, I even went on the right line and nothing wrong... It's retarded.

/facepalm = gtfo.
It just shows laziness... Continue doing it if you want, but if you learn good indentation skills then you won't get errors like that. (believe me, it aint' hard)
Reply
#8

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
It just shows laziness... Continue doing it if you want, but if you learn good indentation skills then you won't get errors like that. (believe me, it aint' hard)
I agree. I need to learn indentation skills because I suck dick when it comes to indentation...
Reply
#9

pawn Код:
/* KickEx Function
 *
 * © Copyright 2009-2010, TheHoodRat SA:MP
 * This file is provided as is (no warranties).
 */


#include <a_samp>
#if defined _KickEx_included
#endinput
#endif
#define _KickEx_included

forward NewLine();

stock KickEx(playerid, reason[]) // KickEx is our handy function.
    {//Let's see the code then!
    new PlayerName[24]; // Define the player's name.
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    new year, month, day; // We want to know the date that the user got kicked, right?
    getdate(year, month, day); // Now we know the real date because of this handy function.
    { // Then...
    new text[128]; // Length of the text (128 characters)
    new File:log = fopen("KickEx.txt", io_write); // Open the file.
    format(text, sizeof(text), "[%d/%d/%d] %s kicked for: %s\r\n",day,month,year,PlayerName,reason); // Displayed in the file.
    fwrite(log, text); // Write to the file.
    fclose(log); // Close the file.
    NewLine();
    Kick(playerid); // Kick the player.
    } // Curly brace to close the script.
    return 1;
}

public NewLine()
{
    new File:hFile;
    hFile = fopen("KickEx.txt", io_append);
    fwrite(hFile, "\n");
    fclose(hFile);
}
I guess the only problem with your indentation was simply, the braces of the stocking...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)