Ошибки компиляции trail

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
16
Реакции
0
Ошибка
// C:\amxmodx-1.9.0-git5247-windows\trail.sma(14) : warning 201: redefinition of constant/macro (symbol "MAX_NAME_LENGTH")
// C:\\amxmodx-1.9.0-git5247-windows\trail.sma(99) : warning 233: symbol "plugin_modules" is marked as deprecated: Module dependency is now automatically handled by the compiler. This forward is no longer called.
//
// C:\amxmodx-1.9.0-git5247-windows\trail.sma(100) : warning 233: symbol "require_module" is marked as deprecated: Module dependency is now automatically handled by the compiler. This native has no effect.
//
// C:\amxmodx-1.9.0-git5247-windows\trail.sma(515) : warning 217: loose indentation
// C:\amxmodx-1.9.0-git5247-windows\trail.sma(516) : warning 217: loose indentation
// C:\amxmodx-1.9.0-git5247-windows\trail.sma(31) : warning 203: symbol is never used: "ColorChat"
// C:\amxmodx-1.9.0-git5247-windows\trail.sma(68) : warning 203: symbol is never used: "ColorSelection"
// C:\amxmodx-1.9.0-git5247-windows\trail.sma(63) : warning 203: symbol is never used: "FindPlayer"
// C:\amxmodx-1.9.0-git5247-windows\trail(70) : warning 203: symbol is never used: "ShowColorMessage"
// C:\amxmodx-1.9.0-git5247-windows\trail.sma(74) : warning 203: symbol is never used: "Team_Info"
Компилятор
Локальный
Amx Mod X
1.9.0
Исходный код
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <colorchat>

#define PLUGNAME "plugin_trail"
#define VERSION "2.1"
#define AUTHOR "Nickron"

#define ACCESS_LEVEL ADMIN_LEVEL_A
#define ACCESS_ADMIN ADMIN_ADMIN

#define MAX_TEXT_LENGTH 200
#define MAX_NAME_LENGTH 40
#define MAX_PLAYERS 32
#define MAX_DISTANCE 400

#define CFG_FILE "colors.cfg"
#define MAX_COLORS 200

#define DEF_TRAIL_LIFE 2

#define TASKID 1337 // change if it interfere with another plugin!
#define TICK 0.1

#define NUM_SPRITES 21

new bool:gl_parsed
new bool:gl_trail
new bool:gl_not_this_map

new SayText

new gl_trail_life
new gl_trail_size[MAX_PLAYERS]
new gl_trail_brightness[MAX_PLAYERS]
new gl_trail_type[MAX_PLAYERS]

new gl_sprite_name[NUM_SPRITES][] = {
"sprites/Grean_Trail/Biohazard.spr",
"sprites/Grean_Trail/tok.spr",
"sprites/Grean_Trail/CT.spr",
"sprites/Grean_Trail/chain.spr",
"sprites/Grean_Trail/Half-Life.spr",
"sprites/Grean_Trail/letters.spr",
"sprites/Grean_Trail/lightning.spr",
"sprites/Grean_Trail/love.spr",
"sprites/Grean_Trail/minecraft.spr",
"sprites/Grean_Trail/tok1.spr",
"sprites/Grean_Trail/snow_white.spr",
"sprites/Grean_Trail/def_T.spr",
"sprites/Grean_Trail/Shar.spr",
"sprites/Grean_Trail/zik.spr",
"sprites/Grean_Trail/sprint.spr",
"sprites/Grean_Trail/present.spr",
"sprites/Grean_Trail/ice.spr",
"sprites/Grean_Trail/vselennaya.spr",
"sprites/Grean_Trail/hp.spr",
"sprites/Grean_Trail/zet.spr",
"sprites/Grean_Trail/box.spr"
}
new gl_sprite[NUM_SPRITES]
new gl_def_sprite_size[NUM_SPRITES] = {
5, 12, 4, 16, 16, 6, 9, 4, 15, 14, 15, 20, 20, 20, 20, 20, 20, 80, 20, 20, 20
}
new gl_def_sprite_brightness[NUM_SPRITES] = {
160, 255, 200, 255, 255, 230, 150, 150, 240, 220, 200, 200, 160, 255, 200, 150, 230, 200, 255, 240, 230
}

new gl_players[MAX_PLAYERS]

new gl_player_position[MAX_PLAYERS][3]
new gl_timer_count[MAX_PLAYERS]
new gl_timer_limit

new gl_player_colors[MAX_PLAYERS][3]
new gl_color_names[MAX_COLORS][MAX_NAME_LENGTH]
new gl_colors[MAX_COLORS][3]
new gl_num_colors

public plugin_init() {
register_plugin(PLUGNAME, VERSION, AUTHOR)
register_concmd("amx_trail","cmdTrail", ACCESS_LEVEL, "- ['on'|'off'|'1'|'0'] : enable/disable trails.")
register_concmd("amx_trail_user","cmdUserTrail", ACCESS_LEVEL, "- <name or #userid> <colorname | 'random' | 'off'> : set user trail.")
register_concmd("amx_trail_type", "cmdTrailType", ACCESS_LEVEL, "- <type> : set trail type for all players.")
register_concmd("amx_trail_life","cmdTrailLife", ACCESS_LEVEL, "- [duration] : get/set trail duration, in seconds.")
register_concmd("amx_trail_size","cmdTrailSize", ACCESS_LEVEL, "- [size] : get/set trail size.")
register_concmd("amx_trail_brightness","cmdTrailBrightness", ACCESS_LEVEL, "- [brightness] : get/set trail brightness.")
register_concmd("amx_trail_reload", "cmdReload", ACCESS_LEVEL, ": reload colors configuration file.")
register_clcmd("say", "SayCmd", 0, "")

gl_parsed = gl_trail = parse_file()
if (!gl_sprite[0]) gl_trail = false

gl_trail_life = DEF_TRAIL_LIFE
gl_timer_limit = floatround(float(gl_trail_life)/TICK)
}

public plugin_modules() {
require_module("engine")
}

public plugin_precache() {
if (check_map()) {
gl_not_this_map = true
return
}

for (new i=0; i<NUM_SPRITES; i++) {
gl_sprite[i] = precache_model(gl_sprite_name[i])
}
}

public client_putinserver(id) {
gl_trail_type[id] = gl_sprite[0]
gl_trail_size[id] = gl_def_sprite_size[0]
gl_trail_brightness[id] = gl_def_sprite_brightness[0]
}

public client_disconnected(id) {
if (task_exists(TASKID+id)) remove_task(TASKID+id)
gl_player_colors[id][0] = gl_player_colors[id][1] = gl_player_colors[id][2] = 0
}

