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

Some questions about source pawn.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hyper Nova
BANNED
Join Date: May 2012
Old 05-15-2012 , 08:10   Some questions about source pawn.
Reply With Quote #1

Hi

I have some questions about pawn.

_____________________________________________ _______________
#1
First, i want to know something about include files.

I have .sma .vinc and two .sinc files
Inside of .sma :
PHP Code:
#include "file1.sinc"
#include "file2.sinc"

public plugin_init()  
{  
    
register_clcmd"say t0""t1_clcmd" )
    
register_clcmd"say t1""t2_clcmd" )
}  

public 
t1_clcmd(id)
{
    
gvar[id] = 3
    call_test
(id7)
    
client_print(0print_chat"varriable value: %d"gvar2[id])

}

public 
t2_clcmd(id)
{
    
gvar[id] = 1
    call_test2
(id1)
    
client_print(0print_chat"varriable value: %d"gvar2[id])


Inside of file1.sinc :
PHP Code:
#include "file1.vinc"

call_test(idvalue)
{
    
gvar2[id] = value
    gvar
[id] += 2
    gvar2
[id] += gvar[id]
    
client_print(0print_chat"file1 called")

Inside of file2.sinc :
PHP Code:
#include "file1.vinc"

call_test2(idvalue)
{
    
gvar2[id] = value
    gvar
[id] += 6
    gvar2
[id] += gvar[id]
    
client_print(0print_chat"file1 called")

Inside of file1.vinc :
PHP Code:
#include "include/amxmodx.inc"
#include "include/amxmisc.inc"

new gvar2[33], gvar[33

the problem is that if file1.sinc and file2.sinc include file1.vinc then gvar2 and gvar will be defined twice.

it will couse the error : sombol already defined "gvar" ( and gvar2 )
what i want to know is how to make include what do not couse that error.

i need to use those variables in all inc files ( and in sma ofcourse )



I have one big script inside of .sma
in xinc files are small functions and in vinc are all variables what my sma and xinc file will use.

it is for that example in sma i have

PHP Code:
public server_frame()
{
     if ( 
g_myvar )
         
call_myfunc


and in example my_func.f_inc
this function just count calling and when calls count is like i want will set myvar to 0 so it will not call myfunc anymore, because function is done

PHP Code:
public call_myfunc()
{
    if ( 
gCcount 20 )
         
g_myvar 0
    
else
        
gCcount++


i have very big sma and i just want to make all functions in parts.
But the functions mayby use variables what ohter functions also use, so thats way i need to know it.


to making native ( or something like that ) for set variable value is just too much, there are soo many variables what i have done.

anyway there must be a way how to do it.
I would be very grateful if i can get a solution from here!


_____________________________________________ _______________
#2
Now there come question about amxmodx and about goldsource engine.

I have made model ( water model ), there are 81 bone.
What i want to do now is controll these bone position.

I want to make water animation, but i can not make it inside model.
In my system there are wind and i just need my own way to controll bones in script ( like wind want )
i have search codes and things 2 week now and i did not found it, i need help.


_____________________________________________ _______________
#3

how that thing work?
PHP Code:
if ( myvar 10 
i know that this do but how it work in computer?
whether computer do one check for that or more than just one check ( in this case mayby 10 time check )?

basically i wanna know how computer understand this.


_____________________________________________ _______________
#4

how this will work?
PHP Code:

switch (myvar)
{
    case 
1
    {
              
// computer now know that myvar is 1
        
}
    case 
2
    {
              
// computer now know that myvar is 2
        
}
        ... 
if computer find out that myvar is example 1 then computer will skip ohter cases?
I mean if i have 50 case in function and if computer know that myvar is 1 and computer must take case 1 then ohter cases will increase cpu or not?

it is main thing what i want to know.


if myvar is example 4 how to computer take it?

whether computer check 1,2,3 too or it will just take 4 and computer no need to check here something more?


is this

PHP Code:
switch (myvar)
{
    case 
1
    {
              
// computer now know that myvar is 1
        
}
    case 
2
    {
              
// computer now know that myvar is 2
        
}
        ... 
same as

PHP Code:
if ( myvar == )
{
              
// computer now know that myvar is 1
}
else if if ( 
myvar == )
{
              
// computer now know that myvar is 2
}
... 
?


_____________________________________________ _______________

That is all right now.
I really hope that you found the time to answer to my questions.
I will be very very grateful!

Sorry about my bad english, i hope that you will understand me.
Thanks!
Hyper Nova is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-16-2012 , 03:24   Re: Some questions about source pawn.
Reply With Quote #2

TL;DR

Pawn or Source Pawn? Which are you actually asking about. None of the code you posted is Source Pawn.

EDIT: Ok, I skimmed over it:

#1: Example:

amxmodx.inc
PHP Code:
#if defined _amxmodx_included
  #endinput
#endif
#define _amxmodx_included 
#3: Why would it be checked 10 times?????? If it's called once, it gets called once.
#4: A switch() is always more efficient than an if else if structure.

#3&4: If you want to know more then you should first read the AMX Mod X wiki. There are some explanations of why some things are more efficient than others.
__________________

Last edited by fysiks; 05-16-2012 at 03:31.
fysiks is offline
Hyper Nova
BANNED
Join Date: May 2012
Old 05-16-2012 , 05:06   Re: Some questions about source pawn.
Reply With Quote #3

thanks.

Last edited by Hyper Nova; 05-16-2012 at 11:19.
Hyper Nova is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-16-2012 , 11:27   Re: Some questions about source pawn.
Reply With Quote #4

Quote:
Originally Posted by Hyper Nova View Post
the problem is that if file1.sinc and file2.sinc include file1.vinc then gvar2 and gvar will be defined twice.

it will couse the error : sombol already defined "gvar" ( and gvar2 )
what i want to know is how to make include what do not couse that error.

i need to use those variables in all inc files ( and in sma ofcourse )
I'm gonna be honest....that was a long post and i only read a bit of it. Answer to above quoted question:
The variables are defined IN THAT CLASS ONLY and do not effect anything outside of it. You can use cheeseGraterC as a var in every single plugin on a server and it will act independently in each plugin. Variables are block specific.....for instance you can define a global (for use in all of your plugin) and use it throughout all your functions and loops and blocks.
ex:
PHP Code:
#include <amxmodx>
new g_cheeseGraterC 15    // This is a global var: usable anywhere in your plugin
public plugin_init() {
    
register_plugin("Your Mom""Eats""Vegetables")
    new 
funcVar 13            // This is a function-specific var: usable ONLY within the function
    
new varW funcVar          // This will effectively set varW as 13
}
public 
function1() {
    new 
varW g_cheeseGraterC    // This will take your global and set it to a new variable
                                                // varW can still be defined; it is separate from varW in plugin_init
    
new varK funcVar                  // This WILL NOT WORK. funcVar was NOT defined within this function's scope; thus will give you an error

I hope that helped a little.
Liverwiz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-16-2012 , 21:22   Re: Some questions about source pawn.
Reply With Quote #5

Quote:
Originally Posted by Liverwiz View Post
I'm gonna be honest....that was a long post and i only read a bit of it.
You are correct, you didn't read it. Also, Pawn doesn't have "classes," btw.
__________________
fysiks is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-16-2012 , 23:05   Re: Some questions about source pawn.
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
You are correct, you didn't read it. Also, Pawn doesn't have "classes," btw.
I got my point across, didn't i?
Class, sma, headerfile, include. Whatever you call it. Its all the same.
Liverwiz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-17-2012 , 04:32   Re: Some questions about source pawn.
Reply With Quote #7

Quote:
Originally Posted by Liverwiz View Post
Class, sma, headerfile, include. Whatever you call it. Its all the same.
No, they are not the same.

Quote:
Originally Posted by Liverwiz View Post
I got my point across, didn't i?
In the context of the actual question I have to disagree.
__________________

Last edited by fysiks; 05-17-2012 at 04:34.
fysiks is offline
Hyper Nova
BANNED
Join Date: May 2012
Old 06-28-2012 , 19:42   Re: Some questions about source pawn.
Reply With Quote #8

bump for:
Quote:
#2
Now there come question about amxmodx and about goldsource engine.

I have made model ( water model ), there are 81 bone.
What i want to do now is controll these bone position.

I want to make water animation, but i can not make it inside model.
In my system there are wind and i just need my own way to controll bones in script ( like wind want )
i have search codes and things 2 week now and i did not found it, i need help.

If i know how to do this then almost everything is possible.
I can do that cs1.6 look like a new fps game what has come out in 2010-2012.
I can controll so many things, like creating blood decal in model or create berfect water or i can even do pixel shader with some render tricks.
It is really so important, i really want to update goldsource and when i have done this then i will update source engine ; )
I already done some great things what never will be seen in ohter plugins or servers or what ever in goldsource.
and all things support client-server side.

And please, dont say it is impossible and most important dont say nothing it will make me sad.

Last edited by Hyper Nova; 06-28-2012 at 19:42.
Hyper Nova 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 13:16.


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