Fix Santa Hat plugin - normal players have a hat too

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
glmmlg
Извън линия
Foreigner
Foreigner
Мнения: 31
Регистриран на: 20 Фев 2019, 21:51
Се отблагодари: 6 пъти
Получена благодарност: 2 пъти

Fix Santa Hat plugin - normal players have a hat too

Мнение от glmmlg » 20 Фев 2019, 22:24

Someone can help to fix this plugin ? i want to do this : if one admin with a specifically flags connect on server to use my model. Plugin actually does this but i think something wrong bcz i saw on server player can use this model and he is not admin.

Код за потвърждение: Избери целия код

#include <amxmodx> 
#include <fakemeta> 
#include <hamsandwich> 

new g_Enable;
new g_bwEnt[33];
new g_CachedStringInfoTarget;

public plugin_init() {
	register_plugin( "Santa Hat", "1.2", "xPaw" );
	register_cvar("santa_hat", "1.2", FCVAR_SERVER);
	g_Enable = register_cvar("amx_santahat", "1");

	RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);
	g_CachedStringInfoTarget = engfunc( EngFunc_AllocString, "info_target" );
}

public plugin_precache()
	precache_model("models/gmv.mdl");

public fwHamPlayerSpawnPost( const player ) {
   if ( get_pcvar_num( g_Enable ) && is_user_alive( player ) && get_user_flags ( player ) & ADMIN_RESERVATION ) {
      new iEnt = g_bwEnt[ player ];
      if( !pev_valid( iEnt ) ) {
         g_bwEnt[ player ] = iEnt = engfunc ( EngFunc_CreateNamedEntity, g_CachedStringInfoTarget );
         set_pev( iEnt, pev_movetype, MOVETYPE_FOLLOW );
         set_pev( iEnt, pev_aiment, player );
         engfunc( EngFunc_SetModel, iEnt, "models/gmv.mdl" );
      }
   }
}
Последно промяна от OciXCrom на 20 Фев 2019, 22:51, променено общо 1 път.
Причина: Fixed title. Please use a more descriptive title next time.

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Fix Santa Hat plugin - normal players have a hat too

Мнение от OciXCrom » 20 Фев 2019, 22:55

Next time please add a better description for the thread in the thread's title. Look at how I changed it and use it as an example.

On-topic: the problem is probably because the hat isn't removed when a player disconnects, so the next player that connects with the same id will get the hat no matter if he has the flag or not. This should fix the problem:

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#if !defined client_disconnected
	#define client_disconnected client_disconnect
#endif

new g_Enable;
new g_bwEnt[33];
new g_CachedStringInfoTarget;

public plugin_init() {
	register_plugin( "Santa Hat", "1.2", "xPaw" );
	register_cvar("santa_hat", "1.2", FCVAR_SERVER);
	g_Enable = register_cvar("amx_santahat", "1");

	RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);
	g_CachedStringInfoTarget = engfunc( EngFunc_AllocString, "info_target" );
}

public plugin_precache()
	precache_model("models/gmv.mdl");

public client_disconnected( id )
{
	if( pev_valid( g_bwEnt[ id ] ) ) {
		engfunc ( EngFunc_RemoveEntity, g_bwEnt[ id ] );
	}
}

public fwHamPlayerSpawnPost( const player ) {
   if ( get_pcvar_num( g_Enable ) && is_user_alive( player ) && get_user_flags( player ) & ADMIN_RESERVATION ) {
      new iEnt = g_bwEnt[ player ];
      if( !pev_valid( iEnt ) ) {
         g_bwEnt[ player ] = iEnt = engfunc ( EngFunc_CreateNamedEntity, g_CachedStringInfoTarget );
         set_pev( iEnt, pev_movetype, MOVETYPE_FOLLOW );
         set_pev( iEnt, pev_aiment, player );
         engfunc( EngFunc_SetModel, iEnt, "models/gmv.mdl" );
      }
   }
}

Аватар
glmmlg
Извън линия
Foreigner
Foreigner
Мнения: 31
Регистриран на: 20 Фев 2019, 21:51
Се отблагодари: 6 пъти
Получена благодарност: 2 пъти

Fix Santa Hat plugin - normal players have a hat too

Мнение от glmmlg » 22 Фев 2019, 11:12

Tnx, now no more problem :)

Заключено
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Заявки за плъгини”

Кой е на линия

Потребители разглеждащи този форум: 0 регистрирани и 14 госта