Half-Life и Adrenaline Gamer форум

Всё об игре в Халф-Лайф и АГ
Текущее время: 18 апр 2024, 21:53

Часовой пояс: UTC + 5 часов [ Летнее время ]




Начать новую тему Ответить на тему  [ Сообщений: 16 ]  На страницу 1, 2  След.
Автор Сообщение
 Заголовок сообщения: Flashlight Power Plugin Request
СообщениеДобавлено: 01 май 2013, 08:18 
Не в сети
Зарегистрирован:
01 май 2013, 08:10
Последнее посещение:
16 сен 2014, 05:43
Сообщения: 92
Hi,

If it is possible, I would like to request a amxmodx plugin in case someone here knows how to make one. Sorry for being so daring.

I want a plugin that will make the flashlight not run out of power and that will force all of the players to have it on at the admin's will.
I found this code at another website where I can request plugins, but so far they don't give me an answer.

Код:
#include < amxmodx >
#include < fakemeta >

const m_iFlashBattery = 244;

public plugin_init( ) {
   register_plugin( "Infinity Flash Bat", "1.0", "xPaw" );
   
   register_message( get_user_msgid( "FlashBat" ),   "MsgFlashBat" );
   register_message( get_user_msgid( "Flashlight" ), "MsgFlashLight" );
}

public MsgFlashLight( const MsgId, const MsgType, const id )
   set_msg_arg_int( 2, ARG_BYTE, 100 );

public MsgFlashBat( const MsgId, const MsgType, const id ) {
   if( get_msg_arg_int( 1 ) < 100 ) {
      set_msg_arg_int( 1, ARG_BYTE, 100 );
      
      set_pdata_int( id, m_iFlashBattery, 100, 5 );
   }
}

I tested it, but it only makes the flashlight not run out of power. It does not force the player's flashlight to be at all times, since they join the server until they leave.

I hope somebody answers.

Thanks :)

_________________
Pain is weakness leaving your body.

FOUNDER OF X-FACTOR 2 IN USA AND GERMANY.
http://www.gametracker.com/clan/xf2/
http://steamcommunity.com/groups/XF2
https://www.facebook.com/groups/xf2hl/
Изображение


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: Flashlight Power Plugin Request
СообщениеДобавлено: 01 май 2013, 08:53 
Не в сети
Site Admin
Зарегистрирован:
01 июн 2010, 01:27
Последнее посещение:
18 апр 2024, 17:14
Сообщения: 6867
Hi.

Not sure about your coding skills, but you have/can to try this:
To turn flashlight on you have to send message to that client and set his pev->effects field. Here how it looks in HLSDK:
Код:
SetBits(pev->effects, EF_DIMLIGHT);
MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev );
   WRITE_BYTE(1);
   WRITE_BYTE(m_iFlashBattery);
MESSAGE_END();
To turn it off do opposite:
Код:
ClearBits(pev->effects, EF_DIMLIGHT);
MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev );
   WRITE_BYTE(0);
   WRITE_BYTE(m_iFlashBattery);
MESSAGE_END();
To block users ability to change it you need to block impulse command (you can look at the code here: viewtopic.php?p=14750#p14750). Flashlight is impulse 100.
Feel free to ask something.


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: Flashlight Power Plugin Request
СообщениеДобавлено: 01 май 2013, 09:01 
Не в сети
Зарегистрирован:
01 май 2013, 08:10
Последнее посещение:
16 сен 2014, 05:43
Сообщения: 92
My coding skills are awful.
I copied and pasted that from another site. So you just wasted your time explaining all that to me. Im sorry lol.
In other words I dont understand that at all.

_________________
Pain is weakness leaving your body.

FOUNDER OF X-FACTOR 2 IN USA AND GERMANY.
http://www.gametracker.com/clan/xf2/
http://steamcommunity.com/groups/XF2
https://www.facebook.com/groups/xf2hl/
Изображение


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: Flashlight Power Plugin Request
СообщениеДобавлено: 02 май 2013, 04:16 
Не в сети
Зарегистрирован:
01 май 2013, 08:10
Последнее посещение:
16 сен 2014, 05:43
Сообщения: 92
Ok,

I understood about the cmd_blocker plugin. I changed impulse 101 for impulse 100 in the .sma file, then compiled it. And that plugin is going to prevent clients from turning on/off the flashlight, right?

Now, how do I force my players to have the flashlight on at all times since they join the server until they leave?
That's the part I'm clueless about. :D

Posted after 6 minutes 21 second:
Hi,

I just tested the cmd_blocker.amxx and it didn't work. I still can turn the flashlight on and off like the plugin was not loaded. Amxmodx does not show any error log file. what am i missing?

Posted after 11 minutes 39 seconds:
Ok, that was so dumb of me.
I just noticed that only admins with the BAN flag can turn the flashlight on/off. I removed that part of the .sma file and compiled it again. Like this only:

Код:
#include <amxmodx>
#include <engine>

public plugin_init(){
   register_plugin("Commands Blocker","Sydney","GordonFreeman")
   
   register_impulse(100,"blockme")
   register_clcmd("give","blockme")
}

It did work :)

