Изменение плагина

mzeke

Участник
Сообщения
51
Реакции
4
Здравствуйте.

Мы имеем код:

C-подобный:
PerformFade(attacker, 300, {0, 0, 200, 51});

Нужно сделать чтобы значения 300, {0, 0, 200, 51} считывались из конфига /addons/sourcemod/configs/plg.cfg

чтобы при желании сменить значения не компилировать плагин заново.

Заранее спасибо.
 

R1KO

fuck society
Сообщения
9,457
Реакции
7,786
  • Команда форума
  • #2
mzeke, структура конфига? Может лучше квар?
 

mzeke

Участник
Сообщения
51
Реакции
4
R1KO,
C-подобный:
#include <sourcemod>

public Plugin:myinfo = 
{
name = "Blue Screen of Kill",
author = "johnspade",
description = "The plugin fades the screen to transparent blue for a second when you kill someone",
version = "1.0",
url = "http://johnspade.ru"
}
// Получение события смерти
public OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath);
}
// Функция затемнения
PerformFade(client, duration, const color[4]) {
new Handle:hFadeClient=StartMessageOne("Fade",client)
BfWriteShort(hFadeClient,duration)
BfWriteShort(hFadeClient,0)
BfWriteShort(hFadeClient,(0x0001))
BfWriteByte(hFadeClient,color[0])
BfWriteByte(hFadeClient,color[1])
BfWriteByte(hFadeClient,color[2])
BfWriteByte(hFadeClient,color[3])
EndMessage()
}
// Получение игрока-убийцы, применение к нему функции затемнения
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new attacker_id = GetEventInt(event, "attacker");
new attacker = GetClientOfUserId(attacker_id);
PerformFade(attacker, 300, {0, 0, 200, 51});
// PerformFade(клиент, продолжительность, {красный, зеленый, синий, прозрачность})
}

Что такое квар?

В итоге должно получиться что-то типа того:

C-подобный:
Содержимое конфига:
screen_red "0" //красный
screen_green "0" //зеленый
screen_blue "200" //синий
screen_duration "300" //продолжительность
screen_transparency "300" //прозрачность

Можно ли так сделать?
 

AlmazON

Не путать с самим yand3xmail
Сообщения
5,099
Реакции
2,755
[CS:S] Blue Screen of Kill v1.1

Квары:
screen_red "0" //красный
screen_green "0" //зеленый
screen_blue "200" //синий
screen_duration "300" //продолжительность
screen_transparency "255" //прозрачность
Файл настроек BlueScreenKill.cfg появится после запуска плагина по пути cstrike\cfg\sourcemod
PHP:
public Plugin:myinfo = 
{
	name = "Blue Screen of Kill",
	author = "johnspade",
	description = "The plugin fades the screen to transparent blue for a second when you kill someone",
	version = "1.1",
	url = "http://johnspade.ru"
}

new iDuration, iRed, iGreen, iBlue, iTransparency;
public OnPluginStart()
{
	// Получение события смерти
	HookEvent("player_death", Event_PlayerDeath);
	decl Handle:convar;
	HookConVarChange(convar=CreateConVar("screen_duration",		"300",		"Продолжительность.",_, true, 0.0),Duration);
	iDuration = GetConVarInt(convar);
	HookConVarChange(convar=CreateConVar("screen_red",			"0",		"Красный цвет.",_, true, 0.0, true, 255.0),Red);
	iRed = GetConVarInt(convar);
	HookConVarChange(convar=CreateConVar("screen_green",		"0",		"Зелёный цвет.",_, true, 0.0, true, 255.0),Green);
	iGreen = GetConVarInt(convar);
	HookConVarChange(convar=CreateConVar("screen_blue",			"200",		"Синий цвет.",_, true, 0.0, true, 255.0),Blue);
	iBlue = GetConVarInt(convar);
	HookConVarChange(convar=CreateConVar("screen_transparency",	"255",		"Прозрачность.",_, true, 0.0, true, 255.0),Transparency);
	iTransparency = GetConVarInt(convar);
	CloseHandle(convar);
	AutoExecConfig(true, "BlueScreenKill");
}

