AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   Module: Counter-Strike Weapon Mod [1.7.1] (https://forums.alliedmods.net/showthread.php?t=308229)

Ghosted 06-11-2018 16:00

Module: Counter-Strike Weapon Mod [1.7.1]
 
1 Attachment(s)
Description
So you want counter-strike weapon mod that adds new weapons in game?
Then you are in a right place.

Presenting you the Counter-Strike Weapon Mod. You can create them though files or plugins. It is very easy, you should have at least view/weapon/world (v/p/w) models for your weapon. CSWM was created using following SDKs:

  1. ReGameDLL_CS
  2. AMX MOD X
  3. MetaMod

→ Credits Goes To These Projects Authors

______________________________________

  • No Weapon Limit
  • Over 9 Attack2 Modes
  • Over 17 New Ammos Can Be Adeded
  • Only Resources Required & Low Experience of Scripting
  • You Can Download Source Code From Here
  • Or Report An Issue
    (Windows version has higher priority in bug reports)


Tutorial

GitHub Mini Wiki

Creating Weapon Through File:
Spoiler


Creating Weapon Through Plugin:
Spoiler


Requirements
↪ MetaMod
↪ AMX MOD X (Recommended 1.8.2 or higher)


ChangeLog
Spoiler

How To Use
Way A: Enable 'sv_cheats' and type give <Weapon Model Name>
Way B: Create your weapon menu using This Source Code.


Author
Check Poster


Platforms
Windows/Linux (ReGameDLL/reHLDS is not required)


How To Install
First Download (Includes ChangeLog) [Direct Link], Then Add 'cswm' in 'modules.ini'.


Examples (Older versions)

Support For Other Mods
(Put Plugin Before CSWM Plugins In 'plugins.ini')

hjkwe654 06-12-2018 12:52

Re: Module: Counter-Strike Weapon Mod [CSWM][V1.45 Beta]
 
Nice job, i will move my Ion Cannon project to here when i available free time.

543658883 07-14-2018 14:26

Re: Module: Counter-Strike Weapon Mod [1.5 R]
 
r there all the name such as weapon name or ammo name support UTF-8 ?

Ghosted 07-15-2018 02:28

Re: Module: Counter-Strike Weapon Mod [1.5 R]
 
Quote:

Originally Posted by 543658883 (Post 2603614)
r there all the name such as weapon name or ammo name support UTF-8 ?

Support for UTF-8 based on game.

KORD_12.7 07-19-2018 09:15

Re: Module: Counter-Strike Weapon Mod [1.5 R]
 
Wow! Good job! :D

Ghosted 07-19-2018 10:26

Re: Module: Counter-Strike Weapon Mod [1.5 R]
 
Quote:

Originally Posted by KORD_12.7 (Post 2604778)
Wow! Good job! :D

Thanks, i'll add more features & support for more weapons

PartialCloning 07-23-2018 19:00

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
That looks nice. What's the NPC mod going to look like? Smart AI? NPC interaction? Monster mod?

Ghosted 07-24-2018 04:01

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
Quote:

Originally Posted by PartialCloning (Post 2605735)
What's the NPC mod going to look like? Smart AI? NPC interaction? Monster mod?

Actually i don't know how :mrgreen:, but this wont be done in near future :crab:, must learn some about walking and aiming system, gonna check halflife code.

sekac 07-25-2018 05:51

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
So can I just create a new grenade type, and is it gonna have its own slot?

Ghosted 07-25-2018 06:16

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
Quote:

Originally Posted by sekac (Post 2606020)
So can I just create a new grenade type, and is it gonna have its own slot?

This module does not support knives / grenades.

DarthMan 08-16-2018 12:28

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
Quote:

Originally Posted by Ghosted (Post 2596432)
Description
Presenting You Counter-Strike Weapon Mod. This Module Allows Uou To Add Infinite Amount of Weapons Into Game. Usually Such Things Are Used In Zombie Mods, But You Can Use This One On Classic Mode If You Want :) . CSWM Created Using Following Projects SDKs:

  1. ReGameDLL_CS
  2. AMX MOD X
  3. MetaMod

→ Credits Goes To These Projects Authors

______________________________________

  • No Weapon Limit
  • Over 9 Attack2 Modes
  • Over 17 New Ammos Can Be Adeded
  • Only Resources Required & Low Experience of Scripting
  • You Can Download Source Code From Here
  • Or Report An Issue


