AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Make plugin_prechase called after plugin_cfg (https://forums.alliedmods.net/showthread.php?t=302761)

D3XT3R 11-10-2017 06:28

Make plugin_prechase called after plugin_cfg
 
i want maje plugin_prechase function be called after plugin_cfg if ther is any ideas?

indraraj striker 11-10-2017 06:38

Re: Make plugin_prechase called after plugin_cfg
 
i dont think so you will able to change the order of execution

D3XT3R 11-10-2017 06:42

Re: Make plugin_prechase called after plugin_cfg
 
as i remember some words from a devoloper amxx he said to me every thing is possible in pawn :D

Natsheh 11-10-2017 07:01

Re: Make plugin_prechase called after plugin_cfg
 
Whats the point of doing such a stupid thing?

DeMNiX 11-10-2017 07:48

Re: Make plugin_prechase called after plugin_cfg
 
better to save data to file before map changes and on restart server try to precache

D3XT3R 11-10-2017 08:07

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by Natsheh (Post 2559547)
Whats the point of doing such a stupid thing?

I will report you next time of you entre to my thread.
Stop using bad words in your .... Post

D3XT3R 11-10-2017 08:09

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by DeMNiX (Post 2559549)
better to save data to file before map changes and on restart server try to precache

you dont understand why i need that
because i want make models with cvars but if i changed model from cvar and restarted server it will not read the models to prechase them but it will read the default from from function plugin_prechase then will be called plugin_cfg whitch has the cvar model

DjSoftero 11-10-2017 11:21

Re: Make plugin_prechase called after plugin_cfg
 
just create the cvar in plugin_precache()... I think it gets called twice. So before creating a cvar check if it has already been made

OciXCrom 11-10-2017 12:43

Re: Make plugin_prechase called after plugin_cfg
 
I already told you it's not possible. And changing the sequence in which events are called is close to science fiction.

HamletEagle 11-10-2017 13:40

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by D3XT3R (Post 2559544)
as i remember some words from a devoloper amxx he said to me every thing is possible in pawn :D

He lied to you. You can not change the order of execution.

D3XT3R 11-10-2017 14:10

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by HamletEagle (Post 2559610)
He lied to you. You can not change the order of execution.

so any ideas from you to make models change by cvar?

OciXCrom 11-10-2017 15:11

Re: Make plugin_prechase called after plugin_cfg
 
By using a time travel machine.

DjSoftero 11-10-2017 15:26

Re: Make plugin_prechase called after plugin_cfg
 
I don`t really see a point in this. lets say you figured a way to precache a file from cvar(i suggested you a method). And the admin changes cvar to other model. then gg. server crashes. because the model is not going to be redownloaded. just forget it man

KiLLeR. 11-10-2017 15:35

Re: Make plugin_prechase called after plugin_cfg
 
It's very simple.... Registre the cvars in plugin_precache, not in plugin_cfg....

OciXCrom 11-10-2017 15:42

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by KiLLeR. (Post 2559644)
It's very simple.... Registre the cvars in plugin_precache, not in plugin_cfg....

Cvars are read in plugin_cfg.

D3XT3R 11-10-2017 15:44

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by DjSoftero (Post 2559642)
I don`t really see a point in this. lets say you figured a way to precache a file from cvar(i suggested you a method). And the admin changes cvar to other model. then gg. server crashes. because the model is not going to be redownloaded. just forget it man

IM ASKING FOR F HELP NOT FOR UR F SUGGESTION SO please next time when you post in my THREAD Do not post any thing not related with help!

D3XT3R 11-10-2017 15:45

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by OciXCrom (Post 2559639)
By using a time travel machine.

please share that machine with me in pm :lol:

HamletEagle 11-10-2017 16:21

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by D3XT3R (Post 2559647)
IM ASKING FOR F HELP NOT FOR UR F SUGGESTION SO please next time when you post in my THREAD Do not post any thing not related with help!

He is right, calm down.

Natsheh 11-10-2017 16:51

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by Natsheh (Post 2559547)
Whats the point of doing such a stupid thing?


KiLLeR. 11-10-2017 17:18

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by OciXCrom (Post 2559645)
Cvars are read in plugin_cfg.

Whatt?!?! :D

To authour: Keep calm and forget! You can't force plugin_cfg to be called before plugin_precache!!?!

D3XT3R 11-11-2017 07:39

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by HamletEagle (Post 2559652)
He is right, calm down.

so no way :/ to make models change with cvars? intro cfg fille :/ :cry:

HamletEagle 11-11-2017 07:44

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by D3XT3R (Post 2559773)
so no way :/ to make models change with cvars? intro cfg fille :/ :cry:

IMO it is stupid to do that. If an admin changes the cvar mid game the server will crash.

aron9forever 11-11-2017 10:10

Re: Make plugin_prechase called after plugin_cfg
 
nobody said that you can't use a config file
people are saying you can not use a CVAR

there is nothing stopping you from creating your own config file format, reading it manually at precache with fopen and parsing it for your models, like many other plugins are doing, but it is impossible to use a cvar for this (it will work, but your cvar will always have default value, since it's being set after you check it, so then what's the point?)

HamletEagle 11-11-2017 12:34

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by aron9forever (Post 2559803)
nobody said that you can't use a config file
people are saying you can not use a CVAR

there is nothing stopping you from creating your own config file format, reading it manually at precache with fopen and parsing it for your models, like many other plugins are doing, but it is impossible to use a cvar for this (it will work, but your cvar will always have default value, since it's being set after you check it, so then what's the point?)

Actually not, IIRC. Cvars are saved once they are changed, so for example if you read it in precache it will have the value from the previous map, or in other words you need to change the map to make the cvar have an effect in this scenario.
The default value is not always enforced.

I can be wrong tho, and I'm too lazy to check.

aron9forever 11-11-2017 21:55

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by HamletEagle (Post 2559832)
Actually not, IIRC. Cvars are saved once they are changed, so for example if you read it in precache it will have the value from the previous map, or in other words you need to change the map to make the cvar have an effect in this scenario.
The default value is not always enforced.

I can be wrong tho, and I'm too lazy to check.

that is right actually, but it will still crash if you change it live, so if you only read a custom cfg on plugin_precache and then cache those values, it should be safe

I believe that's how other plugins do it

HamletEagle 11-12-2017 03:33

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by aron9forever (Post 2559931)
that is right actually, but it will still crash if you change it live, so if you only read a custom cfg on plugin_precache and then cache those values, it should be safe

I believe that's how other plugins do it

I agree. In ERR I'm using config files for models/sounds/sprites.

klippy 11-12-2017 04:59

Re: Make plugin_prechase called after plugin_cfg
 
I guess you could do
Code:

server_cmd("exec path/to/file.cfg");
server_exec();

in plugin_precache and put cvars in that file. I have never done that, but I guess it could work.

Also it's a misconception that config files are executed at plugin_cfg. I don't know about older versions of AMXX, but currently plugin_cfg gets called once all plugins get initialized (had plugin_init called for them). It's badly named.

Arkshine 11-12-2017 05:35

Re: Make plugin_prechase called after plugin_cfg
 
You can still precache in plugin_init/cfg() with EngFunc_PrecacheModel/Sound/Generic.

OciXCrom 11-12-2017 07:28

Re: Make plugin_prechase called after plugin_cfg
 
But the cvars will still be useless since changing them will be impossible.

klippy 11-12-2017 07:44

Re: Make plugin_prechase called after plugin_cfg
 
I don't think the game cares when you register or change cvars or execute config files. I guess I'll test it.

EDIT:
Tested, works. If I change the cvar in the file and change the map, I retrieve the new value.
PHP Code:

#include <amxmodx>
#include <amxmisc>

#pragma semicolon true

public plugin_init()
{
    
register_plugin("Cvars Test""1.0.0""KliPPy");
}

public 
plugin_precache()
{
    new const 
testCvar register_cvar("my_test_cvar""1337");
    new 
configFilePath[256];
    
    
get_configsdir(configFilePathcharsmax(configFilePath));
    
add(configFilePathcharsmax(configFilePath), "/cvartest.cfg");
    
server_cmd("exec %s"configFilePath);
    
server_exec();
    
    
log_amx("my_test_cvar = %i"get_pcvar_num(testCvar));



OciXCrom 11-12-2017 08:07

Re: Make plugin_prechase called after plugin_cfg
 
I meant changing them via console during gameplay.

aron9forever 11-12-2017 09:11

Re: Make plugin_prechase called after plugin_cfg
 
okay, so the simplest solution is:

- create cvars to store model paths
- cache those cvar values in global variables once before precaching
- forget about cvar, use cached values to precache, and then later on apply the model to players or objects

the cvar cache will make sure that even if the cvar is changed during the game, the old precached models will be used until precaching occurs again

then it's as simple as mentioning in the plugin docs that restarts are necessary to apply changes for those cvars

sorry for overcomplicating it with the custom files, while they are also a viable solution(and they avoid storing duplicate values in memory), this is simpler, and therefore better in this context (of assisting in scripting help)

Quote:

Originally Posted by KliPPy (Post 2559954)
I guess you could do
Code:

server_cmd("exec path/to/file.cfg");
server_exec();

in plugin_precache and put cvars in that file. I have never done that, but I guess it could work.

Also it's a misconception that config files are executed at plugin_cfg. I don't know about older versions of AMXX, but currently plugin_cfg gets called once all plugins get initialized (had plugin_init called for them). It's badly named.

I deploy similar methods to ensure that config files have been executed before using their values, of course only for critical cases that happen right at server start-up, such as sql initialization

Code:
register_srvcmd("SERVER_INIT_SQL_USER", "mysql_init"); server_cmd("exec %s/sql.cfg", configs_dir); server_cmd("SERVER_INIT_SQL_USER");

This is absolutely necessary if planning to use cfg files other than server.cfg to set the value of such cvars in operations that happen as early as precache / init

HamletEagle 11-12-2017 11:13

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

sorry for overcomplicating it with the custom files, while they are also a viable solution(and they avoid storing duplicate values in memory), this is simpler, and therefore better in this context (of assisting in scripting help)
Honestly, in most of cases I would still chose to use a configuration file than a cvar. Server admins may get confused because they are changing the cvar and nothing happens.

D3XT3R 11-12-2017 17:47

Re: Make plugin_prechase called after plugin_cfg
 
i tested KliPPy way and it works =)

D3XT3R 11-12-2017 17:50

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by HamletEagle (Post 2560021)
Honestly, in most of cases I would still chose to use a configuration file than a cvar. Server admins may get confused because they are changing the cvar and nothing happens.

if it was an model cvar will be sure need to restart for prechase the models because server cant prechase new models in middle of gameplay and cvar changed or no will be same if we use cache.

CrazY. 11-13-2017 14:52

Re: Make plugin_prechase called after plugin_cfg
 
The admin can dare change the model in the middle of the game, what's up? Will it advance what you alter the order of execution? If you load the path from a file, the admin will be required to restart the server, so to speak.

D3XT3R 11-13-2017 16:07

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by CrazY. (Post 2560265)
The admin can dare change the model in the middle of the game, what's up? Will it advance what you alter the order of execution? If you load the path from a file, the admin will be required to restart the server, so to speak.

exactly

HamletEagle 11-13-2017 16:35

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by CrazY. (Post 2560265)
The admin can dare change the model in the middle of the game, what's up? Will it advance what you alter the order of execution? If you load the path from a file, the admin will be required to restart the server, so to speak.

I don't understand anything.

D3XT3R 11-14-2017 01:34

Re: Make plugin_prechase called after plugin_cfg
 
Quote:

Originally Posted by HamletEagle (Post 2560288)
I don't understand anything.

I will explain what happent :)

First im maked a plugin Admin models but ther is to mutch admin models, so i added new feature is changing model by cvar but ther is bug cvars change only from sma not from amxx.cfg or something that i wanted to make plugin_prechase call after plugin_cfg not before it so i now stile searching a way if Klippy way by exec the cfg fille of admins model is the only way so making it by ini fille would be more better to add it intro my post
https://forums.alliedmods.net/showthread.php?t=302473

KiLLeR. 11-14-2017 05:32

Re: Make plugin_prechase called after plugin_cfg
 
or precache all needed models and change them by cvar at any time you wish.


All times are GMT -4. The time now is 15:45.

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