public Duration(Handle:convar, String:oldValue[], String:newValue[]) iDuration = GetConVarInt(convar);
public Red(Handle:convar, String:oldValue[], String:newValue[]) iRed = GetConVarInt(convar);
public Green(Handle:convar, String:oldValue[], String:newValue[]) iGreen = GetConVarInt(convar);
public Blue(Handle:convar, String:oldValue[], String:newValue[]) iBlue = GetConVarInt(convar);
public Transparency(Handle:convar, String:oldValue[], String:newValue[]) iTransparency = GetConVarInt(convar);

// Получение игрока-убийцы, применение к нему функции затемнения
public Event_PlayerDeath(Handle:event, String:name[], bool:dontBroadcast)
{
	new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
	if(attacker)
	{
		BfWriteShort(event=StartMessageOne("Fade",attacker),iDuration);
		BfWriteShort(event,0);
		BfWriteShort(event,0x0001);
		BfWriteByte(event,iRed);
		BfWriteByte(event,iGreen);
		BfWriteByte(event,iBlue);
		BfWriteByte(event,iTransparency);
		EndMessage();
	}
}
 

mzeke

Участник
Сообщения
51
Реакции
4
AlmazON, Все работает как надо. Спасибо большое))
 

Hejter

xor ebx, ebx
Сообщения
1,759
Реакции
393
Re: [CS:S] Blue Screen of Kill v1.1

Квары:Файл настроек BlueScreenKill.cfg появится после запуска плагина по пути cstrike\cfg\sourcemod
PHP:
public Plugin:myinfo = 
{
	name = "Blue Screen of Kill",
	author = "johnspade",
	description = "The plugin fades the screen to transparent blue for a second when you kill someone",
	version = "1.1",
	url = "http://johnspade.ru"
}

new iDuration, iRed, iGreen, iBlue, iTransparency;
public OnPluginStart()
{
	// Получение события смерти
	HookEvent("player_death", Event_PlayerDeath);
	decl Handle:convar;
	HookConVarChange(convar=CreateConVar("screen_duration",		"300",		"Продолжительность.",_, true, 0.0),Duration);
	iDuration = GetConVarInt(convar);
	HookConVarChange(convar=CreateConVar("screen_red",			"0",		"Красный цвет.",_, true, 0.0, true, 255.0),Red);
	iRed = GetConVarInt(convar);
	HookConVarChange(convar=CreateConVar("screen_green",		"0",		"Зелёный цвет.",_, true, 0.0, true, 255.0),Green);
	iGreen = GetConVarInt(convar);
	HookConVarChange(convar=CreateConVar("screen_blue",			"200",		"Синий цвет.",_, true, 0.0, true, 255.0),Blue);
	iBlue = GetConVarInt(convar);
	HookConVarChange(convar=CreateConVar("screen_transparency",	"255",		"Прозрачность.",_, true, 0.0, true, 255.0),Transparency);
	iTransparency = GetConVarInt(convar);
	CloseHandle(convar);
	AutoExecConfig(true, "BlueScreenKill");
}

public Duration(Handle:convar, String:oldValue[], String:newValue[]) iDuration = GetConVarInt(convar);
public Red(Handle:convar, String:oldValue[], String:newValue[]) iRed = GetConVarInt(convar);
public Green(Handle:convar, String:oldValue[], String:newValue[]) iGreen = GetConVarInt(convar);
public Blue(Handle:convar, String:oldValue[], String:newValue[]) iBlue = GetConVarInt(convar);
public Transparency(Handle:convar, String:oldValue[], String:newValue[]) iTransparency = GetConVarInt(convar);

// Получение игрока-убийцы, применение к нему функции затемнения
public Event_PlayerDeath(Handle:event, String:name[], bool:dontBroadcast)
{
	new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
	if(attacker)
	{
		BfWriteShort(event=StartMessageOne("Fade",attacker),iDuration);
		BfWriteShort(event,0);
		BfWriteShort(event,0x0001);
		BfWriteByte(event,iRed);
		BfWriteByte(event,iGreen);
		BfWriteByte(event,iBlue);
		BfWriteByte(event,iTransparency);
		EndMessage();
	}
}

Оффтоп
 

Hejter

xor ebx, ebx
Сообщения
1,759
Реакции
393

AlmazON

