Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

[FilterScript] BR Dynamic Rules System

$
0
0
Code:

//////////////////////    ///////////////////
  //                  //    //              //
  //                  //    //              //
  //                  //    //              //
  //                  //    //              //
  //                  //    //        //////
  /////////////////////      ////////////
  //                  //    //        //
  //                  //    //          //
  //                  //    //          //
  //                  //    //            //
  //                  //    //            //
  /////////////////////      //              //

Introduction: hey guys this script has been created by me by the way i would like to thanks to Wherethescripts for helping me in rulestimer.

Credits:
BulletRaja [Activated] [Whole Credits]
Wherethescripters [Merandom] [Timer helped]
Cyber_Punk [Merrandom Include]
Incognito [sscanf2]
Zeex [ZCMD]

Pictures: COMING SOON

Downloads:
Click for merrandom include

CODE:
PHP Code:

/*
  //////////////////////     ///////////////////
  //                  //     //               //
  //                  //     //               //
  //                  //     //               //
  //                  //     //               //
  //                  //     //         //////
  /////////////////////      ////////////
  //                  //     //         //
  //                  //     //          //
  //                  //     //           //
  //                  //     //            //
  //                  //     //             //
  /////////////////////      //              //
  Bullet                      RAJA                  &          Wherethescripters
  cyber_punk: Merandom
  Zeex: ZCMD
  Incognito:  sscanf2
*/
//Merandom Download http://forum.sa-mp.com/showthread.php?t=109196
#define FILTERSCRIPT

#include <a_samp>
#include <sscanf2>
#include <Dini>
#include <zcmd>
#include <merrandom>
/* Dialogs */
#define    DIALOG_RULES                          1
#define DIALOG_RULE_DELETE                    2
#define DIALOG_RULE_DELETE_CONFIRM            3
#define DIALOG_RULE_VIEW                      4

/* Defines */
#define     MAX_RULES               10

/* folders & files */
#define rulesfolder "R"
#define rules       "rules"

/* COLORS */
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_YELLOW 0xFFFF00FF
#define COLOR_RED 0xFF0000FF
#define COLOR_ORANGE 0xFF9900FF

/* Automatic Rules Sending System */
forward rulestimer();
public 
rulestimer()
{
    new 
bb dini_Int(PlaceDirectory(rulesfolderrules), "rules");
    if (
bb == 0) return 1;
    new 
tmp[6];
    for (new 
0MAX_PLAYERSi++) {
        if (
IsPlayerConnected(i)) {
            
format(tmp6"rule%d"MRandom(bb)+1);
            
ReturnMessage(iCOLOR_YELLOW"Rule: {FF0000}%s."dini_Get(PlaceDirectory(rulesfolderrules), tmp), "");
        }
    }
    return 
1;
}
/*         Directory For Files     */
PlaceDirectory(directory[], filename[])
{
    new 
newname[128];
    
format(newnamesizeof(newname), "%s/%c/%s.ini"directoryfilename[0] != '.' filename[0] : '#'filename);
    return 
newname;
}
ReturnMessage(playeridcolorstr[], msg[], msg2[])
{
    new 
pstr[256];
    
format(pstr256strmsgmsg2);
    
SendClientMessage(playeridcolorpstr);
    return 
1;
}

ReturnAll(colorstr[], msg[], msg2[])
{
    new 
pstr[256];
    
format(pstr256strmsgmsg2);
    
SendClientMessageToAll(colorpstr);
    return 
1;
}
public 
OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
" Script by Bulletraja & Wherethescripts");
    print(
"--------------------------------------\n");
    
SetTimer("rulestimer"3000001);
    return 
1;
}

public 
OnFilterScriptExit()
{
    return 
1;
}

