Raised This Month: $ Target: $400
 0% 

[SOLVED] Need help with my anti move and shoot plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Qvintus
Junior Member
Join Date: Sep 2009
Old 04-24-2011 , 18:50   [SOLVED] Need help with my anti move and shoot plugin
Reply With Quote #1

Hello you probaly think I'm weired. Anyways I figured it would be good with this plugin for my aim training, as I need to stand still everytime I shoot, else my bullets wont hit.

Anyways I need to make my plugin kill me everytime I don't stand still while shooting.

This is what I picked up on the forums for moveing, but I'm not sure where I finde the rest I need to finish this.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>

new PLUGIN[]="ProMoveTraining"
new AUTHOR[]="SND Qvintus"
new VERSION[]="1.00"

plugin_init()
{
    
register_plugin(PLUGIN,VERSIONAUTHOR);
    
register_forwardFM_CmdStart"FMCmdStart" );
    
register_concmd(ADMIN_SLAY)
}
public 
FMCmdStartiduc_handlerandseed )
{
    new 
Float:fmoveFloat:smove;
    
get_uc(uc_handleUC_ForwardMovefmove);
    
get_uc(uc_handleUC_SideMovesmove );

    new 
Float:maxspeed;
    
pev(idpev_maxspeedmaxspeed);
    new 
Float:walkspeed = (maxspeed 0.52); 
    
fmove floatabsfmove );
    
smove floatabssmove );
    
    if(
fmove <= walkspeed && smove <= walkspeed && !(fmove == 0.0 && smove == 0.0))
    {
        
// Walking
        
    
}
    else
    {
        
//Running  
    
}

So as you can see I still need it to check when I shoot, and if so execute the ADMIN_SLAY command on me. Is there anywhere I can pickup these commands without haveing to see through the whole libary?


UPDATE: Here is what I've come up with so far.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fun>

new PLUGIN[]="ProMoveTraining"
new AUTHOR[]="SND Qvintus"
new VERSION[]="1.00"

new moveing

plugin_init
()
{
    
register_plugin(PLUGIN,VERSIONAUTHOR);
    
register_forwardFM_CmdStart"FMCmdStart" );
    
register_concmd(ADMIN_SLAY)
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_ak47""ham_ak_Attack")
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_m4a1""ham_colt_Attack")
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_deagle""ham_deagle_Attack")
}
public 
FMCmdStartiduc_handlerandseed )
{
    new 
Float:fmoveFloat:smove;
    
get_uc(uc_handleUC_ForwardMovefmove);
    
get_uc(uc_handleUC_SideMovesmove );

    new 
Float:maxspeed;
    
pev(idpev_maxspeedmaxspeed);
    new 
Float:walkspeed = (maxspeed 0.52); 
    
fmove floatabsfmove );
    
smove floatabssmove );
    
    if(
fmove <= walkspeed && smove <= walkspeed && !(fmove == 0.0 && smove == 0.0))
    {
        
// Walking
        
moveing true;
    }
    else
    {
        
//Running 
        
moveing true;
    }
    
    if(
fmove == 0.0 && smove == 0.0)
    {
        
//Standing
        
moveing false;
    }
}

public 
ham_ak_Attack(weapon_entity)
{
    if (
moveing){
        
//ADMIN_SLAY player
    
}

}

public 
ham_colt_Attack(weapon_entity)
{
    if (
moveing) {
        
//ADMIN_SLAY player
    
}

}

public 
ham_deagle_Attack(weapon_entity)
{
    if (
moveing) {
        
//ADMIN_SLAY player
    
}

OR! I could use this ?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fun>

new PLUGIN[]="ProMoveTraining"
new AUTHOR[]="SND Qvintus"
new VERSION[]="1.00"

new moveing

plugin_init
()
{
    
register_plugin(PLUGIN,VERSIONAUTHOR);
    
register_forwardFM_CmdStart"FMCmdStart" );
    
//register_concmd(ADMIN_SLAY)
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_ak47""ham_ak_Attack")
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_m4a1""ham_colt_Attack")
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_deagle""ham_deagle_Attack")
}
public 
FMCmdStartiduc_handlerandseed )
{
    new 
Float:fmoveFloat:smove;
    
get_uc(uc_handleUC_ForwardMovefmove);
    
get_uc(uc_handleUC_SideMovesmove );

    new 
Float:maxspeed;
    
pev(idpev_maxspeedmaxspeed);
    new 
Float:walkspeed = (maxspeed 0.52); 
    
fmove floatabsfmove );
    