Не путать с самим yand3xmail
Сообщения
5,099
Реакции
2,755
[CS:GO/CS:S] Blue Screen of Kill v1.2

Квары:
screen_red "0" //красный
screen_green "0" //зеленый
screen_blue "200" //синий
screen_duration "300" //продолжительность
screen_transparency "255" //прозрачность
Файл настроек BlueScreenKill.cfg появится после запуска плагина по пути cstrike\cfg\sourcemod
PHP:
public Plugin:myinfo = 
{
    name = "Blue Screen of Kill",
    author = "johnspade",
    description = "The plugin fades the screen to transparent blue for a second when you kill someone",
    version = "1.2",
    url = "http://johnspade.ru"
}

new iDuration, iColor[4];
public OnPluginStart()
{
	decl String:f[5];
	GetGameFolderName(f, 5);
	if(strcmp(f, "csgo")) HookEvent("player_death", Event_PlayerDeath);
	else HookEvent("player_death", Event_PlayerDeath_GO);
	decl Handle:convar;
	HookConVarChange(convar=CreateConVar("screen_duration",        "300",        "Продолжительность.",_, true, 0.0),Duration);
	iDuration = GetConVarInt(convar);
	HookConVarChange(convar=CreateConVar("screen_red",            "0",        "Красный цвет.",_, true, 0.0, true, 255.0),Red);
	iColor[0] = GetConVarInt(convar);
	HookConVarChange(convar=CreateConVar("screen_green",        "0",        "Зелёный цвет.",_, true, 0.0, true, 255.0),Green);
	iColor[1] = GetConVarInt(convar);
	HookConVarChange(convar=CreateConVar("screen_blue",            "200",        "Синий цвет.",_, true, 0.0, true, 255.0),Blue);
	iColor[2] = GetConVarInt(convar);
	HookConVarChange(convar=CreateConVar("screen_transparency",    "255",        "Прозрачность.",_, true, 0.0, true, 255.0),Transparency);
	iColor[3] = GetConVarInt(convar);
	CloseHandle(convar);
	AutoExecConfig(true, "BlueScreenKill");
}

public Duration(Handle:convar, String:oldValue[], String:newValue[]) iDuration = GetConVarInt(convar);
public Red(Handle:convar, String:oldValue[], String:newValue[]) iColor[0] = GetConVarInt(convar);
public Green(Handle:convar, String:oldValue[], String:newValue[]) iColor[1] = GetConVarInt(convar);
public Blue(Handle:convar, String:oldValue[], String:newValue[]) iColor[2] = GetConVarInt(convar);
public Transparency(Handle:convar, String:oldValue[], String:newValue[]) iColor[3] = GetConVarInt(convar);

// Получение игрока-убийцы, применение к нему функции затемнения
public Event_PlayerDeath(Handle:event, String:name[], bool:dontBroadcast)
{
    new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
    if(attacker)
    {
        BfWriteShort(event=StartMessageOne("Fade",attacker),iDuration);
        BfWriteShort(event,0);
        BfWriteShort(event,0x0001);
        BfWriteByte(event,iColor[0]);
        BfWriteByte(event,iColor[1]);
        BfWriteByte(event,iColor[2]);
        BfWriteByte(event,iColor[3]);
        EndMessage();
    }
}
// Получение игрока-убийцы, применение к нему функции затемнения
public Event_PlayerDeath_GO(Handle:event, String:name[], bool:dontBroadcast)
{
	new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
	if(attacker)
	{
		PbSetInt(event=StartMessageOne("Fade",attacker),"duration",iDuration);
		PbSetInt(event,"hold_time",0);
		PbSetInt(event,"flags",0x0001|0x0010);
		PbSetColor(event,"clr",iColor);
		EndMessage();
	}
}
P.S. По личной просьбе mzeke.
 

mzeke

Участник
Сообщения
51
Реакции
4
AlmazON, еще раз спасибо.

Добавлено через 21 час 52 минуты
AlmazON, можно ли компилировать плагин на сайте sourcemod?

Пишет SourcePawn Compiler 1.7.0. Не будет проблем на 1.6.x?
 
Последнее редактирование:

Felton

Участник
Сообщения
799
Реакции
59
C-подобный:
#include <sourcemod>