public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    new 
tmp2[256], tmp[256];
    if (
dialogid == DIALOG_RULE_DELETE)
    {
        if (
response)
        {
            
SetPVarInt(playerid"ruleselect"listitem+1);
            
format(tmp6"rule%d"listitem+1);
            if (!
dini_Isset(PlaceDirectory(rulesfolderrules), tmp))
                return 
SendClientMessage(playeridCOLOR_RED"Rule doesn't exist.");
            
format(tmp2sizeof(tmp2), "%s.\n\nDo you want to delete this rule?"dini_Get(PlaceDirectory(rulesfolderrules), tmp));
            
ShowPlayerDialog(playeridDIALOG_RULE_DELETE_CONFIRMDIALOG_STYLE_MSGBOX"Delete rule"tmp2"Delete""Cancel");
        }
        return 
1;
    }
    if (
dialogid == DIALOG_RULE_DELETE_CONFIRM)
    {
        if (
response)
        {
            
format(tmp6"rule%d"GetPVarInt(playerid"ruleselect"));
            if (!
dini_Isset(PlaceDirectory(rulesfolderrules), tmp))
                return 
SendClientMessage(playeridCOLOR_RED"Rule doesn't exist.");
            new 
bb dini_Int(PlaceDirectory(rulesfolderrules), "rules");
            if (
GetPVarInt(playerid"ruleselect") != bb) {
                
format(tmp26"rule%d"bb);
                
dini_Set(PlaceDirectory(rulesfolderrules), tmpdini_Get(PlaceDirectory(rulesfolderrules), tmp2));
                
dini_Unset(PlaceDirectory(rulesfolderrules), tmp2);
            }
            else {
                
dini_Unset(PlaceDirectory(rulesfolderrules), tmp);
            }
            
dini_IntSet(PlaceDirectory(rulesfolderrules), "rules"bb-1);
            
SendClientMessage(playeridCOLOR_ORANGE"Rule deleted.");
        }
        else {
            new 
bb dini_Int(PlaceDirectory(rulesfolderrules), "rules");
            new 
tmp3[2048];
            for (new 
1<= bbt++) {
                
format(tmp26"rule%d"t);
                
format(tmp2sizeof(tmp2), "%s"dini_Get(PlaceDirectory(rulesfolderrules), tmp2));
                if (
strlen(tmp2) > 64) {
                    
strmid(tmp2tmp2061);
                    
format(tmp2sizeof(tmp2), "%s..."tmp2);
                }
                
format(tmp3sizeof(tmp3), "%s%s\n"tmp3tmp2);
            }
            
ShowPlayerDialog(playeridDIALOG_RULE_DELETEDIALOG_STYLE_LIST"Rules"tmp3"Select""Cancel");
        }
        return 
1;
    }
    if (
dialogid == DIALOG_RULES)
    {
        if (
response)
        {
        }
        return 
1;
    }
    if (
dialogid == DIALOG_RULE_VIEW)
    {
        if (
response)
        {
            new 
bb dini_Int(PlaceDirectory(rulesfolderrules), "rules");
            if (
bb == 0)
                return 
SendClientMessage(playeridCOLOR_RED"There are no rules created.");
            new 
tmp3[2048];
            for (new 
1<= bbt++) {
                
format(tmp26"rule%d"t);
                
format(tmp2sizeof(tmp2), "%s"dini_Get(PlaceDirectory(rulesfolderrules), tmp2));
                if (
strlen(tmp2) > 64) {
                    
strmid(tmp2tmp2061);
                    
format(tmp2sizeof(tmp2), "%s..."tmp2);
                }
                
format(tmp3sizeof(tmp3), "%s%s\n"tmp3tmp2);
            }
            
ShowPlayerDialog(playeridDIALOG_RULESDIALOG_STYLE_LIST"Rules"tmp3"Select""Cancel");
        }
        return 
1;
    }
    return 
1;
}

CMD:rules(playeridparams[])
{
    new 
tmp[256];
    new 
bb dini_Int(PlaceDirectory(rulesfolderrules), "rules");
    if (
bb == 0) return SendClientMessage(playeridCOLOR_RED"There are no rules created.");
    new 
tmp3[2048];
    for (new 
1<= bbt++)
    {
        
format(tmp6"rule%d"t);
        
format(tmpsizeof(tmp), "%s"dini_Get(PlaceDirectory(rulesfolderrules), tmp));
        
format(tmp3sizeof(tmp3), "%s%s\n"tmp3tmp);
    }
    
ShowPlayerDialog(playeridDIALOG_RULESDIALOG_STYLE_MSGBOX"Rules"tmp3"Accept""");
    return 
1;
}
CMD:addrule(playeridparams[])
{
    new 
tmp[256], tmp2[256], playername[25];

    if (
sscanf(params"s[128]"tmp)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /addrule [rule]");
    new 
bb dini_Int(PlaceDirectory(rulesfolderrules), "rules");
    if (
bb == MAX_RULES)
    {
        
format(tmp2sizeof(tmp2), "Error: You have created the maximum of %d rules."MAX_RULES);
        
SendClientMessage(playeridCOLOR_REDtmp2);
        return 
1;
    }
    
dini_IntSet(PlaceDirectory(rulesfolderrules), "rules"bb+1);
    
format(tmp26"rule%d"bb+1);
    
dini_Set(PlaceDirectory(rulesfolderrules), tmp2tmp);
    
ReturnMessage(playeridCOLOR_ORANGE"Rule '%s' created."tmp"");
    
GetPlayerName(playeridplayernameMAX_PLAYER_NAME);
    
ReturnAll(COLOR_YELLOW"%s has added a new rule. Type /rules to view the list of rules."playername"");
    return 
1;
}
CMD:delrule(playeridparams[])
{
    new 
tmp[256];
    new 
bb dini_Int(PlaceDirectory(rulesfolderrules), "rules");
    if (
bb == 0) return SendClientMessage(playeridCOLOR_RED"There are no rules created.");
    new 
tmp3[2048];
    for (new 
1<= bbt++)
    {
        
format(tmp6"rule%d"t);
        
format(tmpsizeof(tmp), "%s"dini_Get(PlaceDirectory(rulesfolderrules), tmp));
        if (
strlen(tmp) > 64)
        {
            
strmid(tmptmp061);
            
format(tmpsizeof(tmp), "%s..."tmp);
        }
        
format(tmp3sizeof(tmp3), "%s%s\n"tmp3tmp);
    }
    
ShowPlayerDialog(playeridDIALOG_RULE_DELETEDIALOG_STYLE_LIST"Rules"tmp3"Select""Cancel");
    return 
1;



Bugs: None [if you found please inform me]

i hope you will like the system
rep+ if you like it

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>