/*****************************************************************************************
*
* cmdTrail ['on'|'off'|'1'|'0'] : enable/disable trails.
*
*****************************************************************************************/
public cmdTrail(id, level, cid) {
if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED

if (!gl_parsed) {
console_print(id, "Линии выключены, потому что невозможно прочитать config файл '%s'!", CFG_FILE)
return PLUGIN_HANDLED
}
if (gl_not_this_map) {
console_print(id, "Линии отключены на этой карте!")
return PLUGIN_HANDLED
}

new str[5]
read_argv(1, str, 4)
if (equali(str, "on") || equali(str, "1")) {
if (gl_trail) {
console_print(id, "Линии разрешены на сервере.")
} else {
gl_trail = true
console_print(id, "Линии сейчас разрешены.")
}
} else if (equali(str, "off") || equali(str, "0")) {
if (!gl_trail) {
console_print(id, "Линии запрещены на сервере.")
}else {
gl_trail = false
new playercount
get_players(gl_players, playercount)
for (new i=0; i<playercount; i++) {
kill_trail_task(gl_players[i])
}
say_to_all("Ваша линия была удалена.", id)
console_print(id, "Линии сейчас запрещены.")
}
} else {
if (gl_trail) {
console_print(id, "Линии разрешены.")
} else {
console_print(id, "Линии запрещены.")
}
}

return PLUGIN_HANDLED
}

/*****************************************************************************************
*
* cmdUserTrail <name or #userid> <colorname | 'random' | 'off'> : set user trail.
*
*****************************************************************************************/
public cmdUserTrail(id, level, cid) {
if (!cmd_access(id, level, cid, 3)) return PLUGIN_HANDLED

if (!gl_parsed) {
console_print(id, "Линии выключены, потому что невозможно прочитать config файл '%s'!", CFG_FILE)
return PLUGIN_HANDLED
}
if (gl_not_this_map) {
console_print(id, "Линии выключены на этой карте!")
return PLUGIN_HANDLED
}

new user[MAX_NAME_LENGTH+1], colorname[MAX_NAME_LENGTH]
new plName[MAX_NAME_LENGTH+1]

read_argv(1, user, MAX_NAME_LENGTH)
read_argv(2, colorname, MAX_NAME_LENGTH-1)

new player = cmd_target(id, user, 6)
if (!player) {
console_print(id, "Неизвестный игрок: %s", user)
return PLUGIN_HANDLED
}
get_user_name(player, plName, MAX_NAME_LENGTH)
if (access(player, ADMIN_IMMUNITY) && id!=player) {
console_print(id, "Вы не можете применить это к %s, Вы глупый медведь!", plName)
return PLUGIN_HANDLED
}
if (!is_user_alive(player)) {
console_print(id, "Только живые игроки, пожалуйста!")
return PLUGIN_HANDLED
}

if (equali(colorname, "off")) {
if (!gl_player_colors[player][0] && !gl_player_colors[player][1] && !gl_player_colors[player][2]) {
console_print(id, "%s's линия уже выключена!", plName)
return PLUGIN_HANDLED
}
kill_trail_task(player)
console_print(id, "%s's линия была удалена.", plName)
client_print(player, print_chat, "Ваша линия была удалена.")
} else if (equali(colorname, "random")) {
do_trail(player, "", "")
console_print(id, "У %s случайный цвет линии.", plName)
} else {
do_trail(player, colorname, "")
console_print(id, "%s взял %s линию.", plName, colorname)
}

return PLUGIN_HANDLED
}

/*****************************************************************************************
*
* cmdTrailType <type> : set trail type (sprite) for all players
*
*****************************************************************************************/
public cmdTrailType(id, level, cid) {
if (!cmd_access(id, level, cid, 2)) return PLUGIN_HANDLED

if (!gl_parsed) {
console_print(id, "Линии выключены, потому что не возможно прочитать config файл '%s'!", CFG_FILE)
return PLUGIN_HANDLED
}
if (gl_not_this_map) {
console_print(id, "Линии отключены на этой карте!")
return PLUGIN_HANDLED
}

new str[5], type
read_argv(1, str, 4)
type = str_to_num(str)
if (type<1 || type>NUM_SPRITES) {
console_print(id, "Тип линии должен быть в [1,%d] диапазоне!", NUM_SPRITES)
return PLUGIN_HANDLED
}
for (new i=0; i<MAX_PLAYERS; i++) {
gl_trail_type[i] = gl_sprite[type-1]
gl_trail_size[i] = gl_def_sprite_size[type-1]
gl_trail_brightness[i] = gl_def_sprite_brightness[type-1]
}
restart_player_trail(id)
return PLUGIN_HANDLED
}

/*****************************************************************************************
*
* cmdTrailLife [duration] : get/set trail duration, in seconds.
*
*****************************************************************************************/
public cmdTrailLife(id, level, cid) {
if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED

if (!gl_parsed) {
console_print(id, "Линии выключены, потому что не возможно прочитать config файл '%s'!", CFG_FILE)
return PLUGIN_HANDLED
}
if (gl_not_this_map) {
console_print(id, "Линии отключены на этой карте!")
return PLUGIN_HANDLED
}

new Str[3], life

read_argv(1, Str, 2)
if (!Str[0]) {
console_print(id, "Линия включется через %d секунды.", gl_trail_life)
return PLUGIN_HANDLED
}
life = str_to_num(Str)
if (life<1 || life>30) {
console_print(id, "Линия должна быть в [1,30] диапазоне!")
return PLUGIN_HANDLED
}
gl_trail_life = life
gl_timer_limit = floatround(float(life)/TICK)
restart_players_trails()

return PLUGIN_HANDLED
}

/*****************************************************************************************
*
* cmdTrailSize [size] : get/set trail size.
*
*****************************************************************************************/
public cmdTrailSize(id, level, cid) {
if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED

if (!gl_parsed) {
console_print(id, "Линии выключены, потому что не возможно прочитать config файл '%s'!", CFG_FILE)
return PLUGIN_HANDLED
}
if (gl_not_this_map) {
console_print(id, "Линии отключены на этой карте!")
return PLUGIN_HANDLED
}

new Str[3], size

read_argv(1, Str, 2)
if (!Str[0]) {
console_print(id, "Ваш размер линии в настоящее время %d.", gl_trail_size[id])
return PLUGIN_HANDLED
}
size = str_to_num(Str)
if (size<1) {
console_print(id, "Размер линии должен быть позитивным!")
return PLUGIN_HANDLED
}
gl_trail_size[id] = size
restart_player_trail(id)

return PLUGIN_HANDLED
}