public Plugin:myinfo =
{
name = "Blue Screen of Kill",
author = "johnspade",
description = "The plugin fades the screen to transparent blue for a second when you kill someone",
version = "1.0",
url = "http://johnspade.ru"
}
// Получение события смерти
public OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath);
}
// Функция затемнения
PerformFade(client, duration, const color[4]) {
new Handle:hFadeClient=StartMessageOne("Fade",client)
BfWriteShort(hFadeClient,duration)
BfWriteShort(hFadeClient,0)
BfWriteShort(hFadeClient,(0x0001))
BfWriteByte(hFadeClient,color[0])
BfWriteByte(hFadeClient,color[1])
BfWriteByte(hFadeClient,color[2])
BfWriteByte(hFadeClient,color[3])
EndMessage()
}
// Получение игрока-убийцы, применение к нему функции затемнения
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new attacker_id = GetEventInt(event, "attacker");
new attacker = GetClientOfUserId(attacker_id);
PerformFade(attacker, 300, {0, 0, 200, 51});
// PerformFade(клиент, продолжительность, {красный, зеленый, синий, прозрачность})
}
Добрый день.Подпелите плагин.Что бы показывало при убийсте т - красный а при убийстве ст - синий.Это возвожно сделать?
 

RusJJ

Доброе утро девачьки
Сообщения
2,582
Реакции
1,075
@Felton,
С помощью тернарного оператора:
C-подобный:
#include <cstrike>

public Plugin myinfo =
{
    name = "Blue Screen of Kill",
    author = "johnspade",
    description = "The plugin fades the screen to transparent blue for a second when you kill someone",
    version = "1.0",
    url = "http://johnspade.ru"
}

// Получение события смерти
public void OnPluginStart()
{
    HookEvent("player_death", Event_PlayerDeath);
}

// Функция затемнения
stock void PerformFade(int client, int duration, const int color[4])
{
    Handle hFadeClient = StartMessageOne("Fade", client);
    BfWriteShort(hFadeClient, duration);
    BfWriteShort(hFadeClient, 0);
    BfWriteShort(hFadeClient, (0x0001));
    BfWriteByte(hFadeClient, color[0]);
    BfWriteByte(hFadeClient, color[1]);
    BfWriteByte(hFadeClient, color[2]);
    BfWriteByte(hFadeClient, color[3]);
    EndMessage();
}

// Получение игрока-убийцы, применение к нему функции затемнения
public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
    int attacker_id = GetEventInt(event, "attacker");
    int attacker = GetClientOfUserId(attacker_id);
    PerformFade(attacker, 300, (GetClientTeam(attacker)==CS_TEAM_T)?{200, 0, 0, 51}:{0, 0, 200, 51});
    // PerformFade(клиент, продолжительность, {красный, зеленый, синий, прозрачность})
}

Или с помощью if, если глаза режет:
C-подобный:
#include <cstrike>

public Plugin myinfo =
{
    name = "Blue Screen of Kill",
    author = "johnspade",
    description = "The plugin fades the screen to transparent blue for a second when you kill someone",
    version = "1.0",
    url = "http://johnspade.ru"
}

// Получение события смерти
public void OnPluginStart()
{
    HookEvent("player_death", Event_PlayerDeath);
}

// Функция затемнения
stock void PerformFade(int client, int duration, const int color[4])
{
    Handle hFadeClient = StartMessageOne("Fade", client);
    BfWriteShort(hFadeClient, duration);
    BfWriteShort(hFadeClient, 0);
    BfWriteShort(hFadeClient, (0x0001));
    BfWriteByte(hFadeClient, color[0]);
    BfWriteByte(hFadeClient, color[1]);
    BfWriteByte(hFadeClient, color[2]);
    BfWriteByte(hFadeClient, color[3]);
    EndMessage();
}

// Получение игрока-убийцы, применение к нему функции затемнения
public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
    int attacker_id = GetEventInt(event, "attacker");
    int attacker = GetClientOfUserId(attacker_id);
    if(GetClientTeam(attacker)==CS_TEAM_T) PerformFade(attacker, 300, {200, 0, 0, 51});
    else PerformFade(attacker, 300, {0, 0, 200, 51});
    // PerformFade(клиент, продолжительность, {красный, зеленый, синий, прозрачность})
}
 

