[Include] infract.inc | Small Infraction System | V1
#1

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); }
Reply
#2

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) ;
Reply
#3

Oh shit, I'm so sorry.. Fixed
Reply
#4

nice job
Reply
#5

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
Reply
#6

@******
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)