/*****************************************************************************************
*
* cmdTrailBrightness [brightness] : get/set trail brightness.
*
*****************************************************************************************/
public cmdTrailBrightness(id, level, cid) {
if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED

if (!gl_parsed) {
console_print(id, "Линии выключены, потому что не возможно прочитать config файл '%s'!", CFG_FILE)
return PLUGIN_HANDLED
}
if (gl_not_this_map) {
console_print(id, "Линии отключены на этой карте!")
return PLUGIN_HANDLED
}

new Str[3], bright

read_argv(1, Str, 3)
if (!Str[0]) {
console_print(id, "Ваша яркость линии в настоящее время %d.", gl_trail_brightness[id])
return PLUGIN_HANDLED
}
bright = str_to_num(Str)
if (bright<1 || bright>255) {
console_print(id, "Яркость линии должна быть в [1,255] диапазоне!")
return PLUGIN_HANDLED
}
gl_trail_brightness[id] = bright
restart_player_trail(id)

return PLUGIN_HANDLED
}

/*****************************************************************************************
*
* cmdReload : reload configuration file.
*
*****************************************************************************************/
public cmdReload(id, level, cid) {
if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED

if (gl_not_this_map) {
console_print(id, "Линии отключены на этой карте!")
return PLUGIN_HANDLED
}

gl_parsed = parse_file()

if (gl_parsed) {
console_print(id, "Ok, конфигурационный файл successfuly перезагруженный.")
} else {
console_print(id, "Ух Ох...Была проблемка! Пожалуйста, проверте Ваш amx файл системного журнала, чтоб знать, что случилось.")
}
return PLUGIN_HANDLED
}

/*****************************************************************************************
*
* sayCmd : say trail <[['light'|'dark'] colorname] | ['random'] | ['off'] | ['help']>
*
*****************************************************************************************/
public SayCmd(id, level, cid) {
new args[128], plName[MAX_NAME_LENGTH], colname[MAX_NAME_LENGTH], arg2[MAX_NAME_LENGTH], arg3[MAX_NAME_LENGTH], typenum

read_args(args, 128)
remove_quotes(args)

if (equali(args, "trail", 5)) {
if (!gl_trail) {
client_print(id, print_chat, "Линии отключены.")
return PLUGIN_HANDLED
}
if (gl_not_this_map) {
client_print(id, print_chat, "Линии отключены на этой карте.")
return PLUGIN_HANDLED
}

get_user_name(id, plName, MAX_NAME_LENGTH)
if (!get_user_team(id) && !access(id, ADMIN_ADMIN)) {
client_print(id, print_chat, "Вы должны играть!")
return PLUGIN_HANDLED
}

if (!args[5]) {
do_trail(id, "", "")
return PLUGIN_HANDLED
} else {
parse(args[6], colname, MAX_NAME_LENGTH, arg2, MAX_NAME_LENGTH, arg3, MAX_NAME_LENGTH)
// console_print(id, "restline = '%s'", restline)
typenum = str_to_num(colname)
}

if (equali(colname, "off")) {
if (!gl_player_colors[id][0] && !gl_player_colors[id][1] && !gl_player_colors[id][2]) {
client_print(id, print_chat, "Ваша линия удалена!")
return PLUGIN_HANDLED
}
kill_trail_task(id)
client_print(id, print_chat, "Ваша линия была удалена.")
return PLUGIN_HANDLED
} else if (equali(colname, "random")) {
do_trail(id, "", "")
return PLUGIN_HANDLED
} else if (equali(colname, "help")) {
trail_help(id)
return PLUGIN_HANDLED
}

if (typenum) {
if (typenum<1 || typenum>NUM_SPRITES) {
client_print(id, print_chat, "Тип линии должен быть в диапазоне [1,%d].", NUM_SPRITES)
return PLUGIN_HANDLED
}
typenum--
gl_trail_type[id] = gl_sprite[typenum]
gl_trail_size[id] = gl_def_sprite_size[typenum]
gl_trail_brightness[id] = gl_def_sprite_brightness[typenum]
if (arg2[0]) {
colname = arg2
arg2 = arg3
} else {
if (!gl_player_colors[id][0] && !gl_player_colors[id][1] && !gl_player_colors[id][2]) {
do_trail(id, "", "")
return PLUGIN_HANDLED
}
new r = gl_player_colors[id][0]
new g = gl_player_colors[id][1]
new b = gl_player_colors[id][2]
kill_trail_task(id)
gl_player_colors[id][0] = r
gl_player_colors[id][1] = g
gl_player_colors[id][2] = b
get_user_origin(id, gl_player_position[id])
set_task(TICK, "check_position", TASKID+id, "", 0, "b")
trail_msg(id)
client_print(id, print_chat, "Вы выбрали тип %d.", typenum+1)
return PLUGIN_HANDLED
}
}

if (equali(colname, "dark")) {
copy(colname, MAX_NAME_LENGTH-1, arg2)
if (!colname[0]) {
client_print(id, print_chat, "Выберите цвет!")
return PLUGIN_HANDLED
}
do_trail(id, colname, "dark")
} else if (equali(colname, "light")) {
copy(colname, MAX_NAME_LENGTH-1, arg2)
if (!colname[0]) {
client_print(id, print_chat, "Выберите цвет!")
return PLUGIN_HANDLED
}
do_trail(id, colname, "light")
}
else {
do_trail(id, colname, "")
}
}
return PLUGIN_CONTINUE
}

/*****************************************************************************************
*****************************************************************************************/
do_trail(id, colname[], intensity[]) {
new i
new name[33]

get_user_name(id, name, 32)
if (!colname[0]) {
kill_trail_task(id)
gl_player_colors[id][0] = random(256)
gl_player_colors[id][1] = random(256)
gl_player_colors[id][2] = random(256)
get_user_origin(id, gl_player_position[id])
set_task(TICK, "check_position", TASKID+id, "", 0, "b")
trail_msg(id)
print_col_chat(id, "!gслучайный ^4траил !gtrail ^4randome")
return
}
for (i=0; i<gl_num_colors; i++) {
if (equali(colname, gl_color_names[i])) {
new Float:intens, r, g, b
if (equali(intensity, "dark")) {
intens = 0.5
} else if (equali(intensity, "light")) {
intens = 2.0
} else {
copy(intensity, 1, "")
intens = 1.0
}
kill_trail_task(id)
r = floatround(float(gl_colors[i][0]) * intens)
g = floatround(float(gl_colors[i][1]) * intens)
b = floatround(float(gl_colors[i][2]) * intens)
gl_player_colors[id][0] = min(r, 255)
gl_player_colors[id][1] = min(g, 255)
gl_player_colors[id][2] = min(b, 255)
get_user_origin(id, gl_player_position[id])
set_task(TICK, "check_position", TASKID+id, "", 0, "b")
trail_msg(id)
if (intensity[0]) {
client_print(id, print_chat, "[Grean Trail]- Line", intensity, colname)
} else {
client_print(id, print_chat, "[Grean Trail]- Line", colname)
}
return
}
}
client_print(id, print_chat, "Извините, %s, но цвета '%s' - нет!", name, colname)
return
}

