SA-MP Forums Archive
[FilterScript] → Dynamic Rules ← Using HTTP! - 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)
+--- Thread: [FilterScript] → Dynamic Rules ← Using HTTP! (/showthread.php?tid=368048)



→ Dynamic Rules ← Using HTTP! - Ronaldo_raul™ - 12.08.2012

Dynamic Rules
Introduction :
Have you ever thought of updating your rules easily without that finding the dialog and editing stuff. Well, now you can update your rules from just one file. This is a little code through which you can show your rules dynamically from a file use HTTP() function.

Concept :
Simply, as provided a HTTP function, we can retrieve data from a file which is hosted completely somewhere else.

Screenshots :
There's nothing to show in screenshots, everything is clear.

Installation :
1. Create a rules.txt file and write everything you want to show in the dialog.
2. Now, upload the rules.txt to your host.
3. Open up the script and change the
pawn Code:
#define URLPath ""
according to your path of the uploaded 'rules.txt' file.
4. And you're done. Load the script.

NOTE: You must have zcmd include to use this.

Download :
pawn Code:
#include <a_samp>
#include <a_http>
#include <zcmd>

#define FILTERSCRIPT
#define rID 1
#define rFID 2
#define URLPath "www.mortalgaming.com/rules.txt"

CMD:rules ( playerid , params [] )
{
    HTTP ( playerid , HTTP_GET , URLPath , "" , "HTTPResponse" ) ;
    return 1 ;
}

forward HTTPResponse ( playerid , response_code, data[] ) ;
public HTTPResponse ( playerid , response_code , data[] )
{
    new Str [ 128 ] ;
    if ( response_code == 200 )
    {
        format ( Str , 128 , "%s" , data ) ;
        ShowPlayerDialog ( playerid , rID , DIALOG_STYLE_MSGBOX , "Rules" , Str , "Close", "" ) ;
    }
    else
    {
        ShowPlayerDialog ( playerid , rFID , DIALOG_STYLE_MSGBOX , "Error" , "Error in getting rules" , "Close" , "" ) ;
    }
}
Credits :
- ME! ^_^


Re: → Dynamic Rules ← Using HTTP! - RaoAbhi - 12.08.2012

Nice i liked your work.


Re: → Dynamic Rules ← Using HTTP! - Ronaldo_raul™ - 12.08.2012

Quote:
Originally Posted by RaoAbhi
View Post
Nice i liked your work.
Thank you.


Re: → Dynamic Rules ← Using HTTP! - Devilxz97 - 12.08.2012

nice works Ronaldo.


Re: → Dynamic Rules ← Using HTTP! - Ronaldo_raul™ - 12.08.2012

Quote:
Originally Posted by Devilxz97
View Post
nice works Ronaldo.
Thank you again ^^


Re: → Dynamic Rules ← Using HTTP! - DarkB0y - 12.08.2012

Nice script !


Re: → Dynamic Rules ← Using HTTP! - Edvin - 12.08.2012

very nice, thanks


Re: → Dynamic Rules ← Using HTTP! - Mark™ - 12.08.2012

"a_http.inc" is embedded in "a_samp.inc", so there's no need to include it separately.


Re: → Dynamic Rules ← Using HTTP! - KingHual - 12.08.2012

Why would you use http if you can just use the file i/o? It's faster and simpler.


Re: → Dynamic Rules ← Using HTTP! - Ronaldo_raul™ - 12.08.2012

Quote:
Originally Posted by X_Boy
View Post
Nice script !
Quote:
Originally Posted by Edvin
View Post
very nice, thanks
Thank you.

Quote:
Originally Posted by Xtreme_playa
View Post
"a_http.inc" is embedded in "a_samp.inc", so there's no need to include it separately.
When removed -
pawn Code:
error 017: undefined symbol "HTTP"
Quote:
Originally Posted by king_hual
View Post
Why would you use http if you can just use the file i/o? It's faster and simpler.
Just for this uniqueness. And I found that this function is not in frequent use.


Re: → Dynamic Rules ← Using HTTP! - Rapgangsta - 13.08.2012

NOTE: You must have zcmd include to use this.

Why?


Re: → Dynamic Rules ← Using HTTP! - Ronaldo_raul™ - 13.08.2012

Quote:
Originally Posted by Rapgangsta
View Post
NOTE: You must have zcmd include to use this.

Why?
That\'s because, the command /rules in made in ZCMD command processor. You may change it to fit your needs.


Re: → Dynamic Rules ← Using HTTP! - Mark™ - 13.08.2012

Quote:
Originally Posted by Ronaldo_raul™
View Post
Thank you.




When removed -
pawn Code:
error 017: undefined symbol "HTTP"
Oh well ! You can embed a_http.inc manually too, just open a_samp.inc and add #include<a_http> under all other embedded includes and save it.


Re: → Dynamic Rules ← Using HTTP! - Ronaldo_raul™ - 13.08.2012

Quote:
Originally Posted by Xtreme_playa
View Post
Oh well ! You can embed a_http.inc manually too, just open a_samp.inc and add #include<a_http> under all other embedded includes and save it.
Not everyone have done that. So, publicly it is as it should be.