Raised This Month: $ Target: $400
 0% 

set_cvar_num on plugin hook


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
'-_-'<3zok<3'-_-'
Senior Member
Join Date: Feb 2010
Location: Norway
Old 03-13-2014 , 19:51   set_cvar_num on plugin hook
Reply With Quote #1

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
'-_-'<3zok<3'-_-' is offline
Send a message via Skype™ to '-_-'<3zok<3'-_-'
wickedd
Veteran Member
Join Date: Nov 2009
Old 03-13-2014 , 20:28   Re: set_cvar_num on plugin hook
Reply With Quote #2

Read this
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
'-_-'<3zok<3'-_-'
Senior Member
Join Date: Feb 2010
Location: Norway
Old 03-13-2014 , 20:46   Re: set_cvar_num on plugin hook
Reply With Quote #3

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

Last edited by '-_-'<3zok<3'-_-'; 03-13-2014 at 22:08. Reason: gammar, added codesnippet.
'-_-'<3zok<3'-_-' is offline
Send a message via Skype™ to '-_-'<3zok<3'-_-'
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-14-2014 , 01:19   Re: set_cvar_num on plugin hook
Reply With Quote #4

Quote:
Originally Posted by '-_-'<3zok<3'-_-' View Post
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'-_-' View Post
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'-_-' View Post
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:"
__________________
fysiks is offline
'-_-'<3zok<3'-_-'
Senior Member
Join Date: Feb 2010
Location: Norway
Old 03-14-2014 , 05:16   Re: set_cvar_num on plugin hook
Reply With Quote #5

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

Last edited by '-_-'<3zok<3'-_-'; 03-14-2014 at 13:05.
'-_-'<3zok<3'-_-' is offline
Send a message via Skype™ to '-_-'<3zok<3'-_-'
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-14-2014 , 14:01   Re: set_cvar_num on plugin hook
Reply With Quote #6

The error is written in english.
Also, if you search for that error you would probably find about 10000000000 matches.
__________________
Black Rose is offline
'-_-'<3zok<3'-_-'
Senior Member
Join Date: Feb 2010
Location: Norway
Old 03-15-2014 , 00:42   Re: set_cvar_num on plugin hook
Reply With Quote #7

Quote:
Originally Posted by Black Rose View Post
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.
'-_-'<3zok<3'-_-' is offline
Send a message via Skype™ to '-_-'<3zok<3'-_-'
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-15-2014 , 03:03   Re: set_cvar_num on plugin hook
Reply With Quote #8

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").
__________________
fysiks is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-15-2014 , 03:05   Re: set_cvar_num on plugin hook
Reply With Quote #9

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);
__________________
Arkshine is offline
'-_-'<3zok<3'-_-'
Senior Member
Join Date: Feb 2010
Location: Norway
Old 03-15-2014 , 15:15   Re: set_cvar_num on plugin hook
Reply With Quote #10

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!
'-_-'<3zok<3'-_-' is offline
Send a message via Skype™ to '-_-'<3zok<3'-_-'
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 05:54.


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