How to add filterscript to GM?
#1

Hello guys,

I want to add this filterscript to my gamemode:
http://pastebin.com/MZEz8FCB

-.. But i don't want to add it as a Filterscript, I want to merge it with my gamemode. Could someone please tell me where each part goes in the comments below?

Thank you!
Reply
#2

Since this is a business System, First make sure to have all includes in your GameMode, If you don't have them, Add them in the top and make sure to download the includes and place them into Pawno > Includes Folder.
When you've done that, You can start adding Colors, I'm sure you have most of them defined already, After that you can start copying the rest of things.
Remove this
pawn Код:
#
public OnFilterScriptInit()
#
{
#
    LoadBiz();
#
        print("\n--------------------------------------");
#
        print(" Business System By Mariooo");
#
        print("--------------------------------------\n");
#
        return 1;
#
}
#
 
#
public OnFilterScriptExit()
#
{
#
    SaveBiz();
#
        return 1;
#
}
Add this
pawn Код:
#
// Biz Defines
#
#define MAX_BIZ 201
#
#define COE "{F07B0F}"
#
#define CWE "{FFFFFF}"
#
#define CGE "{2A8A07}"
#
 
#
enum pInfo
#
{
#
        pAdmin,
#
        pCash,
#
    pBiz,
#
    pMaskOn,
#
    pHideOn,
#
    pVBiz
#
};
#
new PlayerInfo[MAX_PLAYERS][pInfo];
#
 
#
enum bizInfo
#
{
#
        bType,
#
        bStatus,
#
        bOwner[32],
#
        Float:bX,
#
        Float:bY,
#
        Float:bZ,
#
        bPickup,
#
        bMoney,
#
        bProducts,
#
        Text3D:bText,
#
        bSold,
#
        bLevel,
#
        bPrice,
#
        bAP
#
}
#
new BizInfo[MAX_BIZ][bizInfo];
#
stock CheckFiles()
#
{
#
    if(!dini_Exists("businesses.cfg")) dini_Create("businesses.cfg");
#
    return 1;
#
}
#
stock LoadBiz()
#
{
#
    if(!fexist("businesses.cfg")) fcreate("businesses.cfg");
#
        new binfo[12][32];
#
        new string[256];
#
        new File:file = fopen("businesses.cfg", io_read);
#
        if(file)
#
        {
#
            new idx = 1;
#
                while(idx < MAX_BIZ)
#
                {
#
                    fread(file, string);
#
                    split(string, binfo, '|');
#
                    BizInfo[idx][bType] = strval(binfo[0]);
#
                    BizInfo[idx][bStatus] = strval(binfo[1]);
#
                    format(BizInfo[idx][bOwner], 32, "%s", binfo[2]);
#
                    BizInfo[idx][bX] = floatstr(binfo[3]);
#
                    BizInfo[idx][bY] = floatstr(binfo[4]);
#
                    BizInfo[idx][bZ] = floatstr(binfo[5]);
#
                    BizInfo[idx][bMoney] = strval(binfo[6]);
#
                    BizInfo[idx][bProducts] = strval(binfo[7]);
#
                    BizInfo[idx][bSold] = strval(binfo[8]);
#
                    BizInfo[idx][bLevel] = strval(binfo[9]);
#
                    BizInfo[idx][bPrice] = strval(binfo[10]);
#
                    BizInfo[idx][bAP] = strval(binfo[11]);
#
                    if(BizInfo[idx][bType]) // If Business is owned
#
                    {
#
                        BizInfo[idx][bPickup] = CreateDynamicPickup(1272, 1, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], 0);
#
                        if(!strcmp("The State", BizInfo[idx][bOwner])) format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", idx, RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice]);
#
                                //else format(string, sizeof(string), "ID: %d\n%s\nOwner: %s\nStatus: %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
#
                                else format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
#
                        BizInfo[idx][bText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]+0.3, 15);
#
                        }
#
                        idx++;
#
            }
