Raised This Month: $51 Target: $400
 12% 

Change model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Alexxxxxxxxx
Member
Join Date: Aug 2017
Old 12-13-2017 , 08:43   Change model
Reply With Quote #1

Hello, i have this code for change player skin

only the part of change model task func, and player spawn codes

But sometimes, i get
Host_Error: CL_EntityNum: 1373 is an invalid number, cl.max_edicts is 1365


PHP Code:
new g_ZombieModels[7][] = 
{
    
"z_out_clasic",
    
"z_out_raptor",
    
"z_out_predator_blue",
    
"z_out_mutant",
    
"frozen",
    
"z_out_regenerator",
    
"z_out_hunter"
};

new 
g_HumanModels[4][] =
{
    
"terror",
    
"gign",
    
"sas",
    
"arctic"
};

public 
fw_PlayerSpawn_Post(id)
{
    if (!
is_user_alive(id) || !fm_cs_get_user_team(id))
        return;
    
remove_task(id+250)
    static 
Float:fCurrentTime;
    
fCurrentTime get_gametime();
    if (
fCurrentTime g_fLastChangedModel >= 0.35)
    {
        
ChangeModel(id 250);
        
g_fLastChangedModel fCurrentTime;
    }
    else
    {
        
set_task((g_fLastChangedModel 0.35) - fCurrentTime"ChangeModel"id 250);
        
g_fLastChangedModel g_fLastChangedModel 0.35;
    }
}

