PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#define PLUGIN "CZ Tutor Messages - Enhanced Edition 9-30-2017"
#define VERSION "1.0"
#define AUTHOR "Sneaky.amxx | GlobalModders.net"
#define MAP_GLOBAL "global.ini"
#define MAX_MESSAGE 16
#define TASK_TUT 1111
#define TUT_TYPE 0 // 0 - Global (one file for all maps) / 1 - By Map (one file for each map)
#define TUT_SOUND "events/tutor_msg.wav"
enum
{
RED = 1,
BLUE,
YELLOW,
GREEN
}
new const g_TutorPrecache[][] =
{
"gfx/career/icon_!.tga",
"gfx/career/icon_!-bigger.tga",
"gfx/career/icon_i.tga",
"gfx/career/icon_i-bigger.tga",
"gfx/career/icon_skulls.tga",
"gfx/career/round_corner_ne.tga",
"gfx/career/round_corner_nw.tga",
"gfx/career/round_corner_se.tga",
"gfx/career/round_corner_sw.tga",
"resource/TutorScheme.res",
"resource/UI/TutorTextWindow.res"
}
new g_MsgTutor;
new g_MsgTutClose;
// Main
new Message_Command[MAX_MESSAGE][64];
new Message_Content[MAX_MESSAGE][256];
new Message_Color[MAX_MESSAGE];
new Message_Time[MAX_MESSAGE];
new MessageCount;
new g_MaxPlayers;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_MsgTutor = get_user_msgid("TutorText")
g_MsgTutClose = get_user_msgid("TutorClose")
register_clcmd("say", "Say_Handler");
register_clcmd("say_team", "Say_Handler");
g_MaxPlayers = get_maxplayers();
}
public plugin_precache()
{
precache_sound(TUT_SOUND)
File_Load()
for(new i = 0; i < sizeof g_TutorPrecache; i++)
{
precache_generic(g_TutorPrecache[i])
}
}
public client_putinserver(id)
{
if(MessageCount > 0)
set_task(1.0, "Recheck_Join", id);
}
public Recheck_Join(id)
{
if(!is_user_connected(id))
return;
new CsTeams:Team; Team = cs_get_user_team(id)
if(Team == CS_TEAM_CT || Team == CS_TEAM_T || Team == CS_TEAM_SPECTATOR)
{
MakeTutor(id, Message_Content[0], Message_Color[0], float(Message_Time[0]));
return;
}
set_task(1.0, "Recheck_Join", id);
}
public Display_AllPeople(id, MessID)
{
if(!is_user_connected(id))
return
MakeTutor(id, Message_Content[MessID], Message_Color[MessID], float(Message_Time[MessID]));
}
public Say_Handler(id)
{
new Message[32], Command[32];
new Return;
read_args(Message, 31);
remove_quotes(Message);
parse(Message, Command, 31);
if(Command[0] == '/')
{
replace_all(Command, 31, "/", "");
for(new i = 0; i < MessageCount; i++)
{
if(equal(Message_Command[i], Command))
{
Display_AllPeople(id, i);
Return = 1;
break;
}
}
}
if(Return) return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
public File_Load()
{
// Build customization file path
new path[128]
get_configsdir(path, charsmax(path))
switch(TUT_TYPE)
{
case 0: format(path, charsmax(path), "%s/iTutor/%s", path, MAP_GLOBAL)
case 1: {
static MapName[32]; get_mapname(MapName, 31);
format(path, charsmax(path), "%s/iTutor/%s.ini", path, MapName)
}
}
// File not present
if (!file_exists(path))
{
static DataA[128]; formatex(DataA, sizeof(DataA), "[iTutor] Can't load: %s", path)
set_fail_state(DataA)
return false;
}
// Open customization file for reading
new file = fopen(path, "rt")
// File can't be opened
if (!file)
return false;
// Set up some vars to hold parsing info
new linedata[1024];
new Command[64], ColorFuck[16], MessTime[8]
new ReadState = 0;
// Seek to setting's section
while (!feof(file))
{
// Read one line at a time
fgets(file, linedata, charsmax(linedata))
// Replace newlines with a null character to prevent headaches
replace(linedata, charsmax(linedata), "^n", "")
if(strlen(linedata) <= 0)
continue;
if(linedata[0] == '[')
{
if(MessageCount >= MAX_MESSAGE)
continue;
ReadState = 1;
replace_all(linedata, charsmax(linedata), "[", "");
parse(linedata, Command, 63, ColorFuck, 15, MessTime, 7);
Message_Command[MessageCount] = Command;
if(equal(ColorFuck, "red")) Message_Color[MessageCount] = RED;
else if(equal(ColorFuck, "blue")) Message_Color[MessageCount] = BLUE;
else if(equal(ColorFuck, "yellow")) Message_Color[MessageCount] = YELLOW;
else if(equal(ColorFuck, "green")) Message_Color[MessageCount] = GREEN;
else Message_Color[MessageCount] = GREEN;
Message_Time[MessageCount] = str_to_num(MessTime);
} else if(linedata[0] == ']') {
if(ReadState > 0)
{
MessageCount++;
ReadState = 0;
}
} else {
ReadState = 2;
formatex(Message_Content[MessageCount], 255, "%s%s", Message_Content[MessageCount], linedata)
}
/*
replace_all(linedata, charsmax(linedata), " ", "_");
replace_all(linedata, charsmax(linedata), "/", " ");
client_print(0, print_chat, "[%s]", linedata);
parse(linedata, Command, 63, ColorFuck, 15, MessTime, 7, Content, 255);
replace_all(Content, 255, "_", " ");
if(MessageCount < MAX_MESSAGE)
{
Message_Command[MessageCount] = Command;
Message_Content[MessageCount] = Content;
if(equal(ColorFuck, "red")) Message_Color[MessageCount] = RED;
else if(equal(ColorFuck, "blue")) Message_Color[MessageCount] = BLUE;
else if(equal(ColorFuck, "yellow")) Message_Color[MessageCount] = YELLOW;
else if(equal(ColorFuck, "green")) Message_Color[MessageCount] = GREEN;
else Message_Color[MessageCount] = GREEN;
Message_Time[MessageCount] = str_to_num(MessTime);
MessageCount++;
}*/
}
return true;
}
MakeTutor(id, Text[], Color, Float:Time = 0.0)
{
static NewText[256];
formatex(NewText, 255, "%s", Text);
replace_all(NewText, 255, "\n", "^n");
if(is_user_connected(id))
{
PlaySound(id, TUT_SOUND);
message_begin(MSG_ONE_UNRELIABLE, g_MsgTutor, _, id)
write_string(NewText)
write_byte(0)
write_short(0)
write_short(0)
write_short(1<<Color)
message_end()
}
if(Time != 0.0) {
if( task_exists(id + TASK_TUT ))
{
remove_task(id + TASK_TUT)
}
set_task(Time,"RemoveTutor",id + TASK_TUT)
}
}
public RemoveTutor(taskID)
{
new id = taskID - TASK_TUT
message_begin(MSG_ALL,g_MsgTutClose,_,id)
message_end()
}
stock PlaySound(id, const sound[])
{
if(equal(sound[strlen(sound)-4], ".mp3")) client_cmd(id, "mp3 play ^"sound/%s^"", sound)
else client_cmd(id, "spk ^"sound/%s^"", sound)
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1042\\ f0\\ fs16 \n\\ par }
*/