AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   model (https://forums.alliedmods.net/showthread.php?t=94125)

Atspulgs 06-06-2009 16:58

model
 
Is it possible to make (in this case shero) with model that will be defined trough cvar instead of being hardcoded?

TitANious 06-06-2009 17:08

Re: model
 
#define MODEL_NAME "models/player/model_name"

Atspulgs 06-06-2009 17:14

Re: model
 
wouldnt that make it hardcoded?

i want i to be compiled only once, but yet able to use different models by just changing the location and file name in cvars.

TitANious 06-06-2009 17:19

Re: model
 
I think you can do it with a cvar?

hleV 06-06-2009 18:00

Re: model
 
Quote:

Originally Posted by TitANious (Post 843259)
#define MODEL_NAME "models/player/model_name"

#define for a string isn't good idea.
Code:
new ModelPathCVar;   public plugin_init()         ModelPathCVar = register_cvar("amx_model", "models/model.mdl");   public SomeFunction() {         new ModelPath[64];         get_pcvar_string(ModelPathCVar, ModelPath, 63);           // ModelPath now contains the string that is in CVar }

Atspulgs 06-07-2009 17:56

Re: model
 
yeah i tried that and it did compile fine but my server wouldn't accept it, tells its a bad string or something, so i figure it wants that string is a constant. So what i need is a way of getting the cvar and then declaring the model variable as a constant. I tried something like that but compiler wouldnt let me do that.

As of that i have come to a question, can i pass that variable down to other methods without making it global?
Please give me an example as well as explanation.

In java it would look something like this.

Code:

class someclass
{
        public static void main(String[] args)
        {
                int someInt = 1;
                someMethod(someInt);
        }
       
        static void someMethod(int theInt)
        {
                System.out.println(theInt);
        }
}

So can i do something similar and how would i be doing it in this particular scenario?

TitANious 06-07-2009 18:14

Re: model
 
You can
PHP Code:

new const MODEL_NAME [33] []
{
    
"models/player/model_name/"



Atspulgs 06-07-2009 18:28

Re: model
 
Ok how exactly would that work?
declaring a constant array named Model_Name then there is unexplained [] and then in curly braces you have the string it self.

Wouldnt that be the same as
new const MODEL_NAME [33] = {"models/player....."}
?


All times are GMT -4. The time now is 13:55.

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