Raised This Month: $ Target: $400
 0% 

hats not turning off


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JusTGo
Veteran Member
Join Date: Mar 2013
Old 12-05-2021 , 06:38   Re: hats not turning off
Reply With Quote #1

You are removing/enabling the hats for all players with the current approach, do you want the player to remove only his hat or to not see all hats?
__________________
JusTGo is offline
mr_tnctproo
Junior Member
Join Date: Mar 2014
Location: UK
Old 12-05-2021 , 06:58   Re: hats not turning off
Reply With Quote #2

Quote:
Originally Posted by JusTGo View Post
You are removing/enabling the hats for all players with the current approach, do you want the player to remove only his hat or to not see all hats?
ah, and i want to not see all hats but only for this player. the rest of the players can see the hats on others

---------------------------

I've managed to fix it!
For anyone that will want this plugin in the future, here is source code for it:

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta> 

new const MODEL[] = "models/kuleczky/dd2/santa_hat.mdl";
new 
szHats[33];
new 
iEntityiMaxPlayersiInfoTarget;

public 
plugin_precache()
{
    
precache_model(MODEL);
}
public 
client_connect(id)
{
    
szHats[id] = 0;
}
public 
plugin_init()
{
    new const 
VERSION[] = "1.3";
    
    
register_plugin("Santa Hat"VERSION"xPaw");
    
register_clcmd("say /hats""ToggleHat");
    
iInfoTarget engfunc(EngFunc_AllocString"info_target");
    
iMaxPlayers get_maxplayers();
}

public 
ToggleHat(id
{
    switch(
szHats[id])
    {
        case 
0:
        {
            
AddHat();
        }
        case 
1:
        {
            
RemoveHat();
        }
    }
    return 
PLUGIN_HANDLED;
}
AddHat()
{
    for(new 
id 1id <= iMaxPlayersid++)
    {
        
iEntity engfunc(EngFunc_CreateNamedEntity,iInfoTarget);
        if(
pev_valid(iEntity))
        {
            
engfunc(EngFunc_SetModeliEntityMODEL);
            
set_pev(iEntitypev_movetypeMOVETYPE_FOLLOW);
            
set_pev(iEntitypev_aimentid);
            
set_pev(iEntitypev_ownerid);
            
entity_set_string(iEntityEV_SZ_classname"SantaHat");
            
szHats[id] = 1;
            
client_print(idprint_chat"Your hat has been added");
        }
    }
}
RemoveHat()
{
    for(new 
id 1id <= iMaxPlayersid++)
    {
        
iEntity engfunc(EngFunc_CreateNamedEntity,iInfoTarget);
        
set_pev(idpev_renderfxkRenderFxNone);
        
set_pev(idpev_rendercolor255,255,255);
        
set_pev(idpev_rendermodekRenderNormal);
        
set_pev(idpev_renderamt0.0);
        
szHats[id] = 0;
        
remove_entity_name("SantaHat");
        
client_print(idprint_chat"Your hat has been removed");
    }

I've added:
PHP Code:
entity_set_string(iEntityEV_SZ_classname"SantaHat"); 
to AddHat()

and I have changed RemoveHat() function from
PHP Code:
RemoveHat()
{
    for(new 
id 1id <= iMaxPlayersid++)
    {
        
iEntity engfunc(EngFunc_FindEntityByStringiEntity"classname"iInfoTarget);
        
engfunc(EngFunc_RemoveEntityiEntity);
        
szHats[id] = 0;
        
client_print(idprint_chat"Your hat has been removed");

    }

to
PHP Code:
RemoveHat()
{
    for(new 
id 1id <= iMaxPlayersid++)
    {
        
iEntity engfunc(EngFunc_CreateNamedEntity,iInfoTarget);
        
set_pev(idpev_renderfxkRenderFxNone);
        
set_pev(idpev_rendercolor255,255,255);
        
set_pev(idpev_rendermodekRenderNormal);
        
set_pev(idpev_renderamt0.0);
        
szHats[id] = 0;
        
remove_entity_name("SantaHat");
        
client_print(idprint_chat"Your hat has been removed");
    }


Last edited by mr_tnctproo; 12-06-2021 at 09:56. Reason: Fixed it
mr_tnctproo is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode