PDA

View Full Version : Request: MG can not fire UNLESS deployed


=|[76AD]|= TatsuSaisei
08-20-2006, 07:49 PM
Can someone whip up a quick plugin that prevents a player from firing an MG if it is not deployed. Too many times have I seen people use a script that allows them to fire the MG without having the normal recoil associated with it, and quite honestly, the weapon is not meant to be used unless deployed, but the game will still let you fire it.

diamond-optic
08-20-2006, 11:21 PM
i was thinking of doing something with the mgs.. but my idea was to add to the recoil by adding to the vector angle

but since i just got home from a really bad 4 day festival lol, dont expect much soon

=|[76AD]|= TatsuSaisei
08-21-2006, 01:27 AM
i was thinking of doing something with the mgs.. but my idea was to add to the recoil by adding to the vector angle

but since i just got home from a really bad 4 day festival lol, dont expect much soon
sorry to hear about festival :(

I "expect" nothing, but appreciate anything that anyone does...

but I think just taking ability to fire away from an undeployed MG would be easier to code, and people could possibly still counter any "extra" recoil with some crafty scripts... but thanx for even considering it...

Wilson [29th ID]
08-21-2006, 08:47 PM
#include <dodfun>

public UpdateClientData_Post( id, sendweapons, cd_handle ) {
new clip, ammo, myWeapon = get_user_weapon(id,clip,ammo)
if ( (myWeapon == DODW_MG42) || (myWeapon == DODW_MG34) || (myWeapon == DODW_30CAL) ) {
if(!dod_is_deployed(id))
set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001 );
}
return FMRES_HANDLED;
}

diamond-optic
08-21-2006, 08:57 PM
hmmmmmm

whats this UpdateClientData stuff & CD_flNextAttack do lol?

Wilson [29th ID]
08-21-2006, 10:03 PM
UpdateClientData is basically sent with every server frame. the CD_flNextAttack is setting the "next time you can fire" to never.

diamond-optic
08-21-2006, 10:33 PM
ahh pretty nifty heh

=|[76AD]|= TatsuSaisei
08-22-2006, 03:18 AM
th ']#include <dodfun>

public UpdateClientData_Post( id, sendweapons, cd_handle ) {
new clip, ammo, myWeapon = get_user_weapon(id,clip,ammo)
if ( (myWeapon == DODW_MG42) || (myWeapon == DODW_MG34) || (myWeapon == DODW_30CAL) ) {
if(!dod_is_deployed(id))
set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001 );
}
return FMRES_HANDLED;
}

works for the first 5 seconds but then the gun is useable non-deployed again... and ONLY when i leave the server and come back does it "work" for the 5 seconds again... if I switch teams and try one of their MGs I can fire from the get go...

I have been looking around for any other plugin that does something similar, and everything I have tried so far has come up bust... I am adding in a chat message to atleast let me know if it is getting to the point in the "if" statement to begin with...

btw in your code there were a few minor "errors" and possibly deprected commands:

DODW_30CAL should be DODW_30_CAL
get_user_weapon changed to dod_get_user_weapon
added #include <fakemeta> | #include <dodx> | #include <engine>

but I now have a question too ... when you check dod_is_deployed(id) will a 0 = FALSE and 1 = TRUE ?? I feel like this is a stupid question, but I have to ask... I am not sure how AMXX treats this, but the dodfun.inc states this:

/* Returns 1 is player weapon is deployed (bar,mg..) */
native dod_is_deployed(index);

here is what I have done completely so far, and am awaiting a map change to test...


#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <dodfun>
#include <dodx>
#define PLUGIN "dod_mg_mustdeploy"
#define VERSION "76.1"
#define AUTHOR "TatsuSaisei"

// Credit goes to Cpt. Wilson [29thID] for most of the code used come from a suggestion he made in the dodplugins.net forum

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
}
public client_PreThink(id) {
new clip, ammo, myWeapon = dod_get_user_weapon(id,clip,ammo)
if((myWeapon == DODW_MG42) || (myWeapon == DODW_MG34) || (myWeapon == DODW_30_CAL)){
if(entity_get_int(id, EV_INT_button) & IN_ATTACK) {
if(dod_is_deployed(id) == 0){
client_print(id,print_chat,"Deploy your Machine Gun before you try firing it !!")
entity_set_int(id, EV_INT_button, entity_get_int(id, EV_INT_button) & ~IN_ATTACK)
return PLUGIN_HANDLED
}
}
}
return PLUGIN_HANDLED
}


OK, it "works"... BUT the gun will still "fire" when undeployed, but the gunshots do NOT register... so the problem now is simply "cosmetic"

Posting code to Non-Developers section. Please lock this post and any future comments should go there in the new post.

http://www.dodplugins.net/forums/showthread.php?p=651#post651

diamond-optic
08-22-2006, 05:35 AM
plugin available @ http://www.dodplugins.net/forums/showthread.php?t=188