But I'm still clueless about forcing the player's flashlight to be on at all times. :( I hope it works for bots as well.

_________________
Pain is weakness leaving your body.

FOUNDER OF X-FACTOR 2 IN USA AND GERMANY.
http://www.gametracker.com/clan/xf2/
http://steamcommunity.com/groups/XF2
https://www.facebook.com/groups/xf2hl/
Изображение


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: Flashlight Power Plugin Request
СообщениеДобавлено: 02 май 2013, 05:18 
Не в сети
Site Admin
Зарегистрирован:
01 июн 2010, 01:27
Последнее посещение:
18 апр 2024, 17:14
Сообщения: 6867
Something like this (didn't tested, feel free to fix bugs):
Код:
#include <fakemeta>

new gmsgFlashlight;

public plugin_init()
{
   gmsgFlashlight = get_user_msgid("Flashlight");
}

public client_putinserver(id)
{
   switch_flashlight(id, 1);
}

switch_flashlight(id, state)
{
   new effects = pev(id, pev_effects);
   if (state > 0)
      effects |= EF_DIMLIGHT;
   else
      effects &= ~EF_DIMLIGHT;
   set_pev(id, pev_effects, effects);

   engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, gmsgFlashlight, {0.0, 0.0, 0.0}, id);
   write_byte(state > 0 ? 1 : 0);
   write_byte(100);
   message_end();
}


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: Flashlight Power Plugin Request
СообщениеДобавлено: 02 май 2013, 07:00 
Не в сети
Зарегистрирован:
01 май 2013, 08:10
Последнее посещение:
16 сен 2014, 05:43
Сообщения: 92
Код:
Your plugin failed to compile!

Read the errors below:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

include\fakemeta.inc(15) : error 017: undefined symbol "AMXX_VERSION_NUM"
include\fakemeta.inc(247) : error 070: rational number support was not enabled
flashlight_on.sma(7) : error 017: undefined symbol "get_user_msgid"
flashlight_on.sma(12) : error 088: number of arguments does not match definition
flashlight_on.sma(15) : error 010: invalid function or declaration
flashlight_on.sma(18) : error 029: invalid expression, assumed zero
flashlight_on.sma(24) : error 017: undefined symbol "MSG_ONE_UNRELIABLE"
flashlight_on.sma(24) : warning 215: expression has no effect
flashlight_on.sma(24) : error 070: rational number support was not enabled
flashlight_on.sma(24) : error 029: invalid expression, assumed zero
flashlight_on.sma(24) : fatal error 107: too many error messages on one line

Compilation aborted.
10 Errors.
Could not locate output file flashlight_on.amx (compile failed).

_________________
Pain is weakness leaving your body.

FOUNDER OF X-FACTOR 2 IN USA AND GERMANY.
http://www.gametracker.com/clan/xf2/
http://steamcommunity.com/groups/XF2
https://www.facebook.com/groups/xf2hl/
Изображение


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: Flashlight Power Plugin Request
СообщениеДобавлено: 02 май 2013, 07:18 
Не в сети
Site Admin
Зарегистрирован:
01 июн 2010, 01:27
Последнее посещение:
18 апр 2024, 17:14
Сообщения: 6867
It is not a plugin to be honest. Just a code you have to combine into your plugin.


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: Flashlight Power Plugin Request
СообщениеДобавлено: 02 май 2013, 08:50 
Не в сети
Зарегистрирован:
01 май 2013, 08:10
Последнее посещение:
16 сен 2014, 05:43
Сообщения: 92
Код:
#include < amxmodx >
#include < fakemeta >

const m_iFlashBattery = 244;

public plugin_init( ) {
   register_plugin( "Infinity Flash Bat", "1.0", "xPaw" );
   
   register_message( get_user_msgid( "FlashBat" ),   "MsgFlashBat" );
   register_message( get_user_msgid( "Flashlight" ), "MsgFlashLight" );
}

public MsgFlashLight( const MsgId, const MsgType, const id )
   set_msg_arg_int( 2, ARG_BYTE, 100 );

public MsgFlashBat( const MsgId, const MsgType, const id ) {
   if( get_msg_arg_int( 1 ) < 100 ) {
      set_msg_arg_int( 1, ARG_BYTE, 100 );
     
      set_pdata_int( id, m_iFlashBattery, 100, 5 );
   }
}

public client_putinserver(id)

{
   switch_flashlight(id, 1);
}

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

flashlight_on.sma(27) : error 017: undefined symbol "switch_flashlight"

1 Error.
Could not locate output file flashlight_on.amx (compile failed).

Am I getting close? :)

_________________
Pain is weakness leaving your body.

FOUNDER OF X-FACTOR 2 IN USA AND GERMANY.
http://www.gametracker.com/clan/xf2/
http://steamcommunity.com/groups/XF2
https://www.facebook.com/groups/xf2hl/
Изображение


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: Flashlight Power Plugin Request
СообщениеДобавлено: 02 май 2013, 11:06 
Не в сети
Site Admin
Зарегистрирован:
01 июн 2010, 01:27
Последнее посещение:
18 апр 2024, 17:14
Сообщения: 6867
-Maverick- писал(а):
Am I getting close?
No. xD
Use different plugin as a base. I mean one you posted above.


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: Flashlight Power Plugin Request
СообщениеДобавлено: 03 май 2013, 04:22 
Не в сети
Зарегистрирован:
01 май 2013, 08:10
Последнее посещение:
16 сен 2014, 05:43
Сообщения: 92
That's what I did.

The first time I tried gathering both yours and mine together didn't work. I got like 8 errors from the amxmodx compiler. Then I deleted and modified a few things that I found logical to me, but still, I got 1 error. I'm not a coder.
I'm obviously missing something. what is it?

_________________
Pain is weakness leaving your body.

FOUNDER OF X-FACTOR 2 IN USA AND GERMANY.
http://www.gametracker.com/clan/xf2/
http://steamcommunity.com/groups/XF2
https://www.facebook.com/groups/xf2hl/
Изображение


Вернуться к началу
 Профиль 
  
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему  [ Сообщений: 16 ]  На страницу 1, 2  След.

Часовой пояс: UTC + 5 часов [ Летнее время ]


Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
Создано на основе phpBB® Forum Software © phpBB Group
Русская поддержка phpBB