public 
ChangeModel(iTask)
{
    static 
bool:bChange;
    static 
cModel[32];
    static 
i;
    static 
ID
    ID 
iTask 250;
    
bChange true;
    static 
iFlags;
    
iFlags get_user_flags(ID);
    
get_user_model(IDcModel31);
    
    if (!
g_zombie[ID])
    {
        if (!
g_sniper[ID] && !g_survivor[ID])
        {
            if (
iFlags ADMIN_VOTE)
            {
                if (
equal(cModel"z_out_admin"))
                {
                    
bChange false;
                }
            }
            else if (
iFlags ADMIN_PASSWORD)
            {
                if (
equal(cModel"owner"))
                {
                    
bChange false;
                }
            }
            else
            {
                for (
04i++)
                {
                    if (
equal(cModelg_HumanModels[i]))
                    {
                        
bChange false;
                    }
                }
            }
        }
    }
    if (
bChange)
    {
        if (!
g_zombie[ID])
        {
            if(!
g_survivor[ID] && !g_sniper[ID])
            {
                if(!
is_user_admin(ID))
                {
                    
set_user_model(IDg_HumanModels[random_num(03)])
                }
                else
                {
                    if (
iFlags ADMIN_VOTE)
                    {
                        
set_user_model(ID"z_out_admin")
                    }
                    else
                    {
                        
set_user_model(ID"owner")
                    }
                }
            }
            else
            {
                if(
g_survivor[ID])
                {
                    
set_user_model(ID"zp64_survivor")
                }
                if(
g_sniper[ID])
                {
                    
set_user_model(ID"arctic")
                }
            }
        }
        else
        {
            if (!
g_nemesis[ID] && !g_assassin[ID])
            {
                
set_user_model(IDg_ZombieModels[g_zombieclass[ID]])
            }
            if (
g_nemesis[ID])
            {
                
set_user_model(ID"monster_nemesis")
            }
            if (
g_assassin[ID])
            {
                
set_user_model(ID"Assasin_by_AsaCaMine")
            }
        }
    }
    return 
0;


Last edited by Alexxxxxxxxx; 12-15-2017 at 04:31.
Alexxxxxxxxx is offline
Alexxxxxxxxx
Member
Join Date: Aug 2017
Old 12-15-2017 , 04:42   Re: Change model
Reply With Quote #2

Help help help help help!
Alexxxxxxxxx is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 12-15-2017 , 07:15   Re: Change model
Reply With Quote #3

what is a get_user_model()? I think you`re changing it by making the actual player invisible and making a separate entity which follows the player. You exceeded the entity limit.
__________________
retired chump
DjSoftero is offline
Alexxxxxxxxx
Member
Join Date: Aug 2017
Old 12-15-2017 , 08:17   Re: Change model
Reply With Quote #4

set_user_model and get_user_model coming by model changer module by claudiuhks

about making pl;ayer invisible i dont have any function to make player invisible
PHP Code:
#include "amxxmodule.h"

class Player {
private:
    
bool Initialized;
    
bool Connected;
    
bool HasCustomModel;
    
size_t Index;
    
edict_t pEntity;

public:
    
void SetCustomModelchar pModel ) {
        
SET_CLIENT_KEYVALUEIndexGET_INFOKEYBUFFERpEntity ), "model"pModel );

        
HasCustomModel true;
    }

    
void ResetCustomModelvoid ) {
        
SET_CLIENT_KEYVALUEIndexGET_INFOKEYBUFFERpEntity ), "model""gordon" );

        
HasCustomModel false;
    }

    
void OnConnectvoid ) {
        
Initialized true;

        
Connected false;

        
HasCustomModel false;
    }

    
void OnDisconnectvoid ) {
        
Initialized false;

        
Connected false;

        
HasCustomModel false;
    }

    
void OnJoinvoid ) {
        
Initialized true;

        
Connected true;

        
HasCustomModel false;
    }

    
void OnServerActivatesize_t GivenIndexedict_t pGivenEntity ) {
        
Index GivenIndex;

        
pEntity pGivenEntity;
    }

    
edict_t GetEdictvoid ) {
        return 
pEntity;
    }

    
bool OwnsCustomModelvoid ) {
        return 
HasCustomModel;
    }

    
bool IsConnectedvoid ) {
        return 
Connected;
    }

    
bool IsInitializedvoid ) {
        return 
Initialized;
    }
};

Player g_Players33 ];

cell AMX_NATIVE_CALL get_user_modelAMX pHandlecell pParameters ) {
    static 
size_t Client;

    
Client pParameters];

    if( 
Client || Client > ( size_t gpGlobals -> maxClients ) {
        
MF_LogErrorpHandleAMX_ERR_NATIVE"Client %d is invalid!"Client );

        return 
0;
    }

    else if( !
g_PlayersClient ].IsConnected( ) ) {
        
MF_LogErrorpHandleAMX_ERR_NATIVE"Client %d is not connected!"Client );

        return 
0;
    }

    
MF_SetAmxStringpHandlepParameters], INFOKEY_VALUEGET_INFOKEYBUFFERg_PlayersClient ].GetEdict( ) ), "model" ), pParameters] );

    return 
1;
}

cell AMX_NATIVE_CALL set_user_modelAMX pHandlecell pParameters ) {
    static 
size_t Client;

    
Client pParameters];

    if( 
Client || Client > ( size_t gpGlobals -> maxClients ) {
        
MF_LogErrorpHandleAMX_ERR_NATIVE"Client %d is invalid!"Client );

        return 
0;
    }

    else if( !
g_PlayersClient ].IsConnected( ) ) {
        
MF_LogErrorpHandleAMX_ERR_NATIVE"Client %d is not connected!"Client );

        return 
0;
    }

    
g_PlayersClient ].SetCustomModelMF_GetAmxStringpHandlepParameters], 0NULL ) );

    return 
1;
}

cell AMX_NATIVE_CALL reset_user_modelAMX pHandlecell pParameters ) {
    static 
size_t Client;

    if( 
Client || Client > ( size_t gpGlobals -> maxClients ) {
        
MF_LogErrorpHandleAMX_ERR_NATIVE"Client %d is invalid!"Client );

        return 
0;
    }

    else if( !
g_PlayersClient ].IsConnected( ) ) {
        
MF_LogErrorpHandleAMX_ERR_NATIVE"Client %d is not connected!"Client );

        return 
0;
    }

    
g_PlayersClient ].ResetCustomModel( );

    return 
1;
}

AMX_NATIVE_INFO g_ModelChangerFunctions[ ] = {
    { 
"get_user_model"get_user_model },
    { 
"set_user_model"set_user_model },
    { 
"reset_user_model"reset_user_model },

    { 
NULLNULL }
};

void ServerActivate_Postedict_t pEntityintint ) {
    static 
size_t Client;

    for( 
Client 1Client <= ( size_t gpGlobals -> maxClientsClient ++ )
        
g_PlayersClient ].OnServerActivateClientClient pEntity );

    
RETURN_METAMRES_IGNORED );
}

void ClientPutInServeredict_t pEntity ) {
    static 
size_t Client;

    
Client = ( size_t ENTINDEXpEntity );

    
g_PlayersClient ].OnJoin( );

    
RETURN_METAMRES_IGNORED );
}

void ClientDisconnectedict_t pEntity ) {
    static 
size_t Client;

    
Client = ( size_t ENTINDEXpEntity );

    if( 
g_PlayersClient ].IsInitialized( ) )
        
g_PlayersClient ].OnDisconnect( );

    
RETURN_METAMRES_IGNORED );
}

qboolean ClientConnect_Postedict_t pEntity, const char *, const char *, char * ) {
    static 
size_t Client;

    
Client = ( size_t ENTINDEXpEntity );

    
g_PlayersClient ].OnConnect( );

    
RETURN_META_VALUEMRES_IGNORED);
}

void SetClientKeyValueint Clientchar *, char pKeychar * ) {
    
RETURN_METAg_PlayersClient ].OwnsCustomModel( ) && !strcmppKey"model" ) ? MRES_SUPERCEDE MRES_IGNORED );
}

void OnAmxxAttachvoid ) {
    
MF_AddNativesg_ModelChangerFunctions );

Alexxxxxxxxx is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 12-15-2017 , 14:12   Re: Change model
Reply With Quote #5

Then post in that module's thread not here.
__________________
edon1337 is offline
Alexxxxxxxxx
Member
Join Date: Aug 2017
Old 12-15-2017 , 17:46   Re: Change model
Reply With Quote #6

i am not requesting help for a module script! did you read the post ?

the problem is that it sends the same error also, with set_user_info.

Last edited by Alexxxxxxxxx; 12-15-2017 at 17:48.
Alexxxxxxxxx is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 12-16-2017 , 09:09   Re: Change model
Reply With Quote #7

Your server exceeds the allowed limit of the entities.
I think the module create new ent for new model, but don't delete the useless ones (or something like this).
__________________
My English is A0
E1_531G is offline
Alexxxxxxxxx
Member
Join Date: Aug 2017
Old 12-16-2017 , 12:46   Re: Change model
Reply With Quote #8

Quote:
Originally Posted by E1_531G View Post
Your server exceeds the allowed limit of the entities.
I think the module create new ent for new model, but don't delete the useless ones (or something like this).
wth are you talking about
Alexxxxxxxxx is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-16-2017 , 13:21   Re: Change model
Reply With Quote #9

Use cs_players_models_api or ReAPI instead of this module.
CrazY. is offline
Alexxxxxxxxx
Member
Join Date: Aug 2017
Old 12-16-2017 , 14:40   Re: Change model
Reply With Quote #10

Quote:
Originally Posted by CrazY. View Post
Use cs_players_models_api or ReAPI instead of this module.
@Crazy they both use the same function and delay...

This happens also with set_user_info, from zp 4.3

Last edited by Alexxxxxxxxx; 12-16-2017 at 14:41.
Alexxxxxxxxx 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 12:30.


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