AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Some questions to ask :D (https://forums.alliedmods.net/showthread.php?t=92339)

--kml-- 05-14-2009 00:23

[HELP] Some questions to ask :D
 
to yamikaito : sorry about the pervious post xD
you rock :O

______________

well i wan to ask somethings


1) What is the usefull of static?

ANSWER:

fysiks
Quote:

Use static for variables when the function is called a lot (like PreThink).
Bugsy
Quote:

Using static variables
  • The function is being called very frequently.
  • If the variable requires a lot of memory allocation. Commonly used for large strings\arrays.
  • If you wish the data to remain static [stored in memory between function calls].

arkshine
Quote:

static acts like a global var but the variable is local to the function. 'new' initializes the var each time where 'static' is created one time and is kept in the memory. In a forward called very often static should be used. Actually it's useful for large array because initializing a big array means write a zero for every byte and in a callback called often the performance could be decreased drastically.
2) when i put g_ to a code does it changes it to global or just labelling and same to sz does it make it string? or just labelling.

ANSWER:

fysiks
Quote:

It's only a label. (You can look up Hungarian Notation)
Bugsy
Quote:

Pawn does not have different data types so keep that in mind; the language uses only a 4-byte data type called a cell for everything. You can tag a variable with 'Float:' or 'bool:' which tells Pawn how to handle the data stored in the cell but regardless of tagging, it is still a 4-byte cell. There is no string type; a string is only an array of cells, each cell holding a character.

Using g_ to prefix a variable is just to remind the scripter [or others looking at your code] that the variable is declared as global [is accessible throughout the script]. This will also prevent accidental use of the incorrect variable if you use the same name for a variable that is declared global and within a function. sz does not do any type of variable declaration either, it is just to signify what kind of data is stored in the variable. You may also see people tag other variables such as iValue [signifying integer] or fValue [signifying float] or bValue [signifying bool [true\false]]
3) how to make an entity move?

ANSWER

arkshine
Quote:

Playing with entity's velocity. There are a lot of examples on this forum.
Bugsy
Quote:

kml, have you read stupoks tut?

http://forums.alliedmods.net/showthread.php?t=91474
Hunter-Digital
Quote:

3. you can set the velocity if you want it to move with a certain speed... or set the origin to just teleport it there... ex:

PHP Code:

new Float:fVelocity[3]
fVelocity[2] = 100.0 // moves up
entity_set_vector(entityEV_VEC_velocityfVelocity


4)if can move how to make it move from A to B by flying?

ANSWER

Hunter-Digital
Quote:

all newly created entities fly by default, you must set movetype ( entity_set_int(ent, EV_INT_movetype, MOVETYPE_*) ) or add gravity, collisions, etc (see the values in hlsdk_const.inc), I wrote above how you can move an entity... but how to move it to a specified location... well, that'll require some calculations, I don't quite know how because I never done something like this but there are examples you can get from plugins that do such things... this for "From point A to point B" thing.... but if you want to spawn an ent at your location and

move it where you aim, see velocity_by_aim()
arkshine
Quote:

If you know both origin, you could calculated the direction ( origin2 - origin1 ), then you could use some velocity in this direction. ( direction * velocity wanted )
Bugsy
Quote:

kml, have you read stupoks tut?

http://forums.alliedmods.net/showthread.php?t=91474

5) how to make a player got FLASH red instead of glowing like nemesis zombie that is glowing red and flashing red.


arkshine
Quote:

Don't fully understand.

EDITED VERSION:


ok now u know flash light? of course u would :)
ok now i wan to put some kind of flash light around the player .
as u can c in the zombie plauge nemesis ( the nemesis is glowing red and got red flash light around him)




6) how to make an ambient sound at only some places?
like a radio at somewhere?


arkshine <<can give me an example?
Quote:

Using emit_sound(). Actually if you want to place in a know origin, use EngFunc_EmitAmbientSound from fakemeta and passing 0 as entity.
7) how to make an npc moves?

arkshine
Quote:

There are severals plugins you could take a look, like Tower Defense, there is also Bot API.
8 ) can give the hlsdk section where got the weaponbox thinking?

arkshine
Quote:

A weaponbox entity doesn't think. ( only touch ). If you do think a weaponbox entity, it will disappear. ( If I'm remember well )
arkshine

Quote:

ouh, yes when an weapon box entity thinks it disapear but i just want to know where is the part of hlsdk explains that weapons.
Quote:

weapons.cpp, line 1246 ; I doubt you understand something.

9) where can i download all FULL NATIVES?

fysiks
Quote:

If you get AMX Mod X you have them all. Look in /addons/amxmodx/scripting/includes/
arkshine
Quote:

See all the includes ( *.inc files ) in scripting/includes/ folder.
10) what is usefull of stock and uses? (please explain fully and i can understand it)

Hunter-Digital

Quote:

stocks are short versions of multiple functions working together to do something... ex (from engine_stocks.inc):
PHP Code:

                            /*  Set rendering of an entity */
stock set_rendering(indexfx=kRenderFxNoner=255g=255b=255render=kRenderNormalamount=16)
{
    
entity_set_int(index,EV_INT_renderfx,fx);
    new 
Float:RenderColor[3];
    
RenderColor[0] = float(r);
    
RenderColor[1] = float(g);
    
RenderColor[2] = float(b);
    
entity_set_vector(index,EV_VEC_rendercolor,RenderColor);
    
entity_set_int(index,EV_INT_rendermode,render);
    
entity_set_float(index,EV_FL_renderamt,float(amount));
 
    return 
1;



arkshine

Quote:

A function with the label 'stock' means that this function will not be included in the compilation if not used. You can get a good description for the usage of public/stock.
EDIT:

11) if i wan to take a whole list of player in my server what should i do?


thank you xD
+k if u help

fysiks 05-14-2009 01:04

Re: [HELP] Some questions to ask :D
 
1. Use static for variables when the function is called a lot (like PreThink).
2. It's only a label. (You can look up Hungarian Notation)
9. If you get AMX Mod X you have them all. Look in /addons/amxmodx/scripting/includes/

Hunter-Digital 05-14-2009 05:23

Re: [HELP] Some questions to ask :D
 
3. you can set the velocity if you want it to move with a certain speed... or set the origin to just teleport it there... ex:
PHP Code:

new Float:fVelocity[3]
fVelocity[2] = 100.0 // moves up
entity_set_vector(entityEV_VEC_velocityfVelocity

4. all newly created entities fly by default, you must set movetype ( entity_set_int(ent, EV_INT_movetype, MOVETYPE_*) ) or add gravity, collisions, etc (see the values in hlsdk_const.inc), I wrote above how you can move an entity... but how to move it to a specified location... well, that'll require some calculations, I don't quite know how because I never done something like this but there are examples you can get from plugins that do such things... this for "From point A to point B" thing.... but if you want to spawn an ent at your location and move it where you aim, see velocity_by_aim()

10. stocks are short versions of multiple functions working together to do something... ex (from engine_stocks.inc):
PHP Code:

/*  Set rendering of an entity */
stock set_rendering(indexfx=kRenderFxNoner=255g=255b=255render=kRenderNormalamount=16)
{
    
entity_set_int(index,EV_INT_renderfx,fx);
    new 
Float:RenderColor[3];
    
RenderColor[0] = float(r);
    
RenderColor[1] = float(g);
    
RenderColor[2] = float(b);
    
entity_set_vector(index,EV_VEC_rendercolor,RenderColor);
    
entity_set_int(index,EV_INT_rendermode,render);
    
entity_set_float(index,EV_FL_renderamt,float(amount));
 
    return 
1;



--kml-- 05-14-2009 09:12

Re: [HELP] Some questions to ask :D
 
oo thx for helping xD realy help me but still i dun understand about stocks can explain more ? :mrgreen:

ooooo hmmm can just make like it float and fly to an origin?
like from AAA AAA AAA to BBB BBB BBB? and also can make it multiple?
like timing? like 1 second from A TO B another 1 second from B TO C?

--kml-- 05-14-2009 10:25

Re: [HELP] Some questions to ask :D
 
will this work?


Quote:

travomail at gmail dot com
Dec-31-07 16:39:22 if you have an entity that you want to travel to a origin you may use (note: this will not teleport the entity, but it was walk/travel to the origin)

stock send_ent_to_origin(ent,start_origin[3],end_origin[3],speed)
{
new diff[3];
for (new b=0;b
can some 1 clean this code? xD if it is ok then can make this as a plugin :O

Bugsy 05-14-2009 10:32

Re: [HELP] Some questions to ask :D
 
Quote:

Originally Posted by --kml-- (Post 827131)
1) What is the usefull of static?
2) when i put g_ to a code does it changes it to global or just labelling and same to sz does it make it string? or just labelling.

1. Using static variables
  • The function is being called very frequently.
  • If the variable requires a lot of memory allocation. Commonly used for large strings\arrays.
  • If you wish the data to remain static [stored in memory between function calls].

2. Pawn does not have different data types so keep that in mind; the language uses only a 4-byte data type called a cell for everything. You can tag a variable with 'Float:' or 'bool:' which tells Pawn how to handle the data stored in the cell but regardless of tagging, it is still a 4-byte cell. There is no string type; a string is only an array of cells, each cell holding a character.

Using g_ to prefix a variable is just to remind the scripter [or others looking at your code] that the variable is declared as global [is accessible throughout the script]. This will also prevent accidental use of the incorrect variable if you use the same name for a variable that is declared global and within a function. sz does not do any type of variable declaration either, it is just to signify what kind of data is stored in the variable. You may also see people tag other variables such as iValue [signifying integer] or fValue [signifying float] or bValue [signifying bool [true\false]]

Arkshine 05-14-2009 10:38

Re: [HELP] Some questions to ask :D
 
1. static acts like a global var but the variable is local to the function. 'new' initializes the var each time where 'static' is created one time and is kept in the memory. In a forward called very often static should be used. Actually it's useful for large array because initializing a big array means write a zero for every byte and in a callback called often the performance could be decreased drastically.

2. It's just a label. g as 'global'. You should read this tuto about the Code Styling.

3. Playing with entity's velocity. There are a lot of examples on this forum.

4. If you know both origin, you could calculated the direction ( origin2 - origin1 ), then you could use some velocity in this direction. ( direction * velocity wanted )

5. Don't fully understand.

6. Using emit_sound(). Actually if you want to place in a know origin, use EngFunc_EmitAmbientSound from fakemeta and passing 0 as entity.

7. There are severals plugins you could take a look, like Tower Defense, there is also Bot API.

8. A weaponbox entity doesn't think. ( only touch ). If you do think a weaponbox entity, it will disappear. ( If I'm remember well )

9. See all the includes ( *.inc files ) in scripting/includes/ folder.

10. A function with the label 'stock' means that this function will not be included in the compilation if not used. You can get a good description for the usage of public/stock.

--kml-- 05-14-2009 10:45

Re: [HELP] Some questions to ask :D
 
oo thx for replying but there is still somethins i dun understand

3( please explain more in details O.O)
4(also please explain more in details and with some codes :O)

and as for 5 i want to make around the player got light . as u know in zombie plauge mod the nemesis got red light beside them and also glowing. i wan to know how to make the red light beside people.

8. ouh, yes when an weapon box entity thinks it disapear but i just want to know where is the part of hlsdk explains that :mrgreen:
9. so if it is not use the whole code in the stock is not used?

Bugsy 05-14-2009 10:47

Re: [HELP] Some questions to ask :D
 
kml, have you read stupoks tut?

http://forums.alliedmods.net/showthread.php?t=91474

Arkshine 05-14-2009 10:54

Re: [HELP] Some questions to ask :D
 
Quote:

ouh, yes when an weapon box entity thinks it disapear but i just want to know where is the part of hlsdk explains that
weapons.cpp, line 1246 ; I doubt you understand something.


All times are GMT -4. The time now is 01:28.

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