AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set_cvar_num on plugin hook (https://forums.alliedmods.net/showthread.php?t=236891)

'-_-'<3zok<3'-_-' 03-13-2014 19:51

set_cvar_num on plugin hook
 
Well, I'm fresh and got no clue these things yet, where do I find all the hamsandwich events, documentation? Like ham_spawn and others?

Well my coding related issue is that I want to set some server cvars via my plugin as soon as the plugin loads, anyhelp and advises are appreciated!

set_cvar_num

wickedd 03-13-2014 20:28

Re: set_cvar_num on plugin hook
 
Read this

'-_-'<3zok<3'-_-' 03-13-2014 20:46

Re: set_cvar_num on plugin hook
 
Quote:

Originally Posted by wickedd (Post 2111123)

Thank you so much, already got going with a bunch of new features, is there any way to enforce server settings on start? And would it be a bad idea to place it on a map change event?

Someone help me, I have no clue on how to setup arguments for these events, tried a bunch of different things but I really dont know what it wants from me,
PHP Code:

public plugin_init() {
    
register_plugin(PLUGINVERSION"zok_Halsen")
    
RegisterHam(Ham_Spawn"player""spawn"true//<-- works! Always has, always will.
    
RegisterHam(Ham_Player_Duck"action1"//They both call for the same
    
RegisterHam(Ham_IsSneaking"action1")   //script, these dont work.
    
RegisterHam(Ham_TakeDamage"action2"idinflictoridattackerFloat:damagedamagebits//neither does this, errors when trying to compile, shown below.


Error:
Code:

// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(19) : error 088: number of arguments does not match definition
// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(20) : error 088: number of arguments does not match definition
// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(21) : error 017: undefined symbol "idinflictor"
// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(21) : error 017: undefined symbol "idattacker"
// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(21) : warning 221: labelname "Float" shadows tag name
// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(21) : error 017: undefined symbol "damage"


fysiks 03-14-2014 01:19

Re: set_cvar_num on plugin hook
 
Quote:

Originally Posted by '-_-'<3zok<3'-_-' (Post 2111128)
Thank you so much, already got going with a bunch of new features, is there any way to enforce server settings on start?

server.cfg

Quote:

Originally Posted by '-_-'<3zok<3'-_-' (Post 2111128)
And would it be a bad idea to place it on a map change event?

What are you trying to change? Explain in detail what you are trying to do.

Quote:

Originally Posted by '-_-'<3zok<3'-_-' (Post 2111128)
Someone help me, I have no clue on how to setup arguments for these events, tried a bunch of different things but I really dont know what it wants from me,
PHP Code:

public plugin_init() {
    
register_plugin(PLUGINVERSION"zok_Halsen")
    
RegisterHam(Ham_Spawn"player""spawn"true//<-- works! Always has, always will.
    
RegisterHam(Ham_Player_Duck"action1"//They both call for the same
    
RegisterHam(Ham_IsSneaking"action1")   //script, these dont work.
    
RegisterHam(Ham_TakeDamage"action2"idinflictoridattackerFloat:damagedamagebits//neither does this, errors when trying to compile, shown below.


Error:
Code:

// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(19) : error 088: number of arguments does not match definition
// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(20) : error 088: number of arguments does not match definition
// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(21) : error 017: undefined symbol "idinflictor"
// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(21) : error 017: undefined symbol "idattacker"
// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(21) : warning 221: labelname "Float" shadows tag name
// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(21) : error 017: undefined symbol "damage"


You can find the arguments required for a forward from the link presented to you or by looking in include/ham_cosnt.inc. It is denoted as "Forward params:"

'-_-'<3zok<3'-_-' 03-14-2014 05:16

Re: set_cvar_num on plugin hook
 
Quote:

Originally Posted by fysiks (Post 2111180)
server.cfg



What are you trying to change? Explain in detail what you are trying to do.



You can find the arguments required for a forward from the link presented to you or by looking in include/ham_cosnt.inc. It is denoted as "Forward params:"

As for using server.cfg, thats a no go since I want to make a mod witch configures it self on plugin load, I know sourcemod has OnPluginLoad() but is there really no alternative for doing it on amxmodx?

As for the sentence with mapchanging, its all about setting the cvars(example, sv_airacceleration), if theres no way to do it on load via an event I'll have to try something that happens every round.

Reading the forward params tells me a lot but I have no idea on how to get the idattacker and the others, I very green on this, its my absolute first real project and a snippet would be lovely, when it comes to what I'm trying to do, when a player is attacked by a gun(any gun), holds shift or holds duck, hes speed decreases, increases or whatever, I might even have the wrong impression of how they're supposed to be working.

Just to make it clear, I allready wrote all the code for the actions, it gives no errors and should work just as I intended, I'm just trying to make them execute when player is shot, walks or ducks.

I've fixed the
PHP Code:

RegisterHam(Ham_TakeDamage"action2""player"

by adding this to the fuction,
PHP Code:

public action2(victiminflictorattackerFloat:fDamagebitDamage

Now it seems that my only presisting issue is with the
PHP Code:

RegisterHam(Ham_Player_Duck"action"
RegisterHam(Ham_IsSneaking"action"

Error:
Code:

// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(19) : error 088: number
of arguments does not match definition
// C:\hlds\cstrike\addons\amxmodx\scripting\huanmod.sma(20) : error 088: number
of arguments does not match definition


Black Rose 03-14-2014 14:01

Re: set_cvar_num on plugin hook
 
The error is written in english.
Also, if you search for that error you would probably find about 10000000000 matches.

'-_-'<3zok<3'-_-' 03-15-2014 00:42

Re: set_cvar_num on plugin hook
 
Quote:

Originally Posted by Black Rose (Post 2111433)
The error is written in english.
Also, if you search for that error you would probably find about 10000000000 matches.

As if you read my posts in this thread you would notice that I'm completly new to making plugins, you cannot know what you havnt learned, even if it might seem to be easy for you, you must be able to comprehend the fact that it makes absolutely no sense at all to me, of course it does make some sense but I have no experience with these error messages or/and how to fix them. Obviously I've already tried finding someone with a simular problem, but there are no threads containing the hams(with the same errors) that I'm trying to use.

fysiks 03-15-2014 03:03

Re: set_cvar_num on plugin hook
 
plugin_init() is run when the plugin is initiated. Cvars should be set in plugin_cfg().

If you are having issues using Ham forwards, you should look at existing working plugins that use the functions you are interested in. You are using RegisterHam() incorrectly. If you look at the include for Ham (hamsandwich.inc), you will see that the second argument is the EntityClass, not the function you want called (which is called the "callback").

Arkshine 03-15-2014 03:05

Re: set_cvar_num on plugin hook
 
Look, you have been told to look in Ham includes files.

You see you have error using RegisterHam() and compiler tells you the number of arguments doesn't match definition.

So, first thing you should do is : how this function RegisterHam should be defined.

You check hamsandwich.inc and you see :

Code:

    56 /**
    57  * Hooks the virtual table for the specified entity class.
    58  * An example would be: RegisterHam(Ham_TakeDamage, "player", "player_hurt");
    59  * Look at the Ham enum for parameter lists.
    60  *
    61  * @param function                The function to hook.
    62  * @param EntityClass        The entity classname to hook.
    63  * @param callback                The forward to call.
    64  * @param post                        Whether or not to forward this in post.
    65  * @return                                Returns a handle to the forward.  Use EnableHamForward/DisableHamForward to toggle the forward on or off.
    66  */
    67 native HamHook:RegisterHam(Ham:function, const EntityClass[], const Callback[], Post=0);


'-_-'<3zok<3'-_-' 03-15-2014 15:15

Re: set_cvar_num on plugin hook
 
fysiks, Thank you! Just what I was looking for, still struggling with some of it but nothing I wont resolve myself.
Arkshine, "Is Work! hurray", I've been using the docs on the Amxmodx site, figured out the either are outdated or I might just simply be reading them incorrect, english isnt my first language but this you all might already have figured out. Thanks for the help!


All times are GMT -4. The time now is 05:54.

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