AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Questions about scripting and HL engine (https://forums.alliedmods.net/showthread.php?t=100856)

OlikA 08-18-2009 16:30

Questions about scripting and HL engine
 
Hi :wink:, I'm new to this plugin making thing :cry:. I started it maybe a week ago, learned from the funcwiki, the amxmodx doc and other plugins source code [and hlsdk for possibilities] . However I have some questions that i couldn't find answer by searching the forum (maybe lack of keywords) :rtfm:.

1 - Optimization

I couldn't find the "basics" of Pawn language regarding the optimizing. I read that "very-frequent" (0.01s) tasks should be redone in server_frame; saw from source codes that i should use constants for regular expressions etc. But i would like to know more optimization. For example, should I use only one public function that can do two or more thing (IF/switch/etc) or write more public function and each will deal with that specific/unique event. Or the "perfect" number of used modules, what module-functions should I use for fast performance etc etc etc.
Response by Bad_Bud: http://wiki.amxmodx.org/Optimizing_Plugins_(AMX_Mod_X_Scripting)

2 - Pev_button
I made a little plugin, that allows me to control an entity with pev(id1, pev_origin, origin1) and set_pev(id2, pev_origin, origin1). And I tried to do a "real" control by pev_button, but pev(id1, pev_button, button1) set_pev(id2, pev_button, button1) doesn't seems to work. If you want, I'll post the code (the question is about the pev_button, not that what is the problem with my plugin).
Here is the source code: https://forums.alliedmods.net/showpo...2&postcount=10

3 - Detailed informations about the constants
I couldn't find anywhere that how should I get the name of the "being spectated" player, later I found it in the specinfo plugin. But why is not there in the *.inc files (I mean the purpose of that specific "value")? So is there any list with all of these constants? Even the HLSDK [not full] has these informations placed recklessly in random header files.

4 - Short and easy questions

A: Is there a specific user message or an event that "fires" when someone fires/attacks/is about to deal damage? I would like to get that very moment, when someone is about to give a shot (:oops:) or slashing with knife [and maybe using a stationary gun]. I tried the AmmoX event, but it doesn't works.
Response by ot_207: https://forums.alliedmods.net/showpo...92&postcount=9

B: Can I "disable" specific events/messages/functions? I read that there's a function that allows to "stop" it, or at least my plugin has the right to do the first steps and then the real event/message/function will be parsed/run, but I can't find it [lack of keywords].
Response by ot_207: https://forums.alliedmods.net/showpo...61&postcount=3 (end of post)

This was my first post. Sorry for making it rather long. I just simply have many ideas that I would like to realize. I hope i didn't asked anything dumb or so noobish.

Bad_Bud 08-18-2009 16:32

Re: Questions about scripting and HL engine
 
#1 http://wiki.amxmodx.org/Optimizing_P...X_Scripting%29

ot_207 08-18-2009 16:38

Re: Questions about scripting and HL engine
 
#2 pev_button works this way. To get it.

PHP Code:

new button pev(idpev_button

To set it.
PHP Code:

new button IN_ATTACK IN_BACK IN_ALT
set_pev
(idpev_buttonbutton

#3 Well there isn't a full list but you can do 2 things with this. You can check the header [.inc] files in the folder: "amxmodx/scripting/include/"
You can check this out, hasn't all of them but most could come in handy -> http://www.amxmodx.org/funcwiki.php
For the being spectated you should check out that plugin to understand the method.

#4
A. Yes there is, you can use 2 methods. It really depends on what you want to do.
One is to use the Hamsandwich module, and use or the Ham_TraceAttack or Ham_TakeDamage forward.
Or you can use Damage event.
PHP Code:

register_event("Damage","Event_Damage","b"

And get the details of it.
For the damage event more can be found here -> http://wiki.amxmodx.org/Half-Life_1_Game_Events
For the Hamsandwich module you should check ham_const.inc

B. Yes, there is a function although I would not recommend doing it on important messages, SVC_TEMPENTITY should be good but not all of them.
register_message ( iMsgId, szFunction[] )

OlikA 08-18-2009 16:39

Re: Questions about scripting and HL engine
 
Quote:

Originally Posted by Bad_Bud (Post 904754)

I'm totally blind. Thank you for the fast response and for the link! [+karma]

OlikA 08-18-2009 16:47

Re: Questions about scripting and HL engine
 
Quote:

Originally Posted by ot_207 (Post 904761)
#2 pev_button works this way. To get it.

PHP Code:

new button pev(idpev_button

PHP Code:

new button IN_ATTACK IN_BACK IN_ALT
set_pev
(idpev_buttonbutton

Will come with an edit to the other 2.

I read that I have to use bitwise operators and get the actual buttons pressed like
PHP Code:

pev(idpev_buttonbutton)
if (
button IN_JUMP

But I want to make a specific plugin that allows me to control another player. No abuse, I'm about to make a public HNS server with bunny hop courses (blockmaker) and it would be great if I could help out newbies to reach what they want. So if they want help, I could easily control them to the right place. I tried this code:

PHP Code:

       pev(idpev_buttonButtons)
        
pev(idpev_anglesAngles)
        
set_pev(Slavepev_buttonButtons)
        
set_pev(Slavepev_anglesAngles

And on the dedicated server, I saw that when I press +forward or simply looking left, the Slave is also was about to go forward and look left but it was only a "visual" change, the Slave didn't saw any change. Give me some minutes and I will post the code.

ot_207 08-18-2009 16:48

Re: Questions about scripting and HL engine
 
Quote:

Originally Posted by OlikA (Post 904762)
I'm totally blind. Thank you for the fast response and for the link!

If that doesn't help try reading the code of other plugins, if you can understand them then you should try writing your own.

ot_207 08-18-2009 16:50

Re: Questions about scripting and HL engine
 
Quote:

Originally Posted by OlikA (Post 904766)
I read that I have to use bitwise operators and get the actual buttons pressed like
PHP Code:

pev(idpev_buttonbutton)
if (
button IN_JUMP

But I want to make a specific plugin that allows me to control another player. No abuse, I'm about to make a public HNS server with bunny hop courses (blockmaker) and it would be great if I could help out newbies to reach what they want. So if they want help, I could easily control them to the right place. I tried this code:

PHP Code:

       pev(idpev_buttonButtons)
        
pev(idpev_anglesAngles)
        
set_pev(Slavepev_buttonButtons)
        
set_pev(Slavepev_anglesAngles

And on the dedicated server, I saw that when I press +forward or simply looking left, the Slave is also was about to go forward and look left but it was only a "visual" change, the Slave didn't saw any change. Give me some minutes and I will post the code.


PHP Code:

pev(idpev_buttonbutton)
if (
button IN_JUMP

it is used this way ->

PHP Code:

button pev(idpev_button)
if (
button IN_JUMP

And yes you need to use the bitwise operators! A good idea is to check all the topics in this thread -> http://forums.alliedmods.net/forumdisplay.php?f=83


PHP Code:

       pev(idpev_buttonButtons)
        
pev(idpev_anglesAngles)
        
set_pev(Slavepev_buttonButtons)
        
set_pev(Slavepev_anglesAngles

For this you should correct the button ones with what I have said above.
And for angles it is correct. Angles must be a float vector.
PHP Code:

    new buttonsFloat:angles[3]
    
buttons pev(idpev_button)
    
pev(idpev_anglesangles)
    
set_pev(Slavepev_buttonbuttons)
    
set_pev(Slavepev_anglesangles

Edit:
I suggest using engine at least when you are a beginner at scripting because it is better when we talk about user friendly access.

OlikA 08-18-2009 17:00

Re: Questions about scripting and HL engine
 
Quote:

Originally Posted by ot_207 (Post 904761)
#4
A. Yes there is, you can use 2 methods. It really depends on what you want to do.
One is to use the Hamsandwich module, and use or the Ham_TraceAttack or Ham_TakeDamage forward.
Or you can use Damage event.
PHP Code:

register_event("Damage","Event_Damage","b"

And get the details of it.
For the damage event more can be found here -> http://wiki.amxmodx.org/Half-Life_1_Game_Events
For the Hamsandwich module you should check ham_const.inc

Question B. Yes, there is a function although I would not recommend doing it on important messages, SVC_TEMPENTITY should be good but not all of them.
register_message ( iMsgId, szFunction[] )

For Question A: I want to do things BEFORE someone is about to shoot a bullet or slash the knife etc. And I want to "alter" or at least stop functions to be runned (I'm bad at english). For example (this isn't I want to do) kick a player if he wants to shoot a bullet and spawn a chicken for it's last origin. This should be my favourite plugin haha.

B: Yes, I think this is I wanted.

Overall: [+karma]

ot_207 08-18-2009 17:00

Re: Questions about scripting and HL engine
 
Quote:

Originally Posted by OlikA (Post 904790)
For Question A: I want to do things BEFORE someone is about to shoot a bullet or slash the knife etc. And I want to "alter" or at least stop functions to be runned (I'm bad at english). For example (this isn't I want to do) kick a player if he wants to shoot a bullet and spawn a chicken for it's last origin. This should be my favourite plugin haha.

B: Yes, I think this is I wanted.

Overall: [+karma]

Then use the forwards from hansandwich they are the ones that allow you to alter everything!
-> Ham_TraceAttack, Ham_TakeDamage, Ham_Weapon_PrimaryAttack, Ham_Weapon_SecondaryAttack

OlikA 08-18-2009 17:08

Re: Questions about scripting and HL engine
 
1 Attachment(s)
Quote:

Originally Posted by ot_207 (Post 904772)
PHP Code:

pev(idpev_buttonbutton)
if (
button IN_JUMP

it is used this way ->

PHP Code:

button pev(idpev_button)
if (
button IN_JUMP


I thought that there is no significant difference between the two code-part. I will try this tomorrow.

Quote:

Originally Posted by ot_207 (Post 904772)

PHP Code:

       pev(idpev_buttonButtons)
        
pev(idpev_anglesAngles)
        
set_pev(Slavepev_buttonButtons)
        
set_pev(Slavepev_anglesAngles

For this you should correct the button ones with what I have said above.
And for angles it is correct. Angles must be a float vector.
PHP Code:

    new buttonsFloat:angles[3]
    
buttons pev(idpev_button)
    
pev(idpev_anglesangles)
    
set_pev(Slavepev_buttonbuttons)
    
set_pev(Slavepev_anglesangles


I attached my (not updated since the first post) plugin's source code.
I will try this tomorrow also. Some comments about the plugin: I used id 1 and id 2 for simplicity and fast-debug. I will use iuser2 and "if user is an admin" and other things. Also the "move" thing is works. And I think I will try it to move to the server_frame and hope for no netchan errors and other.


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

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