smove floatabssmove );
    
    if(
fmove <= walkspeed && smove <= walkspeed && !(fmove == 0.0 && smove == 0.0))
    {
        
// Walking
        
moveing true;
    }
    else
    {
        
//Running 
        
moveing true;
    }
    
    if(
fmove == 0.0 && smove == 0.0)
    {
        
//Standing
        
moveing false;
    }
}

public 
ham_ak_Attack(weapon_entity)
{
    if (
moveing){
        
user_kill(attacker)
    }

}

public 
ham_colt_Attack(weapon_entity)
{
    if (
moveing) {
        
user_kill(attacker)
    }

}

public 
ham_deagle_Attack(weapon_entity)
{
    if (
moveing) {
        
user_kill(attacker)
    }


Last edited by Qvintus; 04-24-2011 at 20:38.
Qvintus is offline
Qvintus
Junior Member
Join Date: Sep 2009
Old 04-24-2011 , 19:40   Re: Need help with my anti move and shoot plugin
Reply With Quote #2

Hmm trying to compile some of this causeing

PHP Code:
/tmp/text92tbwF.sma(24) : error 017undefined symbol "get_uc" 
/tmp/text92tbwF.sma(24) : warning 215expression has no effect 
/tmp/text92tbwF.sma(24) : error 001expected token";"but found ")" 
/tmp/text92tbwF.sma(24) : error 029invalid expressionassumed zero 
/tmp/text92tbwF.sma(24) : fatal error 107too many error messages on one line 
PHP Code:
Welcome to the AMX Mod X 1.8.1-300 CompilerCopyright (c1997-2006 ITB CompuPhaseAMX Mod X Team  
/tmp/textXBw7E9.sma(28) : error 017undefined symbol "pev" 
/tmp/textXBw7E9.sma(28) : warning 215expression has no effect 
/tmp/textXBw7E9.sma(28) : error 001expected token";"but found ")" 
/tmp/textXBw7E9.sma(28) : error 029invalid expressionassumed zero 
/tmp/textXBw7E9.sma(28) : fatal error 107too many error messages on one line  Compilation aborted4 Errors
Qvintus is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 04-24-2011 , 20:03   Re: Need help with my anti move and shoot plugin
Reply With Quote #3

I think you might be able to get away with something easier. A way to detect firing is by hooking the CurWeapon event, as shown by xeroblood here:

http://forums.alliedmods.net/showpos...59&postcount=2

The CurWeapon event is sent any time a player changes weapon or the ammo in his clip changes, so by keeping track of it all you can tell when a player fires a bullet. Then you should be able to check what buttons he is pressing (pev_button) for any movement keys, and if detected kill him with user_kill.

Code:
// Original code by xeroblood: // forums.alliedmods.net/showpost.php?p=137559&postcount=2 #include <amxmodx> #include <fakemeta> // any of the buttons on the right will count as moving #define IN_MOVING (IN_FORWARD|IN_BACK|IN_MOVELEFT|IN_MOVERIGHT|IN_JUMP) // Tracks players Shots-Fired: [0]=WeaponID, [1]=Ammo new g_iCurrWeapon[33][2] public plugin_init() {     register_event( "CurWeapon", "Event_ShotFired",  "b" ) } public Event_ShotFired( id ) {     // Players current weapon data..     new wID = read_data( 2 )     new wAmmo = read_data( 3 )     if( g_iCurrWeapon[id][0] != wID ) // User Changed Weapons..     {         g_iCurrWeapon[id][0] = wID         g_iCurrWeapon[id][1] = wAmmo         return PLUGIN_CONTINUE     }     if( g_iCurrWeapon[id][1] < wAmmo ) // User Reloaded..     {         g_iCurrWeapon[id][1] = wAmmo         return PLUGIN_CONTINUE     }     if( g_iCurrWeapon[id][1] == wAmmo ) // User did something else, but didn't shoot..     {         return PLUGIN_CONTINUE     }     // This far means user shot his/her gun..     // Save new weapon data..     g_iCurrWeapon[id][1] = wAmmo     g_iCurrWeapon[id][0] = wID     // Do Stuff here..     // he is alive and using movement keys     if( is_user_alive(id) && (pev(id, pev_button) & IN_MOVING) )     {         // make sure he is using a gun         if( wID != CSW_HEGRENADE && wID != CSW_FLASHBANG && wID != CSW_SMOKEGRENADE             && wID != CSW_C4 && wID != CSW_KNIFE )         {             user_kill(id, 1)         }     }     return PLUGIN_CONTINUE }

Let me know how it works.

Ava
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS

Last edited by XxAvalanchexX; 04-24-2011 at 20:07.
XxAvalanchexX is offline
Qvintus
Junior Member
Join Date: Sep 2009
Old 04-24-2011 , 20:11   Re: Need help with my anti move and shoot plugin
Reply With Quote #4

WoW thx for the reply I came up with some thing my self

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>

new PLUGIN[]="ProMoveTraining"
new AUTHOR[]="SND Qvintus"
new VERSION[]="1.00"

new moveing

plugin_init
()
{
    
register_plugin(PLUGIN,VERSIONAUTHOR);
    
register_forwardFM_CmdStart"FMCmdStart" );
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_ak47""ham_ak_Attack")
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_m4a1""ham_colt_Attack")
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_deagle""ham_deagle_Attack")
}
public 
FMCmdStartiduc_handlerandseed )
{
    new 
Float:fmoveFloat:smove;
    
get_uc(uc_handleUC_ForwardMovefmove);
   
get_uc(uc_handleUC_SideMovesmove );

    new 
Float:maxspeed;
    
pev(idpev_maxspeedmaxspeed);
    new 
Float:walkspeed = (maxspeed 0.52); 
    
fmove floatabsfmove );
    
