10.06.2015, 12:20
(
Последний раз редактировалось PizzaPuntjes; 10.06.2015 в 13:41.
)
Welcome to my first ever filterscript release on these forums. It's nothing really special but I think it can be useful to some users that wish to learn from my code or get ideas
Features
The filterscript currently has 5 features.
Change Website Text: Here can you change your website link.
Speed: Currently it has 3 speed modes; Normal - Fast - Rapid
No Mode: A simple plain white text with no effects.
Random Letter Colors:
Flashy Colors: This will change the color of the whole link in a random color.
Text Location: Right lower corner.
Instructions
To use this filterscript you need to copy-paste the script from one of the locations below into a fresh .pwn file.
When you've gotten to this step you need to compile it into the filterscripts folder.
After you've done this, edit the server.cfg and add the filename into it after the filterscripts line.
You can also load the script from the console using 'loadfs filename' or use '/rcon loadfs filename from in-game'.
To open the dialog to edit the modes, speed or website you have to type '/website'. Please note that you need to be RCON admin to do this.
Downloads:
Pastebin: http://pastebin.com/iZRHaK3f
Please leave feedback if you've got any and thanks for looking at this topic
Features
The filterscript currently has 5 features.
Change Website Text: Here can you change your website link.
Speed: Currently it has 3 speed modes; Normal - Fast - Rapid
No Mode: A simple plain white text with no effects.
Random Letter Colors:
Flashy Colors: This will change the color of the whole link in a random color.
Text Location: Right lower corner.
Instructions
To use this filterscript you need to copy-paste the script from one of the locations below into a fresh .pwn file.
When you've gotten to this step you need to compile it into the filterscripts folder.
After you've done this, edit the server.cfg and add the filename into it after the filterscripts line.
You can also load the script from the console using 'loadfs filename' or use '/rcon loadfs filename from in-game'.
To open the dialog to edit the modes, speed or website you have to type '/website'. Please note that you need to be RCON admin to do this.
Downloads:
Pastebin: http://pastebin.com/iZRHaK3f
PHP код:
////////////////////////////////////////////////////
////////////////////////////////////////////////////
/*
PizzaPuntjes Website Displayer
Please do not remove credits :)
*/
////////////////////////////////////////////////////
////////////////////////////////////////////////////
#include <a_samp>
////////////////////////////////////////////////////
////////////////////////////////////////////////////
forward UpdateWebsiteDraw();
////////////////////////////////////////////////////
////////////////////////////////////////////////////
#define FS_NAME "PizzaPuntjes Website Shower"
#define WEBSITE ("www.example.com") // change this to your own website or do it from in-game
#define MODE_EDIT_TEXT (0)
#define MODE_EDIT_SPEED (1)
#define MODE_NOTHING (2)
#define MODE_RANDOM_COLORS (3)
#define MODE_FLASH_COLOR (4)
////////////////////////////////////////////////////
////////////////////////////////////////////////////
new td_colors[][] = {
{"~r~"}, {"~b~"}, {"~p~"}, {"~g~"}, {"~y~"}, {"~h~"}
};
new dr_options[][] = {
{"Change Website Text"}, {"Speed"}, {"No Mode"}, {"Random Letter Colors"}, {"Flashy Colors"}
};
new speeds[][] = {
{1300, "Normal Speed"},
{1000, "Regular Speed"},
{750, "Rapid Speed"}
};
enum { DIALOG_SHOW_OPTIONS, DIALOG_CHANGE_WEBSITE };
////////////////////////////////////////////////////
////////////////////////////////////////////////////
new active_mode = MODE_RANDOM_COLORS, speed_mode, website_timer;
new real_site[30];
new Text:Website_Draw;
////////////////////////////////////////////////////
////////////////////////////////////////////////////
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Website Displayer v1 by PizzaPuntjes (2015)");
print("--------------------------------------\n");
if(active_mode) website_timer = SetTimer("UpdateWebsiteDraw", speeds[speed_mode][0], true);
Website_Draw = TextDrawCreate(511.714691, 412.293243, WEBSITE);
TextDrawLetterSize(Website_Draw, 0.268190, 1.523199);
TextDrawAlignment(Website_Draw, 1);
TextDrawColor(Website_Draw, -1);
TextDrawSetShadow(Website_Draw, 0);
TextDrawSetOutline(Website_Draw, 1);
TextDrawBackgroundColor(Website_Draw, 30);
TextDrawFont(Website_Draw, 2);
TextDrawSetProportional(Website_Draw, 1);
TextDrawSetShadow(Website_Draw, 0);
real_site = WEBSITE;
return 1;
}
public OnFilterScriptExit()
{
TextDrawDestroy(Website_Draw);
return 1;
}
public OnPlayerConnect(playerid)
{
TextDrawShowForPlayer(playerid, Website_Draw);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
TextDrawHideForPlayer(playerid, Website_Draw);
return 1;
}
public UpdateWebsiteDraw()
{
new td_str[60];
static new_cid, prev_cid;
if(strlen(real_site) > 1) format(td_str, sizeof(td_str), real_site); else td_str = WEBSITE;
switch(active_mode)
{
case MODE_RANDOM_COLORS:
{
for(new i = strlen(td_str); i > 0; i --)
{
if(i == strlen(td_str)) continue;
repick:
new_cid = random(sizeof(td_colors));
if(prev_cid == new_cid) goto repick;
prev_cid = new_cid;
strins(td_str, td_colors[new_cid], i);
}
repick_2:
new_cid = random(sizeof(td_colors));
if(prev_cid == new_cid) goto repick_2;
strins(td_str, td_colors[new_cid], 0);
}
case MODE_FLASH_COLOR:
{
repick_3:
new_cid = random(sizeof(td_colors));
if(prev_cid == new_cid) goto repick_3;
if(!strfind(td_colors[new_cid], "~h~", false, 0)) goto repick_3;
prev_cid = new_cid;
strins(td_str, td_colors[new_cid], 0);
}
}
TextDrawSetString(Website_Draw, td_str);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/website", true))
{
if(!IsPlayerAdmin(playerid)) return 1;
ShowSelectionDialog(playerid);
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_SHOW_OPTIONS:
{
if(!response) return SendClientMessage(playerid, 0xFFC00CFF, "> You have closed the dialog for changing settings.");
switch(listitem)
{
case 0:
{
ShowDialogChangeSite(playerid, 0);
}
case 1:
{
speed_mode ++;
if(speed_mode == sizeof(speeds)) speed_mode = 0;
if(website_timer)
{
KillTimer(website_timer);
website_timer = SetTimer("UpdateWebsiteDraw", speeds[speed_mode][0], true);
}
ShowSelectionDialog(playerid);
}
case 2:
{
if(website_timer) KillTimer(website_timer);
TextDrawSetString(Website_Draw, real_site);
}
default:
{
if(website_timer)
{
KillTimer(website_timer);
website_timer = SetTimer("UpdateWebsiteDraw", speeds[speed_mode][0], true);
}
else website_timer = SetTimer("UpdateWebsiteDraw", speeds[speed_mode][0], true);
}
}
if(listitem >= 2)
{
active_mode = listitem;
ShowSelectionDialog(playerid);
}
return 1;
}
case DIALOG_CHANGE_WEBSITE:
{
if(!response) return SendClientMessage(playerid, 0xFFC00CFF, "> You have returned to the options."), ShowSelectionDialog(playerid);
if(strlen(inputtext) < 2 || strlen(inputtext) > 30) return ShowDialogChangeSite(playerid, 1);
format(real_site, sizeof(real_site), inputtext);
UpdateWebsiteDraw();
ShowSelectionDialog(playerid);
return 1;
}
}
return 0;
}
ShowSelectionDialog(playerid)
{
new dialog_str[128 * 2];
for(new i = 0; i < sizeof(dr_options); i ++)
{
strcat(dialog_str, dr_options[i]);
if(i == MODE_EDIT_TEXT) strcat(dialog_str, " {FF0000}||{FFFFFF} "), strcat(dialog_str, real_site);
if(i == MODE_EDIT_SPEED) strcat(dialog_str, " {FF0000}||{FFFFFF} "), strcat(dialog_str, speeds[speed_mode][1]);
if(active_mode == i) strcat(dialog_str, " {FF0000}||{FFFFFF}{7cfc00} [ACTIVE]{FFFFFF}");
if(i != sizeof(dr_options)) strcat(dialog_str, "\n");
}
ShowPlayerDialog(playerid, DIALOG_SHOW_OPTIONS, DIALOG_STYLE_LIST, "{FFC00C}"FS_NAME"", dialog_str, "Select", "Exit");
return 1;
}
ShowDialogChangeSite(playerid, error)
{
new dialog_str[128];
strcat(dialog_str, "{FFFFFF}Please fill in your desired website name:\n\n");
if(error) strcat(dialog_str, "{FF0000}The length must be between 2 and 30 characters!\n");
ShowPlayerDialog(playerid, DIALOG_CHANGE_WEBSITE, DIALOG_STYLE_INPUT, "{FFC00C}"FS_NAME"", dialog_str, "Change", "Return");
return 1;
}