AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   CS/DoD/TFC Weapon Gravity (https://forums.alliedmods.net/showthread.php?t=60945)

M249-M4A1 09-16-2007 22:33

CS/DoD/TFC Weapon Gravity
 
2 Attachment(s)
Quote:

/********************************************* *******
*
* Name: CS/DoD/TFC Weapon Gravity
* Author: M249-M4A1
* Idea: X-Script
* Version: 2.0
* Date: 10-06-2007
*
* Description:
* - Players will have a different personal gravity, depending on the weapon that
* they are currently using.
*
* Commands:
* - say /weapongrav
* - amx_reload_weapongrav [SERVER COMMAND]
* - amx_weapon_gravity <1=ON|0=OFF> [REQUIRES ADMIN_BAN FLAG]
*
* Command Details:
* - say /weapongrav toggles weapon gravity on or off (only for that person who typed it)
* - amx_reload_weapongrav reloads gravity configuration file
* - amx_weapon_gravity toggles the weapon gravity plugin on/off
*
* CVARs:
* - [CS] cs_weapon_gravity <1=ON|0=OFF> - enables/disables the plugin (default enabled)
* - [DoD] dod_weapon_gravity (same as above)
* - [TFC] tfc_weapon_gravity (same as above)
*
* Notes:
* - This plugin may interfere with other gravity plugins.
* - Refer to the gravity configuration file "m2_weapon_gravity.ini" file for instructions
* on editing weapon gravities.
*
* Special Thanks (and Credits):
* - X-Script, for their idea of making this plugin, and letting me take over.
* - Zenith77, for many great suggestions to make this plugin better, and providing me with alternative
* code for efficiency and ease of use.
* - EJL's Sound Download Management for the read-from-file example.
* - Bahrmanou, for their method of messaging all players except the caller.
*
* Changelog:
* - 1.0: Initial release
* - 1.5: Cleaned up code; Added lower gravity for all weapons; Added CVAR to enable/disable plugin
* - 1.6: Removed a useless variable; Removed as much white space as possible; Added comments
* - 1.6b: Added ability for clients to enable/disable weapon gravity; Say /weapongrav to toggle
* - 1.6c: Fixed bug where clients could not turn off weapon gravity; Added information message when player joins
* - 1.7: Plugin now reads from a configuration file; Default configuration file is:
* "addons/amxmodx/configs/tfc_weapon_gravity.ini" but can be changed (edit CONFIGFILE in the define section below)
* - 1.7b: Code revision; Added Credits
* - 1.7c: Cleaned up code; Changed CVAR name: "amx_tfcgravity" to "tfc_weapon_gravity"
* - 1.7d: Notify all players (except caller) of the caller's gravity change; Added command to toggle plugin on/off
* - 1.8: Updated "tfc_weapon_gravity.ini" and updated some code
* - 1.9: Supports Counter-Strike, Day of Defeat, and Team Fortress Classic
* - 2.0: One gravity configuration file: "m2_weapon_gravity.ini"
*
********************************************* *******/

M249-M4A1 09-16-2007 22:36

Re: TFC Weapon Gravity (X-Script)
 
Oh yeah, this is pretty much how X-Script left it. Zenith suggested an alternate method of editing the values, so I'll be adding that user-friendly alternative in like 10 minutes...

Zenith77 09-18-2007 18:29

Re: TFC Weapon Gravity (X-Script)
 
This is why I suggested the plugin should read from a file. Also, the admin should be able to turn on or off a cvar that allows clients to turn off the gravity changes.

Stixsmaster 09-18-2007 19:08

Re: TFC Weapon Gravity (X-Script)
 
The idea behind this type of plugin is to add more challenge to the game...

---Stixsmaster

X-Script 09-21-2007 15:57

Re: TFC Weapon Gravity (X-Script)
 
Quote:

Originally Posted by Stixsmaster (Post 532781)
The idea behind this type of plugin is to add more challenge to the game...

---Stixsmaster

Exactly.

M249-M4A1 09-21-2007 16:14

Re: TFC Weapon Gravity (X-Script)
 
Fixed a bug in the plugin, refer to changelog for details.

Zenith77 09-22-2007 12:20

Re: TFC Weapon Gravity (X-Script)
 
This needs more functionality before approval. I find it's pretty pointless, and I don't think many people will use this in the fist place in its current state. Follow my given suggestion(s) here and in the previous threads.

M249-M4A1 09-22-2007 13:14

Re: TFC Weapon Gravity (X-Script)
 
Now updated with configuration file!

Zenith77 09-24-2007 00:29

Re: TFC Weapon Gravity (X-Script)
 
Some things that need to be done:

  1. Code:
    set_task(1.0, "ReadFile")
    I personally use plugin_cfg() to load plugin configuration. You don't have to do this however, just making a note.

  2. Code:
        if (get_pcvar_num(g_WpnGrav) < 1) {         client_print(id, print_chat, "[AMXX] : Weapon gravity has been disabled by the admin!")         return PLUGIN_HANDLED         } else if (PersonalGrav[id] == false) {         PersonalGrav[id] = true         weapongravity(id)         client_print(id, print_chat, "[AMXX] : Your gravity now adjusts to the weapon you are holding! Say /weapongrav again to turn it off!")         } else {         PersonalGrav[id] = false         weapongravity(id)         client_print(id, print_chat, "[AMXX] : Your weapon gravity has been turned off! Say /weapongrav to turn it back on!")     }
    Dear God indent this correctly. Do this for all other areas that occur like this. In fact you may just want to consider using an auto-indenter.

  3. Code:
                i++             gTFCWeaponGravityList[i - 1] = str_to_float(readin)

    Change that to:
    Code:
                gTFCWeaponGravityList[i++] = str_to_float(readin)
  4. Please give proper credit to users who helped formed your code. Thanks.

M249-M4A1 09-24-2007 08:55

Re: TFC Weapon Gravity (X-Script)
 
The AMXX Studio did the indenting for me, becuase I did } else { it shows up on the same line. But yeah, I'll make those changes soon. As for the code, if you are referring to the read from file, i used the sound download management line to get me started, the rest was all trial and error.

...and thanks for the feedback, zenith!

EDIT: changes made!!!!


All times are GMT -4. The time now is 23:46.

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