smove floatabssmove );
    
    if(
fmove <= walkspeed && smove <= walkspeed && !(fmove == 0.0 && smove == 0.0))
    {
        
// Walking
        
moveing true;
    }
    else
    {
        
//Running 
        
moveing true;
    }
    
    if(
fmove == 0.0 && smove == 0.0)
    {
        
//Standing
        
moveing false;
    }
}

public 
ham_ak_Attack(weapon_entity)
{
    static 
attacker
    attacker 
get_pdata_cbase(weapon_entityOFFSET_WEAPONOWNEROFFSET_LINUX_WEAPONS);
    
    if (
moveing){
        
user_kill(attacker)
    }

}

public 
ham_colt_Attack(weapon_entity)
{
    static 
attacker
    attacker 
get_pdata_cbase(weapon_entityOFFSET_WEAPONOWNEROFFSET_LINUX_WEAPONS);
    
    if (
moveing) {
        
user_kill(attacker)
    }

}

public 
ham_deagle_Attack(weapon_entity)
{
    static 
attacker
    attacker 
get_pdata_cbase(weapon_entityOFFSET_WEAPONOWNEROFFSET_LINUX_WEAPONS);
    
    if (
moveing) {
        
user_kill(attacker)
    }

But yea it failed and wont even be loaded xD I test yours in a sec


EDIT:
SCRATCH THAT...

After adding it to plugin.ini it loads ^^, works like a charm. Thx a lot buddy

Last edited by Qvintus; 04-24-2011 at 20:23.
Qvintus is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 04-24-2011 , 20:21   Re: Need help with my anti move and shoot plugin
Reply With Quote #5

Oh, I see. What is the problem with AMXX?
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Qvintus
Junior Member
Join Date: Sep 2009
Old 04-24-2011 , 20:26   Re: Need help with my anti move and shoot plugin
Reply With Quote #6

Hello if anyone is in need of this and want to use it I will attach it to this post

BTW I'm useing LuxBots with DM and HSOnly mod if you'd like to know for some reason xD

PS: remember to say thanks to XxAvalanchexX

EDIT:
Only thing that could be optimized is it should only effect player and not bots + it should also take effect when your moveing after a keypress and not standing completly still.
Attached Files
File Type: amxx ProMoveTraining.amxx (2.0 KB, 83 views)

Last edited by Qvintus; 04-24-2011 at 20:40.
Qvintus is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 04-24-2011 , 20:39   Re: [SOLVED] Need help with my anti move and shoot plugin
Reply With Quote #7

Yay! I'm glad it works. Also, if you're testing with bots, you can disable it for bots by changing the first if statement to something like
Code:
if( is_user_alive(id) && !is_user_bot(id) && (pev(id, pev_button) & IN_MOVING) )
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Qvintus
Junior Member
Join Date: Sep 2009
Old 04-24-2011 , 21:15   Re: [SOLVED] Need help with my anti move and shoot plugin
Reply With Quote #8

Oh and did you know your my Hero?
Qvintus 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 19:50.


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