Raised This Month: $ Target: $400
 0% 

Library - Sentry Gun


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
F0RCE
Senior Member
Join Date: Oct 2010
Old 10-25-2011 , 05:53   Library - Sentry Gun
Reply With Quote #1

Hello everyone ! I'm using Diablix library of Cannon that is being controlled by person!

It is a little bugged[Maybe more than little] , but the author isn't interested anymore in this project[Or maybe he don't know how to fix this :>]

PHP Code:
#include <amxmodx>
 
#include "dzialko.inl"
 
#define VERSION "0.1"
 
public plugin_init() {
        
register_plugin("Test z dzialkiem"VERSION"Diablix")
        
        
register_clcmd("say /test""cmdTest");
}
 
public 
cmdTest(id){
        
diablix_create_cannon(id100301.0);

This will create Cannon with 100hp [Yea working] Dealing 30dmg [Working too]
Allowing You to shoot each one second [Working only with 1.0 value , 0.9 value is giving crazy effect [Totally fast shoot]

So the problems are :


1 #
PHP Code:
L 10/21/2011 02:25:50: [HAMSANDWICHFailed to retrieve classtype for "cl_dzialko"hook for "think_Dzialko" not active.
L 10/21/2011 02:25:50: [AMXXDisplaying debug trace (plugin "dzialko.amxx")
L 10/21/2011 02:25:50: [AMXXRun time error 10native error (native "RegisterHam")
L 10/21/2011 02:25:50: [AMXX] [0dzialko.sma::plugin_init (line 64
The error each map change. That appear only ONCE each map!
[But still annoying]

2 # Even after You die - While You are still pressing Left Mouse Button , the cannon is shooting ;D

3 # Even If Your Cannon is destroyed. On next round in the place where the cannon was, You can press E and attack like with cannon[But Cannon was destroyed]
Ehh don't know If my description of this problem is normal.

I wanted to say.
a) Your Cannon is destroyed
b) In the place where it standed, You still can press E and attack with cannon ;d

4 # The cannon is not deleted after round end.

If someone could fix this, it could be really usefull for a lot of servers!
It is library so implementing this in any plugin is 30sec of work.

I'm uploading sma below.
The sma on top of this topic is just test plugin.

Can't upload the INC files so I'm adding it here

PHP Code:
#if defined _dzialko_included
    #endinput
#endif

#define _dzialko_included

/*
* Creating cannon near player
*
* @param id            Index of player
* @param iHp            HP of Cannon
* @param iDamage        Basic damage of cannon[Hitboxes are not counted]
* @param Float:fCooldown    Delay of each shoot [Normally 0.4sec]
*
* @return            Return if invalid 
*/ 
If there is anyone who could fix this I would be really gratefull!
native diablix_create_cannon(id, const iHp, const iDamage, const Float:fCooldown=0.4);
Attached Files
File Type: sma Get Plugin or Get Source (dzialko.sma - 437 views - 12.2 KB)

Last edited by F0RCE; 10-25-2011 at 05:54.
F0RCE is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-25-2011 , 07:33   Re: Library - Sentry Gun
Reply With Quote #2

Assuming that you know how to edit the plugin yourself:
  1. Instead of registering the Ham_Think forward in plugin_init(), register it when the cannon is created (nativeCreateCannon), and unregister it when destroyed (line 308).
  2. This will be fixed by just adding a small alive check in the CmdStart forward (above line 145).
  3. When the cannon is destroyed (line 308); set entity owner to 0. (and if you did #1, unregister the think forward as well).
  4. It's not supposed to be deleted on round end (at least not from what I can see in the code). This can be added by hooking round end and using find_ent_by_class() and remove_entity().

Note:
The spawn function is hooked by the usage of ResetHud, note that this is not the correct way to see if a player has spawned. Use Ham_Spawn with "player" classname.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!

Last edited by Xellath; 10-25-2011 at 10:40. Reason: #1 is incorrect
Xellath is offline
F0RCE
Senior Member
Join Date: Oct 2010
Old 10-25-2011 , 08:45   Re: Library - Sentry Gun
Reply With Quote #3

Hehe You are forcing me to do a hard work

I will try to fix it myself.

Thanks a lot for tips bro.
F0RCE is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-25-2011 , 08:50   Re: Library - Sentry Gun
Reply With Quote #4

Yeah, well, this is scripting help. I gave you tips on how to fix it. You should at least try fixing it yourself, that'll only improve your AMXX-scripting skills.

However, if you don't manage to fix it by yourself, I can help you further.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
F0RCE
Senior Member
Join Date: Oct 2010
Old 10-25-2011 , 10:20   Re: Library - Sentry Gun
Reply With Quote #5

Alright.

Where should I disable/enable the Ham?

new HamHook: ClassThink // On top
ClassThink = RegisterHam(Ham_Think,g_sClassName,"think_Dzi alko"); //in natives
DisableHamForward(ClassThink) // 308 line

Where should I enable this?

Last edited by F0RCE; 10-25-2011 at 10:41.
F0RCE is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-25-2011 , 10:39   Re: Library - Sentry Gun
Reply With Quote #6

I realized you cannot unregister ham hooks (mixed them with fakemeta hooks). You can use Enable|DisableHamHook to Enable|Disable it.

There is a problem though. The reason you're getting the invalid classname error is that Hamsandwich cannot hook custom classname entities. You'll have to replace the Ham_Think with either fakemeta (hook FM_Think) or engine (register_think). So disregard from #1 that I told you, it's incorrect.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
F0RCE
Senior Member
Join Date: Oct 2010
Old 10-25-2011 , 10:43   Re: Library - Sentry Gun
Reply With Quote #7

omg .

Trying this now . I will update this post with SMA when I'm done , so someone will check it

PHP Code:
register_forward(FM_Think,g_sClassName,"think_Dzialko"); 

Last edited by F0RCE; 10-25-2011 at 10:53.
F0RCE is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-25-2011 , 10:58   Re: Library - Sentry Gun
Reply With Quote #8

Quote:
Originally Posted by F0RCE View Post
omg .

Trying this now . I will update this post with SMA when I'm done , so someone will check it

PHP Code:
register_forward(FM_Think,g_sClassName,"think_Dzialko"); 
Code:
new ForwardId; ForwardId = register_forward( FM_Think, "ThinkFunc" ); // ... unregister_forward( FM_Think, ForwardId );

If you plan on spawning several sentrys, unregistering the think would result in the other sentrys not working. So again, disregard from what I said about disabling the hook, just hook the think with fakemeta as following:

Code:
register_forward(FM_Think, "think_Dzialko");

And you're good to go. Won't throw an error.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!

Last edited by Xellath; 10-25-2011 at 11:19. Reason: Typo
Xellath is offline
F0RCE
Senior Member
Join Date: Oct 2010
Old 10-25-2011 , 11:06   Re: Library - Sentry Gun
Reply With Quote #9

Alright I understand a little about registering/unregistering forwards/ham ;p

The problem is that this doesn't want to compile ;/

PHP Code:
Argument type mismatch 
On this line where is registered FM_Think

Last edited by F0RCE; 10-25-2011 at 11:13.
F0RCE is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-25-2011 , 11:18   Re: Library - Sentry Gun
Reply With Quote #10

Quote:
Originally Posted by F0RCE View Post
Alright I understand a little about registering/unregistering forwards/ham ;p

The problem is that this doesn't want to compile ;/

[php]Argument type mismatch[php]
On this line where is registered FM_Think
My bad. I was misleading you terribly. I don't know what's up today. I'm confused.

Using FM_Think:

Code:
register_forward( FM_Think, "think_dzialko" ); // NOTE: this would require you to check the specified classname in the think function

whereas using register_think (engine) would not:

Code:
register_think( "cl_dzialko", "think_dzialko" );

I'd suggest you to use register_think.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!

Last edited by Xellath; 10-25-2011 at 11:20. Reason: Typo...
Xellath 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 14:23.


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