SIRIUS

♿___DejaVu
Сообщения
509
Реакции
253
C-подобный:
#include <sourcemod>

public Plugin:myinfo =
{
name = "Blue Screen of Kill",
author = "johnspade",
description = "The plugin fades the screen to transparent blue for a second when you kill someone",
version = "1.0",
url = "http://johnspade.ru"
}
// Получение события смерти
public OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath);
}
// Функция затемнения
PerformFade(client, duration, const color[4]) {
new Handle:hFadeClient=StartMessageOne("Fade",client)
BfWriteShort(hFadeClient,duration)
BfWriteShort(hFadeClient,0)
BfWriteShort(hFadeClient,(0x0001))
BfWriteByte(hFadeClient,color[0])
BfWriteByte(hFadeClient,color[1])
BfWriteByte(hFadeClient,color[2])
BfWriteByte(hFadeClient,color[3])
EndMessage()
}
// Получение игрока-убийцы, применение к нему функции затемнения
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new attacker_id = GetEventInt(event, "attacker");
new attacker = GetClientOfUserId(attacker_id);
PerformFade(attacker, 300, {0, 0, 200, 51});
// PerformFade(клиент, продолжительность, {красный, зеленый, синий, прозрачность})
}
Добрый день.Подпелите плагин.Что бы показывало при убийсте т - красный а приубийстве ст - синий.Это возвожно сделать?
В след. раз пиши лучше сюда - Написание плагинов
 

Felton

Участник
Сообщения
799
Реакции
59

RusJJ

Выдает ошибку при компиле.Оригинал что я скинул без ошибок компелиться.
Сообщения автоматически склеены:

SIRIUS

В следующий раз.Не пиши сюда, проходи мимо.
 

Paranoiiik

хачю клиентмод
Сообщения
2,047
Реакции
1,491
@Felton,
C++:
#include <sourcemod>

public Plugin myinfo =
{
    name            = "Blue Screen of Kill",
    author            = "johnspade",
    description        = "The plugin fades the screen to transparent blue for a second when you kill someone",
    version            = "1.0",
    url                = "johnspade.ru"
}

public void OnPluginStart()
{
    HookEvent("player_death", Event_PlayerDeath);
}

PerformFade(client, duration, const color[4])
{
    Handle hFadeClient = StartMessageOne("Fade",  client)
    
    BfWriteShort(hFadeClient, duration)
    BfWriteShort(hFadeClient, 0)
    BfWriteShort(hFadeClient, (0x0001))
    BfWriteByte(hFadeClient, color[0])
    BfWriteByte(hFadeClient, color[1])
    BfWriteByte(hFadeClient, color[2])
    BfWriteByte(hFadeClient, color[3])
    EndMessage()
}

public void Event_PlayerDeath(Handle event, const char[] name, bool dontBroadcast)
{
    int client = GetClientOfUserId(GetEventInt(event, "userid"));
    int attacker_id = GetEventInt(event, "attacker");
    int attacker = GetClientOfUserId(attacker_id);
    
    PerformFade(attacker, 300, (GetClientTeam(client) == 2) ? {255, 0, 0, 51} : {0, 0, 200, 51});
}
@RusJJ, ты, кстати, команду убийцы получаешь, а ему жертва нужна
Сообщения автоматически склеены:

Выдает ошибку при компиле.Оригинал что я скинул без ошибок компелиться.
Просто хватит сидеть на SM <=1.6.3
 

RusJJ

Доброе утро девачьки
Сообщения
2,582
Реакции
1,075
@Felton, ну так ошибку показать надо, а не "ошибка есть"
Сообщения автоматически склеены:

@RusJJ, ты, кстати, команду убийцы получаешь, а ему жертва нужна
А, ну да, лол) Наоборот прочитал
 

Felton

Участник
Сообщения
799
Реакции
59
на моём хосте SM 1.6.3 .А хостер почему то не спишит обновлятся
 

Felton

Участник
Сообщения
799
Реакции
59
Ну ладно не хотите помочь потому что SM 1.6.3?Всем спасибо за ответ!
 
Сверху Снизу