AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   NS and weapon damage - not working? (https://forums.alliedmods.net/showthread.php?t=12200)

onlysolution 04-07-2005 22:18

NS and weapon damage - not working?
 
I am attempting to write a simple joke script at the request of a friend that sets the damage of the welder to absurd levels. After a billion different tries I've come to the conclusion that either ns_set_weap_dmg and ns_get_weap_dmg are completely non working or I am an idiot and I'm hoping someone can tell me which is the case. Here is the last script I tried

Code:

#include <amxmodx>
#include <ns>
#include <amxmisc>

new PLUGIN[]="Turbowelder"
new AUTHOR[]="Onlysolution"
new VERSION[]="1.00"

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_concmd("amx_turboweld", "cmd_turboweld", ADMIN_RCON, "")
}

public cmd_turboweld(id, level, cid)
{
    if (!cmd_access(id, level, cid, 0)) {
        return PLUGIN_HANDLED
            }
 
        new wep = WEAPON_WELDER
        new Float:dmg = 6000.00
        new Float:olddmg = ns_get_weap_dmg(WEAPON_WELDER)

 
        ns_set_weap_dmg(WEAPON_WELDER, dmg)
        server_print ("Weapon %d set to %f damage.", wep, dmg)
        server_print ("Original damage was %f", olddmg)
        server_print ("welder is %d", WEAPON_WELDER)
   

        return PLUGIN_HANDLED
  }

the output of the command is something like (i.e. same number, different number of trailing zeroes) :
Code:

  Weapon 18 set to 6000.0 damage
  Original damage was 0.0
  welder is 18

and the welder does the same amount of damage.

I'm guessing I can't properly program in small and I screwed up a data type or 12 in here.

Thanks in advance!

-Onlysolution

karlos 04-08-2005 11:28

ns_get_weap_dmg(weapon_ID)/ns_set_weap_dmg(weapon_ID)

u need to give the weapon ID not the weapon number
WEAPON_WELDER is a weapon number

i suggest:
1) cycle through all ents
2) check each ent if its a welder
3) if welder check if it belongs to the player u want to increase damage

now u have the weapon ID and u can use both functions

my gnome plugin is dioing it this way

onlysolution 04-09-2005 04:00

Thanks a bunch! The code I wound up using wasn't quite as intense though:

Code:

#include <amxmodx>
#include <ns>
#include <amxmisc>
#include <engine>

new PLUGIN[]="Turbowelder"
new AUTHOR[]="Onlysolution"
new VERSION[]="1.00"

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_concmd("amx_turboweld", "cmd_turboweld", ADMIN_CVAR, "<weapon> <damage>")
}

public cmd_turboweld(id, level, cid)
{
    if (!cmd_access(id, level, cid, 1)) {
        return PLUGIN_HANDLED
            }

        new Arg1[24]


        read_argv(1, Arg1, 24)

 
        new target = cmd_target( id, Arg1, 14 )
        new Float:dmg = 6000.0
        new wep = find_ent_by_owner(get_maxplayers(), "weapon_welder", target)
        new Float:olddmg = ns_get_weap_dmg(wep)
 
        ns_set_weap_dmg(wep, dmg)
        server_print ("Weapon %d set to %f damage.", wep, dmg)
        server_print ("Original damage was %f", olddmg)
   

        return PLUGIN_HANDLED
  }

though I'm sure it does exactly the same thing as you suggested, fundamentally.


All times are GMT -4. The time now is 10:02.

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