#
        }
#
        print("Businesses loaded successfully.");
#
        return 1;
#
}
#
 
#
stock SaveBiz()
#
{
#
    if(!fexist("businesses.cfg")) fcreate("businesses.cfg");
#
        new idx = 1, File:file;
#
        new string[256];
#
        while(idx < MAX_BIZ)
#
        {
#
            format(string, sizeof(string), "%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%d\r\n", BizInfo[idx][bType], BizInfo[idx][bStatus], BizInfo[idx][bOwner], BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], BizInfo[idx][bMoney], BizInfo[idx][bProducts], BizInfo[idx][bSold], BizInfo[idx][bLevel], BizInfo[idx][bPrice], BizInfo[idx][bAP]);
#
            if(idx == 1)
#
            {
#
                file = fopen("businesses.cfg", io_write);
#
            }
#
            else
#
            {
#
                file = fopen("businesses.cfg", io_append);
#
            }
#
                fwrite(file, string);
#
                fclose(file);
#
                idx++;
#
        }
#
        print("Businesses saved successfully.");
#
}
#
#
stock fcreate(filename[])
#
{
#
        if (fexist(filename)) return false;
#
        new File:fhnd;
#
        fhnd=fopen(filename,io_write);
#
        if (fhnd) {
#
                fclose(fhnd);
#
                return true;
#
        }
#
        return false;
#
}
#
stock RBT(bizid)
#
{
#
        new string[24];
#
        if(!BizInfo[bizid][bType]) format(string, sizeof(string), "None");
#
    else if(BizInfo[bizid][bType] == 1) format(string, sizeof(string), "24/7 Market");
#
    else if(BizInfo[bizid][bType] == 2) format(string, sizeof(string), "Clothes Shop");
#
    else if(BizInfo[bizid][bType] == 3) format(string, sizeof(string), "Ammunation");
#
    else if(BizInfo[bizid][bType] == 4) format(string, sizeof(string), "Club");
#
    //else if(BizInfo[bizid][bType] == 5) format(string, sizeof(string), "Advertisement Agency");
#
    else if(BizInfo[bizid][bType] == 5) format(string, sizeof(string), "Adv. Agency");
#
    else if(BizInfo[bizid][bType] == 6) format(string, sizeof(string), "Fast Food");
#
    else if(BizInfo[bizid][bType] == 7) format(string, sizeof(string), "Casino");
#
        return string;
#
}
#
stock RHS(bizid)
#
{
#
        new string[16];
#
        if(!HouseInfo[bizid][hStatus]) format(string, sizeof(string), "Closed");
#
    else if(HouseInfo[bizid][hStatus]) format(string, sizeof(string), "Open");
#
        return string;
#
}
#
 
#
stock RBS(bizid)
#
{
#
        new string[16];
#
        if(!BizInfo[bizid][bStatus]) format(string, sizeof(string), "Closed");
#
    else if(BizInfo[bizid][bStatus]) format(string, sizeof(string), "Open");
#
        return string;
#
}
#
 
#
stock RPBP(playerid)
#
{
#
        new string[32];
#
        if(!PlayerInfo[playerid][pBiz]) format(string, sizeof(string), "None");
#
        else if(PlayerInfo[playerid][pBiz]) format(string, sizeof(string), "%d", BizInfo[PlayerInfo[playerid][pBiz]][bProducts]);
#
        return string;
#
}
#
stock RPN(playerid)
#
{
#
        new string[25];
#
        if(PlayerInfo[playerid][pMaskOn] == 0)format(string, sizeof(string), "%s", RemoveUnderScore(playerid));
#
        else if(PlayerInfo[playerid][pMaskOn] == 1)format(string, sizeof(string), "Stranger");
#
        return string;
#
}
#
stock Log(sz_fileName[], sz_input[]) {
#
 
#
        new     sz_logEntry[156], i_dateTime[2][3], File: fileHandle = fopen(sz_fileName, io_append);
#
        gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
#
        getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);
