SA-MP Forums Archive
[Include] infract.inc | Small Infraction System | V1 - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] infract.inc | Small Infraction System | V1 (/showthread.php?tid=442351)



infract.inc | Small Infraction System | V1 - Swyft™ - 07.06.2013

This is just a basic include for people that are making there own Admin systems, or such.


To use this include, simply add #include <infract after all of your includes

pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <infract> // At the bottom :) MUST be at the bottom

Here's a list of functions used

pawn Код:
GetPlayerInfractions(playerid); // This will get the players Infractions.

InfractPlayer(playerid); // This adds an infraction number to the player and all infractions are out of /3... Version 2, may have options to change it. It also may be possible to set a certain number of Infractions. But that is untested.

Basic example of using the commands

pawn Код:
CMD:infract(playerid, params[])
{
    new string[256], target, reason[128];
    if(IsPlayerAdmin(playerid))
    {
        if(!sscanf(params, "us[128]", target, reason)) return SendClientMessage(playerid, 0xFF0000FF, "[USAGE]{FFFFFF} /infract [id] [reason]");
        new pName[MAX_PLAYER_NAME], gName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(target, gName, MAX_PLAYER_NAME);
        InfractPlayer(target);
        format(string, sizeof(string), "{FF0000}%s has infracted %s (Reason: %s] [INFRACTIONS: %d/3]", pName, gName, reason, GetPlayerInfractions(target));
        SendClientMessageToAll(0xFF0000FF, string);
    }
    else return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]{FFFFFF} You have to be inside RCON");
    return 1;
}

CMD:myinfractions(playerid, params[])
{
    new string[64];
    format(string, sizeof(string), "You have (%d/3) infractions", GetPlayerInfractions(playerid));
    SendClientMessage(playerid, 0xFF0000FF, string);
    return 1;
}
INCLUDES

pawn Код:
/*
Infraction Sender created by Swyft
Created on June 6, 2013
*/


#include <a_samp>

#define GetPlayerInfractions(%0) infraction[(%0)]

forward InfractPlayer(playerid);
forward InfractTimer(playerid);

new infraction[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    infraction[playerid] = 0;
    return CallLocalFunction("Swyft_OnPlayerConnect", "d", playerid);
}
#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect Swyft_OnPlayerConnect
forward Swyft_OnPlayerConnect(playerid);

public InfractPlayer(playerid)
{
    SetTimerEx("InfractTImer",1000,false,"i",playerid) ;
    return 1;
}

public InfractTimer(playerid)
{
    infraction[playerid]++;
    return 1;
}

public OnPlayerUpdate(playerid)
{
    if(infraction[playerid] == 3) return Kick(playerid);
    return CallLocalFunction("Swyft_OnPlayerUpdate", "d", playerid);
}
#if defined _ALS_OnPlayerUpdate
    #undef OnPlayerUpdate
#else
    #define _ALS_OnPlayerUpdate
#endif
#define OnPlayerUpdate Swyft_OnPlayerUpdate
forward Swyft_OnPlayerUpdate(playerid);

stock OnPlayerInfraction(playerid) { return InfractPlayer(playerid); }



Re: infract.inc | Small Infraction System | V1 - mineralo - 07.06.2013

pawn Код:
public InfractPlayer(playerid)
{
    SetTimer("InfractTimer",1000,false);
    return 1;
}
here you failed a bit, the gm or will crash or won't work the function
should be
SetTimerEx("InfractTImer",1000,false,"i",playerid) ;


Re: infract.inc | Small Infraction System | V1 - Swyft™ - 07.06.2013

Oh shit, I'm so sorry.. Fixed


Re: infract.inc | Small Infraction System | V1 - xser12 - 07.06.2013

nice job


Re: infract.inc | Small Infraction System | V1 - JaKe Elite - 07.06.2013

not bad however.
There are some fail parts here.
And this include can be done even in a new script.

Well, for now, 4.5/10


Re: infract.inc | Small Infraction System | V1 - Swyft™ - 07.06.2013

@******
Actually yes, it works.... Infact, I have even made an Infraction System with the infractions saved and it works beautifully.

@_Jake_
Well this is my first include, I had to get Emmet to help me on some parts.. Mainly for _ALS_, he tested it, works for him.