AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   fakemeta's set_pev crash server (https://forums.alliedmods.net/showthread.php?t=187383)

Liverwiz 06-12-2012 14:11

fakemeta's set_pev crash server
 
Ok....so in my plugin i have a skin and originally i used engine entity_set_string() but Connor told me to use fakemeta's set_pev here....
http://forums.alliedmods.net/showpos...2&postcount=11

now....i either did it wrong, misunderstood his post, or it is just an incorrect concept. Either way...i need this fixed.

This is what i did:
PHP Code:

// globals
new g_allocPmodg_allocVmod    // model Handles

// plugin_init
g_allocPmod engfunc(EngFunc_AllocString"model/p_bknuckles.mdl")
    
g_allocVmod engfunc(EngFunc_AllocString"model/v_bknuckles.mdl")

// show_model
        
set_pev(idpev_viewmodelg_allocVmod)
        
set_pev(idpev_weaponmodelg_allocPmod)

// This was my original code (that works fine)
entity_set_string(idEV_SZ_viewmodel"models/v_bknuckles.mdl")
entity_set_string(idEV_SZ_weaponmodel"models/p_bknuckles.mdl"

can someone tell me what's going on here? I read the includes, stocks, and const files for fakemeta and it didn't tell me anything, realy.

ConnorMcLeod 06-12-2012 16:55

Re: fakemeta's set_pev crash server
 
Code is ok, you may have made an error somewhere else.

Exolent[jNr] 06-12-2012 17:35

Re: fakemeta's set_pev crash server
 
You forgot the "s" in "models" for your model path.

ConnorMcLeod 06-12-2012 17:38

Re: fakemeta's set_pev crash server
 
Oh lol !!!


That wouldn't have happened if you had do :

new const g_szModel[] = "models/p_bknuckles.mdl"

..

precache_model( g_szModel )

..

g_iAlloc = engfunc(EngFunc_AllocString, g_szModel)


And doing this you save again some memory.

Liverwiz 06-12-2012 18:39

Re: fakemeta's set_pev crash server
 
Quote:

Originally Posted by Exolent[jNr] (Post 1727534)
You forgot the "s" in "models" for your model path.

LOL! much thanks....


Quote:

Originally Posted by ConnorMcLeod (Post 1727539)
Oh lol !!!


That wouldn't have happened if you had do :

new const g_szModel[] = "models/p_bknuckles.mdl"

..

precache_model( g_szModel )

..

g_iAlloc = engfunc(EngFunc_AllocString, g_szModel)


And doing this you save again some memory.

Now....how would that save memory? You're adding extra variables to the globe.

^SmileY 06-13-2012 00:00

Re: fakemeta's set_pev crash server
 
Quote:

Originally Posted by Liverwiz (Post 1727565)
LOL! much thanks....




Now....how would that save memory? You're adding extra variables to the globe.

is not a extra variables, its a unique variable...

Your original code has multiple constants.

dFF 06-13-2012 03:56

Re: fakemeta's set_pev crash server
 
Quote:

Originally Posted by ConnorMcLeod (Post 1727539)
And doing this you save again some memory.

Sorry for offtopic.

For example I have this:
PHP Code:

public plugin_precache()
{
    
precache_model"models/w_MyModel.mdl" )
}

public 
Fm_SetModelentmodel[ ] )
{
    [...]
    
engfuncEngFunc_SetModelent"models/w_MyModel.mdl" )


and If I use:

PHP Code:

new const g_szWorldModel[ ] = "models/w_MyModel.mdl"

public plugin_precache()
{
    
precache_modelg_szWorldModel )
}

public 
Fm_SetModelentmodel[ ] )
{
    [...]
    
engfuncEngFunc_SetModelentg_szWorldModel )


will clean a bit of memory ? On world model is not necessary to AllocString, right ?

Arkshine 06-13-2012 05:06

Re: fakemeta's set_pev crash server
 
Yes and yes.

dFF 06-13-2012 05:14

Re: fakemeta's set_pev crash server
 
Ok, thanks and thanks :mrgreen:.

Liverwiz 06-13-2012 11:56

Re: fakemeta's set_pev crash server
 
So this would be the best way to do it, yes?
Sorry to get redundant with questions, i'm having a mid-life crisis and just ran out of weed.

PHP Code:

// globals 
new g_allocPmodg_allocVmod    // model Handles 
static const szg_Pbk[] = "models/p_bknuckles.mdl"
static const szg_Vbk[] = "models/v_bknuckles.mdl"

// plugin_init 
g_allocPmod engfunc(EngFunc_AllocStringszg_Pbk//"model/p_bknuckles.mdl") 
    
g_allocVmod engfunc(EngFunc_AllocStringszg_Vbk//"model/v_bknuckles.mdl") 

// show_model 
        
set_pev(idpev_viewmodelg_allocVmod
        
set_pev(idpev_weaponmodelg_allocPmod

// This was my original code (that works fine) 
entity_set_string(idEV_SZ_viewmodel"models/v_bknuckles.mdl"
entity_set_string(idEV_SZ_weaponmodel"models/p_bknuckles.mdl"

or do i skip the EngFunc_AllocString part and just use set_pev(id, pev_viewmodel, szg_Vbk)


All times are GMT -4. The time now is 06:08.

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