#
        format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
#
        fwrite(fileHandle, sz_logEntry);
#
        return fclose(fileHandle);
#
}
#
stock SendNearbyMessage(playerid, Float:radius, string[], col1, col2, col3, col4, col5)
#
{
#
        new Float:x, Float:y, Float:z;
#
        GetPlayerPos(playerid, x, y, z);
#
        new Float:ix, Float:iy, Float:iz;
#
        new Float:cx, Float:cy, Float:cz;
#
        foreach(Player, i)
#
        {
#
            if(IsPlayerConnected(i))
#
            {
#
                if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
#
                {
#
                                GetPlayerPos(i, ix, iy, iz);
#
                                cx = (x - ix);
#
                                cy = (y - iy);
#
                                cz = (z - iz);
#
                                if(((cx < radius/16) && (cx > -radius/16)) && ((cy < radius/16) && (cy > -radius/16)) && ((cz < radius/16) && (cz > -radius/16)))
#
                                {
#
                                    SendClientMessage(i, col1, string);
#
                                }
#
                                else if(((cx < radius/8) && (cx > -radius/8)) && ((cy < radius/8) && (cy > -radius/8)) && ((cz < radius/8) && (cz > -radius/8)))
#
                                {
#
                                    SendClientMessage(i, col2, string);
#
                                }
#
                                else if(((cx < radius/4) && (cx > -radius/4)) && ((cy < radius/4) && (cy > -radius/4)) && ((cz < radius/4) && (cz > -radius/4)))
#
                                {
#
                                    SendClientMessage(i, col3, string);
#
                                }
#
                                else if(((cx < radius/2) && (cx > -radius/2)) && ((cy < radius/2) && (cy > -radius/2)) && ((cz < radius/2) && (cz > -radius/2)))
#
                                {
#
                                    SendClientMessage(i, col4, string);
#
                                }
#
                                else if(((cx < radius) && (cx > -radius)) && ((cy < radius) && (cy > -radius)) && ((cz < radius) && (cz > -radius)))
#
                                {
#
                                    SendClientMessage(i, col5, string);
#
                                }
#
                        }
#
            }
#
        }
#
        return 1;
#
}
#
stock RPNU(playerid)
#
{
#
        new name[MAX_PLAYER_NAME];
#
        GetPlayerName(playerid, name, sizeof(name));
#
        return name;
#
}
#
stock NORPN(playerid)
#
{
#
        new astring[25];
#
        if(PlayerInfo[playerid][pHideOn] == 0)format(astring, sizeof(astring), "%s", RemoveUnderScore(playerid));
#
        else if(PlayerInfo[playerid][pHideOn] == 1)format(astring, sizeof(astring), "Anon");
#
        return astring;
#
}
#
stock RemoveUnderScore(playerid)
#
{
#
    new name[MAX_PLAYER_NAME];
#
    GetPlayerName(playerid,name,sizeof(name));
#
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
#
    {
#
        if(name[i] == '_') name[i] = ' ';
#
    }
#
    return name;
#
}
#
stock split(const strsrc[], strdest[][], delimiter)
#
{
#
    new i, li;
#
    new aNum;
#
    new len;
#
    while(i <= strlen(strsrc))
#
    {
#
        if(strsrc[i] == delimiter || i == strlen(strsrc))
#
        {
#
            len = strmid(strdest[aNum], strsrc, li, i, 128);
#
            strdest[aNum][len] = 0;
#
            li = i+1;
#
            aNum++;
#
        }
#
        i++;
#
    }
#
    return 1;
#
}
Make sure to convert the commands to what ever you are using.
Some commands like /enter and /exit you can add them to your original command if you have it.

I'm not sure if you will really need this anyway add it.
pawn Код:
stock GivePlayerCash(playerid, money)
#
{
#
        SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash")+money);
#
        GivePlayerMoney(playerid, money);
#
        return 1;
#
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)