////////////////////////////////////////////////////
////////////////////////////////////////////////////
/*
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;
}
enum
{
DIALOG_SHOW_OPTIONS,
DIALOG_CHANGE_WEBSITE
};
What I would do is extend this system to be able to do the following.
1.) Save websites 2.) Set position 3.) Create styles Another suggestion is avoid using public OnPlayerCommandText(playerid, cmdtext[]) directly even if you have one command just use a command processor (ZCMD) it is good practice. Overall I wouldn't say this is good but unlike a lot of new guys you actually made an effort for your script to be complete and did something that could be useful which means you've learned something here. |