Raised This Month: $ Target: $400
 0% 

Questions about scripting and HL engine


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OlikA
Junior Member
Join Date: Aug 2009
Location: Caldeum
Old 08-18-2009 , 16:30   Questions about scripting and HL engine
Reply With Quote #1

Hi , I'm new to this plugin making thing . 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) .

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 () 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.

Last edited by OlikA; 08-18-2009 at 17:31.
OlikA is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 08-18-2009 , 16:32   Re: Questions about scripting and HL engine
Reply With Quote #2

#1 http://wiki.amxmodx.org/Optimizing_P...X_Scripting%29
__________________
Bad_Bud is offline
OlikA
Junior Member
Join Date: Aug 2009
Location: Caldeum
Old 08-18-2009 , 16:39   Re: Questions about scripting and HL engine
Reply With Quote #3

Quote:
Originally Posted by Bad_Bud View Post
I'm totally blind. Thank you for the fast response and for the link! [+karma]

Last edited by OlikA; 08-18-2009 at 16:49.
OlikA is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-18-2009 , 16:48   Re: Questions about scripting and HL engine
Reply With Quote #4

Quote:
Originally Posted by OlikA View Post
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.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-18-2009 , 16:38   Re: Questions about scripting and HL engine
Reply With Quote #5

#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[] )
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 08-18-2009 at 16:47.
ot_207 is offline
OlikA
Junior Member
Join Date: Aug 2009
Location: Caldeum
Old 08-18-2009 , 16:47   Re: Questions about scripting and HL engine
Reply With Quote #6

Quote:
Originally Posted by ot_207 View Post
#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.
OlikA is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-18-2009 , 16:50   Re: Questions about scripting and HL engine
Reply With Quote #7

Quote:
Originally Posted by OlikA View Post
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.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 08-18-2009 at 16:54.
ot_207 is offline
OlikA
Junior Member
Join Date: Aug 2009
Location: Caldeum
Old 08-18-2009 , 17:08   Re: Questions about scripting and HL engine
Reply With Quote #8

Quote:
Originally Posted by ot_207 View Post
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 View Post

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.
Attached Files
File Type: sma Get Plugin or Get Source (mindcontrol.sma - 536 views - 2.2 KB)
OlikA is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-18-2009 , 17:27   Re: Questions about scripting and HL engine
Reply With Quote #9

Quote:
Originally Posted by OlikA View Post
I thought that there is no significant difference between the two code-part. I will try this tomorrow.
There is a significant difference that is why I recommend using engine module for entity property manipulation.

Quote:
Originally Posted by OlikA View Post
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.
Edit them, use cmd_target function. And be careful server_frame uses a lot of resources!
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
OlikA
Junior Member
Join Date: Aug 2009
Location: Caldeum
Old 08-18-2009 , 17:00   Re: Questions about scripting and HL engine
Reply With Quote #10

Quote:
Originally Posted by ot_207 View Post
#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]
OlikA 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 15:06.


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