/*****************************************************************************************
*****************************************************************************************/
public check_position(taskid) {
new origin[3], id = taskid-TASKID

if (!get_user_team(id)) {
kill_trail_msg(id)
return
}

get_user_origin(id, origin)
if (origin[0]!=gl_player_position[id][0] || origin[1]!=gl_player_position[id][1] || origin[2]!=gl_player_position[id][2]) {
if (get_distance(origin, gl_player_position[id])>MAX_DISTANCE || gl_timer_count[id] >= gl_timer_limit/2) {
kill_trail_msg(id)
trail_msg(id)
}
gl_player_position[id][0] = origin[0]
gl_player_position[id][1] = origin[1]
gl_player_position[id][2] = origin[2]
gl_timer_count[id] = 0
} else {
if (gl_timer_count[id] < gl_timer_limit) gl_timer_count[id]++
}
}

/*****************************************************************************************
*****************************************************************************************/
kill_trail_task(id) {
if (task_exists(TASKID+id)) remove_task(TASKID+id)
kill_trail_msg(id)
gl_player_colors[id][0] = gl_player_colors[id][1] = gl_player_colors[id][2] = 0
}

/*****************************************************************************************
*****************************************************************************************/
kill_trail_msg(id) {
gl_timer_count[id] = 0

message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(99) // TE_KILLBEAM
write_short(id)
message_end()
}

/*****************************************************************************************
*****************************************************************************************/
trail_msg(id) {
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(22) // TE_BEAMFOLLOW
write_short(id)
write_short(gl_trail_type[id])
write_byte(gl_trail_life*10)
write_byte(gl_trail_size[id])
write_byte(gl_player_colors[id][0])
write_byte(gl_player_colors[id][1])
write_byte(gl_player_colors[id][2])
write_byte(gl_trail_brightness[id])
message_end()

}

/*****************************************************************************************
*****************************************************************************************/
restart_player_trail(id) {
if (task_exists(TASKID+id)) {
remove_task(TASKID+id)
kill_trail_msg(id)
get_user_origin(id, gl_player_position[id])
set_task(TICK, "check_position", TASKID+id, "", 0, "b")
trail_msg(id)
}
}

/*****************************************************************************************
*****************************************************************************************/
restart_players_trails() {
new playercount

get_players(gl_players, playercount)
for (new i=0; i<playercount; i++) {
restart_player_trail(gl_players[i])
}
}

/*****************************************************************************************
*****************************************************************************************/
say_to_all(msg[], id) {
new playercount

get_players(gl_players, playercount)
for (new i=0; i<playercount; i++) {
if (gl_players[i]!=id) client_print(gl_players[i], print_chat, msg)
}
}

/*****************************************************************************************
*****************************************************************************************/
trail_help(id) {
new msg[200], clen=0

console_print(id, "^nTrail Colors List:^n")
for (new i=0; i<gl_num_colors; i++) {
clen += format(msg[clen], 199-clen, "%s ", gl_color_names[i])
if (clen > 80) {
console_print(id, msg)
copy(msg, 1, "")
clen = 0
}
}
console_print(id, "^nNOTE: All colors can be prefixed by the words 'light' or 'dark'.^n")
console_print(id, "^nSay 'trail <color>' to get a colored trail.^nSay 'trail off' to turn trail off.")
console_print(id, "Say 'trail <number> [color]' to change the look of the trail.^n")
console_print(id, "^nExamples:")
console_print(id, " trail")
console_print(id, " trail off")
console_print(id, " trail tomato")
console_print(id, " trail 6 gold")
console_print(id, " trail 11 light blue")
client_print(id, print_chat, "The colors list has been displayed in your console.")
}

/*****************************************************************************************
*****************************************************************************************/
bool:parse_file() {
new got_line, line_num=0, len=0, parsed
new r[3][4], g[3][4], b[3][4]
new full_line[MAX_TEXT_LENGTH], rest_line[MAX_TEXT_LENGTH], cfgdir[MAX_TEXT_LENGTH], cfgpath[MAX_TEXT_LENGTH]

gl_num_colors = 0
get_configsdir(cfgdir, MAX_TEXT_LENGTH)
format(cfgpath, MAX_TEXT_LENGTH, "%s/%s", cfgdir, CFG_FILE)
if (!file_exists(cfgpath)) {
log_amx("ERROR: Cannot find configuration file '%s'!", cfgpath)
return false
}
got_line = read_file(cfgpath, line_num, full_line, MAX_TEXT_LENGTH, len)
if (got_line <=0) {
log_amx("ERROR: Cannot read configuration file '%s'!", cfgpath)
return false
}
while (got_line>0) {
if (!equal(full_line, "//", 2) && len) {
strtok(full_line, gl_color_names[gl_num_colors], MAX_NAME_LENGTH, rest_line, MAX_TEXT_LENGTH, ' ', 1)
copy(full_line, MAX_TEXT_LENGTH, rest_line)

parsed = parse(full_line,r[0],3,g[0],3,b[0],3)
if (parsed<3) {
log_amx("ERROR: Not enough colors, line %d in configuration file '%s'!", 1+line_num, CFG_FILE)
return false
}
gl_colors[gl_num_colors][0] = str_to_num(r[0])
gl_colors[gl_num_colors][1] = str_to_num(g[0])
gl_colors[gl_num_colors][2] = str_to_num(b[0])

gl_num_colors++
if (gl_num_colors>=MAX_COLORS) {
log_amx("WARNING: Max colors reached in file '%s'!", CFG_FILE)
return true
}
}
line_num++
got_line = read_file(cfgpath, line_num, full_line, MAX_TEXT_LENGTH, len)
}
return true
}

