Не устанавливает цвет кнопки(Button)

Павел 01

Участник
Сообщения
81
Реакции
4
Народ, здаров. Проблема. Плагин блокирует второе нажатие кнопки, но не меняет цвет кнопки после нажатия.

P.s На многих форумах писали, что нужно задать прозрачный цвет, а потом задавать цветом.
Не вышло.
SetEntityRenderMode(entity, RENDER_NONE);
SetEntityRenderColor(entity,255,0,0,255);
Кнопка становилась прозрачной, но цвет не меняла. Как будто команда SetEntityRenderColor - вообще не реагирует.
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

#define PLUGIN_VERSION "2.4.6"

stock bool:Entity_IsLocked(entity) {

return bool:GetEntProp(entity, Prop_Data, "m_bLocked", 1);
}

stock Entity_Lock(entity) {
SetEntProp(entity, Prop_Data, "m_bLocked", 1, 1);
}

stock Entity_UnLock(entity) {
SetEntProp(entity, Prop_Data, "m_bLocked", 0, 1);
}

new Handle:g_cvar_Version = INVALID_HANDLE;
new Handle:g_cvar_Enable = INVALID_HANDLE;
new Handle:g_cvar_Time = INVALID_HANDLE;
new Handle:g_cvar_Deathrun = INVALID_HANDLE;
new Handle:g_cvar_TriggerTime = INVALID_HANDLE;
new Handle:g_cvar_EnableColors = INVALID_HANDLE;

new Handle:g_hLockedButtons = INVALID_HANDLE;

public Plugin:myinfo =
{
name = "No Double Push - Locks buttons.",
author = "Chanz",
description = "Locks func_button and func_rot_button entities for a certain amount of time, to prevent double pushing on deathrun or other maps.",
version = PLUGIN_VERSION,
url = "[ANY] No Double Push (2.4.6, 2015-12-05) - AlliedModders OR http://www.mannisfunhouse.eu/"
}

public OnPluginStart(){

g_cvar_Version = CreateConVar("sm_nodoublepush_version", PLUGIN_VERSION, "No Double Push Version", FCVAR_PLUGIN|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY);
SetConVarString(g_cvar_Version,PLUGIN_VERSION);
g_cvar_Enable = CreateConVar("sm_nodoublepush_enable", "1","Enable or disable No Double Push",FCVAR_PLUGIN);
g_cvar_Time = CreateConVar("sm_nodoublepush_time", "-1","The time in seconds, when the button should be unlocked again. -1 will never unlock the buttons again.",FCVAR_PLUGIN);
g_cvar_Deathrun = CreateConVar("sm_nodoublepush_deathrun", "1","How to handle deathrun maps: 0 this plugin is always on, 1 this plugin is only on deathrun maps on, 2 this plugin is only on deathrun maps off",FCVAR_PLUGIN);
g_cvar_TriggerTime = CreateConVar("sm_nodoublepush_triggertime", "5.0","Only change the time of buttons if the original time (in seconds) is greater than this value (in seconds).",FCVAR_PLUGIN);
g_cvar_EnableColors = CreateConVar("sm_nodoublepush_enablecolor", "1", "If this is set to 1 every button turns red when locked. By setting this to 0 the buttrons never change color.", FCVAR_PLUGIN);

AutoExecConfig(true,"plugin.nodoublepush");

g_hLockedButtons = CreateArray();

HookEntityOutput("func_button", "OnIn", EntityOutput:FuncButtonOutput);
HookEntityOutput("func_rot_button", "OnIn", EntityOutput:FuncButtonOutput);
}

public OnPluginEnd(){

new size = GetArraySize(g_hLockedButtons);

for(new index=0;index<size;index++){

Timer_UnLockEntity(INVALID_HANDLE, GetArrayCell(g_hLockedButtons,index));
}
}

public OnMapStart(){

ClearArray(g_hLockedButtons);

if(GetConVarBool(g_cvar_Enable)){

decl String:mapname[128];
GetCurrentMap(mapname, sizeof(mapname));

switch(GetConVarInt(g_cvar_Deathrun)){

case 1:{

if (strncmp(mapname, "dr_", 3, false) != 0 && (strncmp(mapname, "deathrun_", 9, false) != 0) && (strncmp(mapname, "dtka_", 5, false) != 0)){
//LogMessage("sm_nodoublepush_deathrun is 1 and this is the map: %s, so this plugin is disabled.",mapname);
SetConVarBool(g_cvar_Enable,false);
return;
}
}
case 2:{

if (strncmp(mapname, "dr_", 3, false) == 0 || (strncmp(mapname, "deathrun_", 9, false) == 0) || (strncmp(mapname, "dtka_", 5, false) == 0)){
//LogMessage("sm_nodoublepush_deathrun is 2 and this is the map: %s, so this plugin is disabled.",mapname);
SetConVarBool(g_cvar_Enable,false);
return;
}
}
}
}
}

public EntityOutput:FuncButtonOutput(const String:output[], entity, client, Float:delay){

if(!GetConVarBool(g_cvar_Enable)){
return;
}

if(GetEntPropFloat(entity,Prop_Data,"m_flWait") > GetConVarFloat(g_cvar_TriggerTime)){

new Float:time = GetConVarFloat(g_cvar_Time);

PushArrayCell(g_hLockedButtons,entity);
SetButtonColor(entity, true);
Entity_Lock(entity);

if(time != -1.0){

CreateTimer(time,Timer_UnLockEntity,entity);
}
}
}

public Action:Timer_UnLockEntity(Handle:timer, any:entity) {

if(IsValidEdict(entity)){
SetButtonColor(entity, false);
Entity_UnLock(entity);
}
}

SetButtonColor(entity, bool:bLocked) {

if (GetConVarInt(g_cvar_EnableColors) == 1) {

SetEntityRenderMode(entity, RENDER_TRANSCOLOR);
if (bLocked) {

// This will set the color to red
SetEntityRenderColor(entity,255,0,0,255);
}
else {

// This will set the color back to normal
SetEntityRenderColor(entity,255,255,255,255);
}
}
}
 

Вложения

  • nodoublepush.sp
    4.5 КБ · Просмотры: 1

Павел 01

Участник
Сообщения
81
Реакции
4
@AlmazON, я пробовал так. Бесполезно. Изначально стояло SetEntityRenderMode(entity, RENDER_TRANSCOLOR);
Я писал что на форумах советовали, и я попробовал SetEntityRenderMode(entity, RENDER_NONE);
 
Сверху Снизу