Tutorial
  • Creating Weapon
    Code:

            new Weapon = CreateWeapon(<Model Name>, <Type>, <Name>);
  • Editing/Defining Parameters
    • Deploy
      Code:

              BuildWeaponDeploy(<Weapon>, <Animation [-1 = Auto Detect]>, <Duration [0.0 = Auto Detect]>);
    • Shoot
      Code:

              BuildWeaponPrimaryAttack(<Weapon>, <Delay>, <Damage>, <Recoil>, <Animation [-1 = Auto Detect (Alle)]> ...);
    • Reload Style of Pistol/Rifle/Sniper
      Code:

              BuildWeaponReload(<Weapon>, <Animation [-1 = Auto Detect]>, <Duration [0.0 = Auto Detect]>);
    • Reload Style of Shotgun (Uses Default Animation Indexes)
      Code:

              BuildWeaponReload2(<Weapon>, <Duration [Insert Time]>, <Style [M3/XM1014]>);
    • Models
      Code:

              BuildWeaponModels(<Weapon>, <View Model>, <Weapon Model>, <World Model>);
    • Ammo
      Code:

              BuildWeaponAmmunition(<Weapon>, <Clip>, <Type>);
    • Fire Sound
      Code:

              BuildWeaponFireSound(<Weapon>, <Sound>);
    • Weapon List (HUD)
      Code:

              BuildWeaponList(<Weapon>, <WeaponList Name>);
    • Flags
      Code:

              BuildWeaponFlags(<Weapon>, <Flag Bitsum>);


Where's Secondary Attack Functions? They Are Not Done Yet :crab:

Requirements
↪ MetaMod
↪ AMX MOD X


How To Use
Enable 'sv_cheats' (Restart The Game) & Type 'give *', Where * Is Model Name of The Weapon Or Create Your Own Weapons Menu Using This Source Code.


Author
It's Me (Ghost)


Platforms
At This Time > Windows Only


How To Install
First Download [Direct Link], Then Add 'cswm' in 'modules.ini'.


Examples

Does this support adding entirely new weapons to CS on slots? By that I mean having all of the old weapons plus the new ones. Also, is ReHLDS a must?

Ghosted 08-16-2018 14:00

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
Quote:

Originally Posted by DarthMan (Post 2610553)
Does this support adding entirely new weapons to CS on slots? By that I mean having all of the old weapons plus the new ones. Also, is ReHLDS a must?

No need to quote whole post. No you cant have all old ones and new ones holding at once. No you don't need reHLDS/reGameDLL.

Airkish 09-08-2018 01:59

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
Tried to build some weapons from cs:go, then noticed it's windows only :/ Can we expect linux support?
And what will get_user_weapon(id) return when I've selected custom weapon?

Ghosted 09-08-2018 05:17

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
Quote:

Originally Posted by Airkish (Post 2614230)
Tried to build some weapons from cs:go, then noticed it's windows only :/ Can we expect linux support?

I'l try.
EDIT: I think compiling on windows to get linux library is impssible.

Quote:

Originally Posted by Airkish (Post 2614230)
And what will get_user_weapon(id) return when I've selected custom weapon?

Will return Pistol as P228, Rifle as AK47, Sniper as AWP, Shotgun as XM1014

Airkish 09-08-2018 05:20

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
Quote:

Originally Posted by Ghosted (Post 2614236)
Will return Pistol as P228, Rifle as AK47, Sniper as AWP, Shotgun as XM1014

Would it be possible for you to let us set custom id?

PHP Code:

new Weapon CreateWeapon(<Model Name>, <Type>, <Name>, <Index>); 


Ghosted 09-08-2018 06:02

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
Quote:

Originally Posted by Airkish (Post 2614237)
Would it be possible for you to let us set custom id?

PHP Code:

new Weapon CreateWeapon(<Model Name>, <Type>, <Name>, <Index>); 


no, there is limit of weapon index - 32 (MAX_WEAPONS) which is already filled up.
things would mess up.

hjkwe654 09-09-2018 01:45

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
CSWM will conflict with other plugins and cause server crash

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <rpgx>

#define dmgcalc (0.04 * RPGx_GetUpgradeLevel(attacker, upgrade_id))

new g_hambots
new cvar_botquota
new upgrade_id

public plugin_init() {
    
register_plugin("Knife Dmg+ RPGx Upgrade""2.7""hjkwe654")
    
cvar_botquota get_cvar_pointer("bot_quota")
    
RegisterHam(Ham_TakeDamage"player""KnifeDamage")
}

public 
client_putinserver(id) {
    if (!
is_user_bot(id) && g_hambots && !cvar_botquota)
        return
    
    
set_task(0.1"fw_RegisterHamBots"id)
}

public 
fw_RegisterHamBots(id) {
    
RegisterHamFromEntity(Ham_TakeDamageid"KnifeDamage_BOT")
    
g_hambots true
}

public 
RPGx_OnPluginReady()
    
upgrade_id RPGx_MakeUpgrade("近戰訓練"100157)

public 
KnifeDamage(thisidattackerFloat:fDmgdamagebits) {
    if(
is_user_alive(attacker)){
        new 
iLevel RPGx_GetUpgradeLevel(attackerupgrade_id)
        if(
iLevel && get_user_weapon(attacker) == CSW_KNIFE)
        {
            
SetHamParamFloat(4fDmg * (dmgcalc))   //this code will conflict with CSWM
            
return HAM_HANDLED
        
}
    }
    return 
HAM_IGNORED
}

public 
KnifeDamage_BOT(thisidattackerFloat:fDmgdamagebits) {
    if(
is_user_alive(attacker)){
        new 
iLevel RPGx_GetUpgradeLevel(attackerupgrade_id)
        if(
iLevel && get_user_weapon(attacker) == CSW_KNIFE)
        {
            
SetHamParamFloat(4fDmg + (iLevel 0.08))   //this code will conflict with CSWM
            
return HAM_HANDLED
        
}
    }
    return 
HAM_IGNORED



Ghosted 09-09-2018 04:49

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
Quote:

Originally Posted by hjkwe654 (Post 2614339)
CSWM will conflict with other plugins and cause server crash
Spoiler

Thanks for report, i have fixed the issue, problem was not SetHamParamFloat, it was caused after restarting the game and shooting bot.

Your code is incorrect at:
Code:

if (!is_user_bot(id) && g_hambots && !cvar_botquota)
                return

should be:
Code:

if (!is_user_bot(id) || g_hambots || !cvar_botquota)
                return

If you face any issues please report here or on github page.

hjkwe654 09-09-2018 13:28

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
One more issue, client get into buy menu will crash client side. (After update to 1.6.1)

Ghosted 09-09-2018 16:20

Re: Module: Counter-Strike Weapon Mod [1.6 R]
 
Quote:

Originally Posted by hjkwe654 (Post 2614424)
One more issue, client get into buy menu will crash client side. (After update to 1.6.1)

That should not be connected to server in any way. Anyway tested and it is not an issue.

killerZM 10-07-2018 11:52

Re: Module: Counter-Strike Weapon Mod [1.6.3]
 
off-topic sorry
where did you learn using C++ to make CS modules ?

HamletEagle 10-07-2018 12:12

Re: Module: Counter-Strike Weapon Mod [1.6.3]
 
Quote:

Originally Posted by killerZM (Post 2618724)
off-topic sorry
where did you learn using C++ to make CS modules ?

There are tons of sites/books to learn C++ from.

killerZM 10-07-2018 15:22

Re: Module: Counter-Strike Weapon Mod [1.6.3]
 
Quote:

Originally Posted by HamletEagle (Post 2618728)
There are tons of sites/books to learn C++ from.

i am not talking about C++ i am talking about HL SDK and such

Ghosted 10-08-2018 02:21

Re: Module: Counter-Strike Weapon Mod [1.6.3]
 
I've learned HLSDK by creating modifications of halflife via its code, and learned C++ via GOOGLING

killerZM 10-08-2018 17:40

Re: Module: Counter-Strike Weapon Mod [1.6.3]
 
ok

metal_upa 11-02-2018 16:43

Re: Module: Counter-Strike Weapon Mod [1.6.3]
 
Quote:

Weapon Type Can Be Pistol (P228), ShotGun (XM1014), Rifle (AK47), Sniper (AWP).
What about dual gun weapons?
For example i wanna make dual mp5 weapon. How? i see no replacement for Dual-Elites weapon.

Ghosted 11-02-2018 18:12

Re: Module: Counter-Strike Weapon Mod [1.6.3]
 
Quote:

Originally Posted by metal_upa (Post 2622343)
What about dual gun weapons?
For example i wanna make dual mp5 weapon. How? i see no replacement for Dual-Elites weapon.

That would require a bit code.
RegisterWeaponForward on primary attack post and then send weapon animation.
animation will be left or right depends on which was previous. you can do this by using custom entity variable than is not used by original dll. for example EV_INT_iuser4/pev_iuser4 and set 1/0. 0 will be left 1 will be right.

Example:

Code:

MyHookedForward(Weapon)
{
static IsRight = entity_get_int(Weapon, EV_INT_iuser4);
SendWeaponAnim(Weapon, IsRight ? <YourRightAnimation> : <YourLeftAnimation>);
entity_set_int(Weapon, EV_INT_iuser4, !IsRight);
}


metal_upa 11-08-2018 14:48

Re: Module: Counter-Strike Weapon Mod [1.6.3]
 
Quote:

Originally Posted by Ghosted (Post 2622346)
That would require a bit code.
RegisterWeaponForward on primary attack post and then send weapon animation.
animation will be left or right depends on which was previous. you can do this by using custom entity variable than is not used by original dll. for example EV_INT_iuser4/pev_iuser4 and set 1/0. 0 will be left 1 will be right.

Example:

Code:

MyHookedForward(Weapon)
{
static IsRight = entity_get_int(Weapon, EV_INT_iuser4);
SendWeaponAnim(Weapon, IsRight ? <YourRightAnimation> : <YourLeftAnimation>);
entity_set_int(Weapon, EV_INT_iuser4, !IsRight);
}


You module crash too much on rehlds server, no error log given. I just create a simple weapon replacement for rifle.

BTW this is just a basic weapon replacement:
Spoiler


Can you make a complete documentation of this module, your wiki seems to be out dated.

Ghosted 11-09-2018 06:02

Re: Module: Counter-Strike Weapon Mod [1.6.3]
 
Quote:

Originally Posted by metal_upa (Post 2623154)
Can you make a complete documentation of this module, your wiki seems to be out dated.

Sorry but i'm currently working on 1.7 version which will also add support for linux, cant tell when it will be done.

PS: I will test module on rehlds/hlds & regame/game.

metal_upa 11-10-2018 07:32

Re: Module: Counter-Strike Weapon Mod [1.6.3]
 
Quote:

Originally Posted by Ghosted (Post 2623224)
Sorry but i'm currently working on 1.7 version which will also add support for linux, cant tell when it will be done.

PS: I will test module on rehlds/hlds & regame/game.

I would like to use this module to make custom weapons on my server.

Bug found: GiveAmmo(id, WAmmoType_762Nato, 100)
it capped value at 90? why not go more than that?


Nevermind, my bad.. i need to create custom ammo first. Looking forward for your new update.

God Of Gaming 11-19-2018 18:18

Re: Module: Counter-Strike Weapon Mod [1.6.3]
 
Oh lol, why the hell am I using the old hl weaponmod from a decade ago when there's this. This works so much better!

P.S. there seems to be some sort of conflict with ConnorMcLeod's bpammo_features.amxx

P.S.2 for some reason GiveWeaponByName() doesnt seem to work?

P.S.3 I noticed a few pretty nasty bugs, I'd say this is not yet ready for use, but theres definitely potential in there, I hope version 1.7.0 fixes these

PyPKjE20 12-02-2018 18:09

Re: Module: Counter-Strike Weapon Mod [1.7]
 
Pleas add function pev_viewmodel2 + pev_skin (textured pack) funcion
https://image.prntscr.com/image/HyZA...UAGS8wzJZw.png

Ghosted 12-03-2018 03:01

Re: Module: Counter-Strike Weapon Mod [1.7]
 
Quote:

Originally Posted by PyPKjE20 (Post 2626464)
Pleas add function pev_viewmodel2 + pev_skin (textured pack) funcion
https://image.prntscr.com/image/HyZA...UAGS8wzJZw.png

weapon skin can be changed but it also changes player's skin. (viewmodel of the weapon is attached to player.)

PyPKjE20 12-03-2018 03:55

Re: Module: Counter-Strike Weapon Mod [1.7]
 
What code would you use to change the texture of a weapon?

Ghosted 12-03-2018 08:59

Re: Module: Counter-Strike Weapon Mod [1.7]
 
Quote:

Originally Posted by PyPKjE20 (Post 2626498)
What code would you use to change the texture of a weapon?

get playerid and edit pev_body/pev_skin
this worked with weapmodel (p_*) but should work on viewmodel too
this also changed player's submodel (if there is)

metal_upa 12-03-2018 13:05

Re: Module: Counter-Strike Weapon Mod [1.7]
 
Quote:

Originally Posted by Ghosted (Post 2626530)
get playerid and edit pev_body/pev_skin
this worked with weapmodel (p_*) but should work on viewmodel too
this also changed player's submodel (if there is)

I doubt that, pev_body and pev_skin will never work on v_* model, it handled on client-side. Metahook can do this stuff.

quLeryuzz 12-25-2018 06:59

Re: Module: Counter-Strike Weapon Mod [1.7]
 
Ok, I did it easily. But I want to you add to module something.
I use your module for lasermine plugin, and it was successful. But this is not a weapon. Oke this is specific a weapon but, when I take another weapon, this shouldn't remove on player.
That's why, can you add free Weapon Type? Not pistol, not ShotGun, only free weapon type. And How can move weapon to Slot5?



Don't look to ammo. I haven't written yet.

Ghosted 12-25-2018 08:13

Re: Module: Counter-Strike Weapon Mod [1.7]
 
Quote:

Originally Posted by quLeryuzz (Post 2630887)
Ok, I did it easily. But I want to you add to module something.
I use your module for lasermine plugin, and it was successful. But this is not a weapon. Oke this is specific a weapon but, when I take another weapon, this shouldn't remove on player.
That's why, can you add free Weapon Type? Not pistol, not ShotGun, only free weapon type. And How can move weapon to Slot5?



Don't look to ammo. I haven't written yet.

Free type does not exists, but you can change slot of pistol/rifle via weaponlist message, but thats kinda useless when you can't have same weapon type weapon with custom one. (For example for pistol you wont be able to have p228 and lasermine together)

quLeryuzz 12-25-2018 16:14

Re: Module: Counter-Strike Weapon Mod [1.7]
 
Can you add native like GiveWeaponByName? It will not be sending drop command to player. Because I wrote somethings and I approached.
Code:

public plugin_precache()
{
    BuildWeaponModels(Weapon, VMODELI, PMODELI, WMODELI);
}
public plugin_init()
{
    register_forward(FM_Touch,"FM_Touch_hook")
    register_clcmd("drop","dropped")
}
public dropped(id)
{
    justdropped[id]=true
    set_task(0.5,"notdropped",id)
}
public notdropped(id) justdropped[id]=false

public FM_Touch_hook(weaponbox,id)
{
    if(id && is_user_alive(id) && !is_user_bot(id) && pev_valid(weaponbox) && !justdropped[id])
    {
        static classname[64]
        pev(weaponbox,pev_classname,classname,63)
        if(equali(classname,"weaponbox"))
        {
            pev(weaponbox,pev_model,classname,63)
            if(equali(classname,WMODELI))
            {
                client_print_color(id, id, "dogru/true")
                justdropped[id]=true
                set_task(0.5,"notdropped",id)
                GiveWeaponByName(id,"laserm")
                if(pev_valid(weaponbox)) engfunc(EngFunc_RemoveEntity,weaponbox)
            }
        }
    }
}

give_item doesn't send drop command. But your GiveWeaponByName native send drop command.
Does this have anything to do with it? https://github.com/CodeGhosty/CSWM/b.../CSWM.cpp#L989

---
And I think you can add SlotID to weapons. Because u added hud to weapons.

I'm waiting next version. A very successful module.

quLeryuzz 12-25-2018 19:13

Re: Module: Counter-Strike Weapon Mod [1.7]
 
1 Attachment(s)
I wrote a pistol, that's name is Magic Wand. It has got unlimited ammo. When I writing I hope I didn't make a mistake.
I found v model on internet. I made p and w models with MilkShape.
I taken effects in codes from SweetMilitary.


All times are GMT -4. The time now is 04:19.

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