check_map() {
new got_line, line_num, len
new cfgdir[MAX_TEXT_LENGTH]
new cfgpath[MAX_TEXT_LENGTH]
new mapname[MAX_NAME_LENGTH]
new txt[MAX_TEXT_LENGTH]

get_configsdir(cfgdir, MAX_TEXT_LENGTH-1)
get_mapname(mapname, MAX_NAME_LENGTH-1)

format(cfgpath, MAX_TEXT_LENGTH, "%s/sensiblemaps.cfg", cfgdir)

if (file_exists(cfgpath)) {
got_line = read_file(cfgpath, line_num, txt, MAX_TEXT_LENGTH-1, len)
while (got_line>0) {
if (equali(txt, mapname)) return 1
line_num++
got_line = read_file(cfgpath, line_num, txt, MAX_TEXT_LENGTH-1, len)
}
}
return 0
}
stock print_col_chat(const id, const input[], any:...)
{
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^4");
replace_all(msg, 190, "!y", "^1");
replace_all(msg, 190, "!t", "^3");
if (id) players[0] = id; else get_players(players, count, "ch");
{
for ( new i = 0; i < count; i++ )
{
if ( is_user_connected(players[i]) )
{
message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
Подскажите, как исправить? Не получается скомпилировать под Amx Mod X 1.9.0.
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
2,751
Реакции
3,016
Помог
61 раз(а)
Исправлена компиляция на AMXX 1.9.0+
C++:
#include <amxmodx>
#include <amxmisc>
#include <engine>

#define PLUGNAME      "plugin_trail"
#define VERSION         "2.1"
#define AUTHOR         "Nickron"

#define ACCESS_LEVEL      ADMIN_LEVEL_A
#define ACCESS_ADMIN      ADMIN_ADMIN

#define MAX_TEXT_LENGTH      200
#define MAX_PLAYERS      32
#define MAX_DISTANCE      400

#define CFG_FILE      "colors.cfg"
#define MAX_COLORS      200

#define DEF_TRAIL_LIFE      2

#define TASKID         1337   // change if it interfere with another plugin!
#define TICK         0.1

#define NUM_SPRITES      21

new bool:gl_parsed
new bool:gl_trail
new bool:gl_not_this_map

new SayText

new gl_trail_life
new gl_trail_size[MAX_PLAYERS]
new gl_trail_brightness[MAX_PLAYERS]
new gl_trail_type[MAX_PLAYERS]

new gl_sprite_name[NUM_SPRITES][] = {
   "sprites/Grean_Trail/Biohazard.spr",
   "sprites/Grean_Trail/tok.spr",
   "sprites/Grean_Trail/CT.spr",
   "sprites/Grean_Trail/chain.spr",
   "sprites/Grean_Trail/Half-Life.spr",
   "sprites/Grean_Trail/letters.spr",
   "sprites/Grean_Trail/lightning.spr",
   "sprites/Grean_Trail/love.spr",
   "sprites/Grean_Trail/minecraft.spr",
   "sprites/Grean_Trail/tok1.spr",
   "sprites/Grean_Trail/snow_white.spr",
   "sprites/Grean_Trail/def_T.spr",
   "sprites/Grean_Trail/Shar.spr",
   "sprites/Grean_Trail/zik.spr",
   "sprites/Grean_Trail/sprint.spr",
   "sprites/Grean_Trail/present.spr",
   "sprites/Grean_Trail/ice.spr",
   "sprites/Grean_Trail/vselennaya.spr",
   "sprites/Grean_Trail/hp.spr",
   "sprites/Grean_Trail/zet.spr",
   "sprites/Grean_Trail/box.spr"
}
new gl_sprite[NUM_SPRITES]
new gl_def_sprite_size[NUM_SPRITES] = {
   5, 12, 4, 16, 16, 6, 9, 4, 15, 14, 15, 20, 20, 20, 20, 20, 20, 80, 20, 20, 20
}
new gl_def_sprite_brightness[NUM_SPRITES] = {
   160, 255, 200, 255, 255, 230, 150, 150, 240, 220, 200, 200, 160, 255, 200, 150, 230, 200, 255, 240, 230
}
 
new gl_players[MAX_PLAYERS]

new gl_player_position[MAX_PLAYERS][3]
new gl_timer_count[MAX_PLAYERS]
new gl_timer_limit

new gl_player_colors[MAX_PLAYERS][3]
new gl_color_names[MAX_COLORS][MAX_NAME_LENGTH]
new gl_colors[MAX_COLORS][3]
new gl_num_colors

public plugin_init() {
   register_plugin(PLUGNAME, VERSION, AUTHOR)
   register_concmd("amx_trail","cmdTrail", ACCESS_LEVEL,  "- ['on'|'off'|'1'|'0'] : enable/disable trails.")
   register_concmd("amx_trail_user","cmdUserTrail", ACCESS_LEVEL,  "- <name or #userid> <colorname | 'random' | 'off'> : set user trail.")
   register_concmd("amx_trail_type", "cmdTrailType", ACCESS_LEVEL, "- <type> : set trail type for all players.")
   register_concmd("amx_trail_life","cmdTrailLife", ACCESS_LEVEL,  "- [duration] : get/set trail duration, in seconds.")
   register_concmd("amx_trail_size","cmdTrailSize", ACCESS_LEVEL,  "- [size] : get/set trail size.")
   register_concmd("amx_trail_brightness","cmdTrailBrightness", ACCESS_LEVEL,  "- [brightness] : get/set trail brightness.")
   register_concmd("amx_trail_reload", "cmdReload", ACCESS_LEVEL, ": reload colors configuration file.")
   register_clcmd("say", "SayCmd", 0, "")
 
   gl_parsed = gl_trail = parse_file()
   if (!gl_sprite[0]) gl_trail = false

   gl_trail_life = DEF_TRAIL_LIFE
   gl_timer_limit = floatround(float(gl_trail_life)/TICK)
}

public plugin_precache() {
   if (check_map()) {
      gl_not_this_map = true
      return
   }

   for (new i=0; i<NUM_SPRITES; i++) {
      gl_sprite[i] = precache_model(gl_sprite_name[i])
   }
}

public client_putinserver(id) {
   gl_trail_type[id] = gl_sprite[0]
   gl_trail_size[id] = gl_def_sprite_size[0]
   gl_trail_brightness[id] = gl_def_sprite_brightness[0]
}

public client_disconnected(id) {
   if (task_exists(TASKID+id)) remove_task(TASKID+id)
   gl_player_colors[id][0] = gl_player_colors[id][1] = gl_player_colors[id][2] = 0
}

/*****************************************************************************************
*
*   cmdTrail ['on'|'off'|'1'|'0'] : enable/disable trails.
*
*****************************************************************************************/
public cmdTrail(id, level, cid) {
   if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED
 
   if (!gl_parsed) {
      console_print(id, "Линии выключены, потому что невозможно прочитать config файл '%s'!", CFG_FILE)
      return PLUGIN_HANDLED
   }
   if (gl_not_this_map) {
      console_print(id, "Линии отключены на этой карте!")
      return PLUGIN_HANDLED
   }

   new str[5]
   read_argv(1, str, 4)
   if (equali(str, "on") || equali(str, "1")) {
      if (gl_trail) {
         console_print(id, "Линии разрешены на сервере.")
      } else {
         gl_trail = true
         console_print(id, "Линии сейчас разрешены.")
      }
   } else if (equali(str, "off") || equali(str, "0")) {
      if (!gl_trail) {
         console_print(id, "Линии запрещены на сервере.")
      }else {
         gl_trail = false
         new playercount
         get_players(gl_players, playercount)
         for (new i=0; i<playercount; i++) {
            kill_trail_task(gl_players[i])
         }
         say_to_all("Ваша линия была удалена.", id)
         console_print(id, "Линии сейчас запрещены.")
      }
   } else {
      if (gl_trail) {
         console_print(id, "Линии разрешены.")
      } else {
         console_print(id, "Линии запрещены.")
      }
   }
 
   return PLUGIN_HANDLED
}

/*****************************************************************************************
*
*   cmdUserTrail <name or #userid> <colorname | 'random' | 'off'> : set user trail.
*
*****************************************************************************************/
public cmdUserTrail(id, level, cid) {
   if (!cmd_access(id, level, cid, 3)) return PLUGIN_HANDLED

   if (!gl_parsed) {
      console_print(id, "Линии выключены, потому что невозможно прочитать config файл '%s'!", CFG_FILE)
      return PLUGIN_HANDLED
   }
   if (gl_not_this_map) {
      console_print(id, "Линии выключены на этой карте!")
      return PLUGIN_HANDLED
   }

   new user[MAX_NAME_LENGTH+1], colorname[MAX_NAME_LENGTH]
   new plName[MAX_NAME_LENGTH+1]

   read_argv(1, user, MAX_NAME_LENGTH)
   read_argv(2, colorname, MAX_NAME_LENGTH-1)

   new player = cmd_target(id, user, 6)
   if (!player) {
      console_print(id, "Неизвестный игрок: %s", user)
      return PLUGIN_HANDLED
   }
   get_user_name(player, plName, MAX_NAME_LENGTH)
   if (access(player, ADMIN_IMMUNITY) && id!=player) {
      console_print(id, "Вы не можете применить это к %s, Вы глупый медведь!", plName)
      return PLUGIN_HANDLED
   }
   if (!is_user_alive(player)) {
      console_print(id, "Только живые игроки, пожалуйста!")
      return PLUGIN_HANDLED
   }

   if (equali(colorname, "off")) {
      if (!gl_player_colors[player][0] && !gl_player_colors[player][1] && !gl_player_colors[player][2]) {
         console_print(id, "%s's линия уже выключена!", plName)
         return PLUGIN_HANDLED
      }
      kill_trail_task(player)
      console_print(id, "%s's линия была удалена.", plName)
      client_print(player, print_chat, "Ваша линия была удалена.")
   } else if (equali(colorname, "random")) {
      do_trail(player, "", "")
      console_print(id, "У %s случайный цвет линии.", plName)
   } else {
      do_trail(player, colorname, "")
      console_print(id, "%s взял %s линию.", plName, colorname)
   }

   return PLUGIN_HANDLED
}

/*****************************************************************************************
*
*   cmdTrailType <type> : set trail type (sprite) for all players
*
*****************************************************************************************/
public cmdTrailType(id, level, cid) {
   if (!cmd_access(id, level, cid, 2)) return PLUGIN_HANDLED
 
   if (!gl_parsed) {
      console_print(id, "Линии выключены, потому что не возможно прочитать config файл '%s'!", CFG_FILE)
      return PLUGIN_HANDLED
   }
   if (gl_not_this_map) {
      console_print(id, "Линии отключены на этой карте!")
      return PLUGIN_HANDLED
   }

   new str[5], type
   read_argv(1, str, 4)
   type = str_to_num(str)
   if (type<1 || type>NUM_SPRITES) {
      console_print(id, "Тип линии должен быть в [1,%d] диапазоне!", NUM_SPRITES)
      return PLUGIN_HANDLED
   }
   for (new i=0; i<MAX_PLAYERS; i++) {
      gl_trail_type[i] = gl_sprite[type-1]
      gl_trail_size[i] = gl_def_sprite_size[type-1]
      gl_trail_brightness[i] = gl_def_sprite_brightness[type-1]
   }
   restart_player_trail(id)
   return PLUGIN_HANDLED
}

/*****************************************************************************************
*
*   cmdTrailLife [duration] : get/set trail duration, in seconds.
*
*****************************************************************************************/
public cmdTrailLife(id, level, cid) {
   if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED

   if (!gl_parsed) {
      console_print(id, "Линии выключены, потому что не возможно прочитать config файл '%s'!", CFG_FILE)
      return PLUGIN_HANDLED
   }
   if (gl_not_this_map) {
      console_print(id, "Линии отключены на этой карте!")
      return PLUGIN_HANDLED
   }

   new Str[3], life
 
   read_argv(1, Str, 2)
   if (!Str[0]) {
      console_print(id, "Линия включется через %d секунды.", gl_trail_life)
      return PLUGIN_HANDLED
   }
   life = str_to_num(Str)
   if (life<1 || life>30) {
      console_print(id, "Линия должна быть в [1,30] диапазоне!")
      return PLUGIN_HANDLED
   }
   gl_trail_life = life
   gl_timer_limit = floatround(float(life)/TICK)
   restart_players_trails()
 
   return PLUGIN_HANDLED
}

/*****************************************************************************************
*
*   cmdTrailSize [size] : get/set trail size.
*
*****************************************************************************************/
public cmdTrailSize(id, level, cid) {
   if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED

   if (!gl_parsed) {
      console_print(id, "Линии выключены, потому что не возможно прочитать config файл '%s'!", CFG_FILE)
      return PLUGIN_HANDLED
   }
   if (gl_not_this_map) {
      console_print(id, "Линии отключены на этой карте!")
      return PLUGIN_HANDLED
   }

   new Str[3], size
 
   read_argv(1, Str, 2)
   if (!Str[0]) {
      console_print(id, "Ваш размер линии в настоящее время %d.", gl_trail_size[id])
      return PLUGIN_HANDLED
   }
   size = str_to_num(Str)
   if (size<1) {
      console_print(id, "Размер линии должен быть позитивным!")
      return PLUGIN_HANDLED
   }
   gl_trail_size[id] = size
   restart_player_trail(id)

   return PLUGIN_HANDLED
}

/*****************************************************************************************
*
*   cmdTrailBrightness [brightness] : get/set trail brightness.
*
*****************************************************************************************/
public cmdTrailBrightness(id, level, cid) {
   if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED

   if (!gl_parsed) {
      console_print(id, "Линии выключены, потому что не возможно прочитать config файл '%s'!", CFG_FILE)
      return PLUGIN_HANDLED
   }
   if (gl_not_this_map) {
      console_print(id, "Линии отключены на этой карте!")
      return PLUGIN_HANDLED
   }

   new Str[3], bright
 
   read_argv(1, Str, 3)
   if (!Str[0]) {
      console_print(id, "Ваша яркость линии в настоящее время %d.", gl_trail_brightness[id])
      return PLUGIN_HANDLED
   }
   bright = str_to_num(Str)
   if (bright<1 || bright>255) {
      console_print(id, "Яркость линии должна быть в [1,255] диапазоне!")
      return PLUGIN_HANDLED
   }
   gl_trail_brightness[id] = bright
   restart_player_trail(id)

   return PLUGIN_HANDLED
}

/*****************************************************************************************
*
*   cmdReload : reload configuration file.
*
*****************************************************************************************/
public cmdReload(id, level, cid) {
   if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED

   if (gl_not_this_map) {
      console_print(id, "Линии отключены на этой карте!")
      return PLUGIN_HANDLED
   }

   gl_parsed = parse_file()
 
   if (gl_parsed) {
      console_print(id, "Ok, конфигурационный файл successfuly перезагруженный.")
   } else {
      console_print(id, "Ух Ох...Была проблемка! Пожалуйста, проверте Ваш amx файл системного журнала, чтоб знать, что случилось.")
   }
   return PLUGIN_HANDLED
}

/*****************************************************************************************
*
*   sayCmd : say trail <[['light'|'dark'] colorname] | ['random'] | ['off'] | ['help']>
*
*****************************************************************************************/
public SayCmd(id, level, cid) {
   new args[128], plName[MAX_NAME_LENGTH], colname[MAX_NAME_LENGTH], arg2[MAX_NAME_LENGTH], arg3[MAX_NAME_LENGTH], typenum
 
   read_args(args, 128)
   remove_quotes(args)

   if (equali(args, "trail", 5)) {
      if (!gl_trail) {
         client_print(id, print_chat, "Линии отключены.")
         return PLUGIN_HANDLED
      }
      if (gl_not_this_map) {
         client_print(id, print_chat, "Линии отключены на этой карте.")
         return PLUGIN_HANDLED
      }

      get_user_name(id, plName, MAX_NAME_LENGTH)
      if (!get_user_team(id) && !access(id, ADMIN_ADMIN)) {
         client_print(id, print_chat, "Вы должны играть!")
         return PLUGIN_HANDLED
      }
     
      if (!args[5]) {
         do_trail(id, "", "")
         return PLUGIN_HANDLED
      } else {
         parse(args[6], colname, MAX_NAME_LENGTH, arg2, MAX_NAME_LENGTH, arg3, MAX_NAME_LENGTH)
//         console_print(id, "restline = '%s'", restline)
         typenum = str_to_num(colname)
      }
     
      if (equali(colname, "off")) {
         if (!gl_player_colors[id][0] && !gl_player_colors[id][1] && !gl_player_colors[id][2]) {
            client_print(id, print_chat, "Ваша линия удалена!")
            return PLUGIN_HANDLED
         }
         kill_trail_task(id)
         client_print(id, print_chat, "Ваша линия была удалена.")
         return PLUGIN_HANDLED
      } else if (equali(colname, "random")) {
         do_trail(id, "", "")
         return PLUGIN_HANDLED
      } else if (equali(colname, "help")) {
         trail_help(id)
         return PLUGIN_HANDLED
      }
     
      if (typenum) {
         if (typenum<1 || typenum>NUM_SPRITES) {
            client_print(id, print_chat, "Тип линии должен быть в диапазоне [1,%d].", NUM_SPRITES)
            return PLUGIN_HANDLED
         }
         typenum--
         gl_trail_type[id] = gl_sprite[typenum]
         gl_trail_size[id] = gl_def_sprite_size[typenum]
         gl_trail_brightness[id] = gl_def_sprite_brightness[typenum]
         if (arg2[0]) {
            colname = arg2
            arg2 = arg3
         } else {
            if (!gl_player_colors[id][0] && !gl_player_colors[id][1] && !gl_player_colors[id][2]) {
               do_trail(id, "", "")
               return PLUGIN_HANDLED
            }
            new r = gl_player_colors[id][0]
            new g = gl_player_colors[id][1]
            new b = gl_player_colors[id][2]
            kill_trail_task(id)
            gl_player_colors[id][0] = r
            gl_player_colors[id][1] = g
            gl_player_colors[id][2] = b
            get_user_origin(id, gl_player_position[id])
            set_task(TICK, "check_position", TASKID+id, "", 0, "b")
            trail_msg(id)
            client_print(id, print_chat, "Вы выбрали тип %d.", typenum+1)
            return PLUGIN_HANDLED
         }
      }
     
      if (equali(colname, "dark")) {
         copy(colname, MAX_NAME_LENGTH-1, arg2)
         if (!colname[0]) {
            client_print(id, print_chat, "Выберите цвет!")
            return PLUGIN_HANDLED
         }
         do_trail(id, colname, "dark")
      } else if (equali(colname, "light")) {
         copy(colname, MAX_NAME_LENGTH-1, arg2)
         if (!colname[0]) {
            client_print(id, print_chat, "Выберите цвет!")
            return PLUGIN_HANDLED
         }
         do_trail(id, colname, "light")
      }
      else {
         do_trail(id, colname, "")
      }
   }
   return PLUGIN_CONTINUE
}

/*****************************************************************************************
*****************************************************************************************/
do_trail(id, colname[], intensity[]) {
   new i
   new name[33]
 
   get_user_name(id, name, 32)
   if (!colname[0]) {
      kill_trail_task(id)
      gl_player_colors[id][0] = random(256)
      gl_player_colors[id][1] = random(256)
      gl_player_colors[id][2] = random(256)
      get_user_origin(id, gl_player_position[id])
      set_task(TICK, "check_position", TASKID+id, "", 0, "b")
      trail_msg(id)
      client_print_color(id, print_team_default, "^3случайный ^4траил ^3trail ^4randome")
      return
   }
   for (i=0; i<gl_num_colors; i++) {
      if (equali(colname, gl_color_names[i])) {
         new Float:intens, r, g, b
         if (equali(intensity, "dark")) {
            intens = 0.5
         } else if (equali(intensity, "light")) {
            intens = 2.0
         } else {
            copy(intensity, 1, "")
            intens = 1.0
         }
         kill_trail_task(id)
         r = floatround(float(gl_colors[i][0]) * intens)
         g = floatround(float(gl_colors[i][1]) * intens)
         b = floatround(float(gl_colors[i][2]) * intens)
         gl_player_colors[id][0] = min(r, 255)
         gl_player_colors[id][1] = min(g, 255)
         gl_player_colors[id][2] = min(b, 255)
         get_user_origin(id, gl_player_position[id])
         set_task(TICK, "check_position", TASKID+id, "", 0, "b")
         trail_msg(id)
         if (intensity[0]) {
            client_print(id, print_chat, "[Grean Trail]- Line", intensity, colname)
         } else {
            client_print(id, print_chat, "[Grean Trail]- Line", colname)
         }
         return
      }
   }
   client_print(id, print_chat, "Извините, %s, но цвета '%s' - нет!", name, colname)
   return
}

/*****************************************************************************************
*****************************************************************************************/
public check_position(taskid) {
   new origin[3], id = taskid-TASKID
     
   if (!get_user_team(id)) {
      kill_trail_msg(id)
      return
   }

   get_user_origin(id, origin)
   if (origin[0]!=gl_player_position[id][0] || origin[1]!=gl_player_position[id][1] || origin[2]!=gl_player_position[id][2]) {
      if (get_distance(origin, gl_player_position[id])>MAX_DISTANCE || gl_timer_count[id] >= gl_timer_limit/2) {
         kill_trail_msg(id)
         trail_msg(id)
      }
      gl_player_position[id][0] = origin[0]
      gl_player_position[id][1] = origin[1]
      gl_player_position[id][2] = origin[2]
      gl_timer_count[id] = 0
   } else {
      if (gl_timer_count[id] < gl_timer_limit) gl_timer_count[id]++
   }
}

/*****************************************************************************************
*****************************************************************************************/
kill_trail_task(id) {
   if (task_exists(TASKID+id)) remove_task(TASKID+id)
   kill_trail_msg(id)
   gl_player_colors[id][0] = gl_player_colors[id][1] = gl_player_colors[id][2] = 0
}

/*****************************************************************************************
*****************************************************************************************/
kill_trail_msg(id) {
   gl_timer_count[id] = 0

   message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
   write_byte(99)   // TE_KILLBEAM
   write_short(id)
   message_end()
}

/*****************************************************************************************
*****************************************************************************************/
trail_msg(id) {
   message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
   write_byte(22)   // TE_BEAMFOLLOW
   write_short(id)
   write_short(gl_trail_type[id])
   write_byte(gl_trail_life*10)
   write_byte(gl_trail_size[id])
   write_byte(gl_player_colors[id][0])
   write_byte(gl_player_colors[id][1])
   write_byte(gl_player_colors[id][2])
   write_byte(gl_trail_brightness[id])
   message_end()

}

/*****************************************************************************************
*****************************************************************************************/
restart_player_trail(id) {
   if (task_exists(TASKID+id)) {
      remove_task(TASKID+id)
      kill_trail_msg(id)
      get_user_origin(id, gl_player_position[id])
      set_task(TICK, "check_position", TASKID+id, "", 0, "b")
      trail_msg(id)
   }
}

/*****************************************************************************************
*****************************************************************************************/
restart_players_trails() {
   new playercount
 
   get_players(gl_players, playercount)
   for (new i=0; i<playercount; i++) {
      restart_player_trail(gl_players[i])
   }
}

/*****************************************************************************************
*****************************************************************************************/
say_to_all(msg[], id) {
   new playercount
 
   get_players(gl_players, playercount)
   for (new i=0; i<playercount; i++) {
      if (gl_players[i]!=id) client_print(gl_players[i], print_chat, msg)
   }
}

/*****************************************************************************************
*****************************************************************************************/
trail_help(id) {
   new msg[200], clen=0
       
   console_print(id, "^nTrail Colors List:^n")
   for (new i=0; i<gl_num_colors; i++) {
      clen += format(msg[clen], 199-clen, "%s ", gl_color_names[i])
      if (clen > 80) {
         console_print(id, msg)
         copy(msg, 1, "")
         clen = 0
      }
   }
   console_print(id, "^nNOTE: All colors can be prefixed by the words 'light' or 'dark'.^n")
   console_print(id, "^nSay 'trail <color>' to get a colored trail.^nSay 'trail off' to turn trail off.")
   console_print(id, "Say 'trail <number> [color]' to change the look of the trail.^n")
   console_print(id, "^nExamples:")
   console_print(id, "    trail")
   console_print(id, "    trail off")
   console_print(id, "    trail tomato")
   console_print(id, "    trail 6 gold")
   console_print(id, "    trail 11 light blue")
   client_print(id, print_chat, "The colors list has been displayed in your console.")
}

/*****************************************************************************************
*****************************************************************************************/
bool:parse_file() {
   new got_line, line_num=0,  len=0, parsed
   new r[3][4], g[3][4], b[3][4]
   new full_line[MAX_TEXT_LENGTH], rest_line[MAX_TEXT_LENGTH], cfgdir[MAX_TEXT_LENGTH], cfgpath[MAX_TEXT_LENGTH]
 
   gl_num_colors = 0
   get_configsdir(cfgdir, MAX_TEXT_LENGTH)
   format(cfgpath, MAX_TEXT_LENGTH, "%s/%s", cfgdir, CFG_FILE)
   if (!file_exists(cfgpath)) {
      log_amx("ERROR: Cannot find configuration file '%s'!", cfgpath)
      return false
   }
   got_line = read_file(cfgpath, line_num, full_line, MAX_TEXT_LENGTH, len)
   if (got_line <=0) {
      log_amx("ERROR: Cannot read configuration file '%s'!", cfgpath)
      return false
   }
   while (got_line>0) {
      if (!equal(full_line, "//", 2) && len) {
         strtok(full_line, gl_color_names[gl_num_colors], MAX_NAME_LENGTH, rest_line, MAX_TEXT_LENGTH, ' ', 1)
         copy(full_line, MAX_TEXT_LENGTH, rest_line)

         parsed = parse(full_line,r[0],3,g[0],3,b[0],3)
         if (parsed<3) {
            log_amx("ERROR: Not enough colors, line %d in configuration file '%s'!", 1+line_num, CFG_FILE)
            return false
         }
         gl_colors[gl_num_colors][0] = str_to_num(r[0])
         gl_colors[gl_num_colors][1] = str_to_num(g[0])
         gl_colors[gl_num_colors][2] = str_to_num(b[0])

         gl_num_colors++
         if (gl_num_colors>=MAX_COLORS) {
            log_amx("WARNING: Max colors reached in file '%s'!", CFG_FILE)
            return true
         }
      }
      line_num++
      got_line = read_file(cfgpath, line_num, full_line, MAX_TEXT_LENGTH, len)
   }
   return true
}

check_map() {
   new got_line, line_num, len
   new cfgdir[MAX_TEXT_LENGTH]
   new cfgpath[MAX_TEXT_LENGTH]
   new mapname[MAX_NAME_LENGTH]
   new txt[MAX_TEXT_LENGTH]

   get_configsdir(cfgdir, MAX_TEXT_LENGTH-1)
   get_mapname(mapname, MAX_NAME_LENGTH-1)

   format(cfgpath, MAX_TEXT_LENGTH, "%s/sensiblemaps.cfg", cfgdir)
 
   if (file_exists(cfgpath)) {
      got_line = read_file(cfgpath, line_num, txt, MAX_TEXT_LENGTH-1, len)
      while (got_line>0) {
         if (equali(txt, mapname)) return 1
         line_num++
         got_line = read_file(cfgpath, line_num, txt, MAX_TEXT_LENGTH-1, len)
      }
   }
   return 0
}
stock print_col_chat(const id, const input[], any:...)
{      
        new count = 1, players[32];    
        static msg[191];      
        vformat(msg, 190, input, 3);  
        replace_all(msg, 190, "!g", "^4");
        replace_all(msg, 190, "!y", "^1");
        replace_all(msg, 190, "!t", "^3");
        if (id) players[0] = id; else get_players(players, count, "ch");      
        {      
                for ( new i = 0; i < count; i++ )      
                {      
                        if ( is_user_connected(players[i]) )  
                        {      
                                message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i]);    
                                write_byte(players[i]);
                                write_string(msg);    
                                message_end();
                        }      
                }      
        }      
}
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу