Category:Counter-Strike: Global Offensive Weapons: Difference between revisions
TheBlokker (talk | contribs) No edit summary |
m (→Manipulating Weapons: Fixed example with SetAmmoAmount -> SetReserveAmmoAmount.) |
||
Line 97: | Line 97: | ||
=== Manipulating Weapons === | === Manipulating Weapons === | ||
Weapons can be manipulated via [[I/O]], e.g. with {{ent|ent_fire}}, and even more using [[VScript]]. All weapon entities support the inputs <code>Kill, SetAmmoAmount <int>, SetReserveAmmoAmount <int>, ToggleCanBePickedUp</code>, for example the command <code>ent_fire weapon_ak47 kill</code> removes all AK-47s in the map. To give some inspiration, if <code>weapon</code> is the VScript handle of a weapon entity, we can use <code>weapon.Destroy()</code> to kill it, <code>weapon.GetOwner() == null</code> to check whether it is dropped (true) or carried by a player (false), <code>[[List of CS:GO Script Functions#Other|EntFireByHandle]](weapon, " | Weapons can be manipulated via [[I/O]], e.g. with {{ent|ent_fire}}, and even more using [[VScript]]. All weapon entities support the inputs <code>Kill, SetAmmoAmount <int>, SetReserveAmmoAmount <int>, ToggleCanBePickedUp</code>, for example the command <code>ent_fire weapon_ak47 kill</code> removes all AK-47s in the map. To give some inspiration, if <code>weapon</code> is the VScript handle of a weapon entity, we can use <code>weapon.Destroy()</code> to kill it, <code>weapon.GetOwner() == null</code> to check whether it is dropped (true) or carried by a player (false), <code>[[List of CS:GO Script Functions#Other|EntFireByHandle]](weapon, "SetReserveAmmoAmount", "0", 0, null, null)</code> to remove its reserve ammo and much more. | ||
{{note|When the weapon is killed that a player has deployed, their viewmodel will be broken until they deploy another weapon.}} | {{note|When the weapon is killed that a player has deployed, their viewmodel will be broken until they deploy another weapon.}} | ||
{{tip|Some weapon entities will have the same classname after being spawned even though they were created from different classnames. This makes it impossible to target only one of these weapon classes in the [[I/O]] system such as [[weapon_mp5sd|MP5-SD]] and [[weapon_mp7|MP7]] entities, because both will have the classname <code>"weapon_mp7"</code> after being spawned, so firing I/O events to <code>weapon_mp5sd</code> won't have any effect. This problem can be bypassed in VScript: If we find an <code>entity</code> with the classname <code>"weapon_mp7"</code>, we can identify whether it is actually an MP5-SD or an MP7 by checking whether <code>entity.GetModelName()</code> returns either <code>"models/weapons/w_smg_mp5sd_dropped.mdl"</code> or <code>"models/weapons/w_smg_mp7_dropped.mdl"</code>. Other entities whose classname changes on spawn are the [[weapon_usp_silencer|USP-S]], [[weapon_cz75a|CZ75-Auto]], [[weapon_revolver|R8 Revolver]], [[weapon_m4a1_silencer|M4A1-S]], [[item_cutters|Rescue Kit]], [[weapon_spanner|Wrench]], [[weapon_hammer|Hammer]], [[weapon_axe|Axe]] and all knives except [[weapon_knife]] and [[weapon_knifegg]].}} | {{tip|Some weapon entities will have the same classname after being spawned even though they were created from different classnames. This makes it impossible to target only one of these weapon classes in the [[I/O]] system such as [[weapon_mp5sd|MP5-SD]] and [[weapon_mp7|MP7]] entities, because both will have the classname <code>"weapon_mp7"</code> after being spawned, so firing I/O events to <code>weapon_mp5sd</code> won't have any effect. This problem can be bypassed in VScript: If we find an <code>entity</code> with the classname <code>"weapon_mp7"</code>, we can identify whether it is actually an MP5-SD or an MP7 by checking whether <code>entity.GetModelName()</code> returns either <code>"models/weapons/w_smg_mp5sd_dropped.mdl"</code> or <code>"models/weapons/w_smg_mp7_dropped.mdl"</code>. Other entities whose classname changes on spawn are the [[weapon_usp_silencer|USP-S]], [[weapon_cz75a|CZ75-Auto]], [[weapon_revolver|R8 Revolver]], [[weapon_m4a1_silencer|M4A1-S]], [[item_cutters|Rescue Kit]], [[weapon_spanner|Wrench]], [[weapon_hammer|Hammer]], [[weapon_axe|Axe]] and all knives except [[weapon_knife]] and [[weapon_knifegg]].}} |
Revision as of 19:07, 19 June 2022
This listing is for weapons featured in Template:Game name.
Buy Menu
Pistol | SMG | Heavy | Rifle | Equipment | Grenade |
---|---|---|---|---|---|
Other
Knives | Miscellaneous | ![]() |
![]() |
![]() |
---|---|---|---|---|
|
Giving Weapons
To give yourself a weapon, you can use the cheat command give <entityname>
, which should spawn a specified weapon inside the executing player, for example give weapon_awp
. Knives and Danger Zone melees might instantly be removed by the game when they would spawn; To overcome this, one can use the command sequence give <entityname>; ent_fire <entityname> addoutput "classname weapon_knifegg"
(in one line!) so that the entity "becomes" an entity that is not removed by the game in the same tick. Note that some weapons have a different classname after being given, e.g. give weapon_axe; ent_fire weapon_melee addoutput "classname weapon_knifegg"
.
Map driven item giving can be done with game_player_equip. To equip weapons using VScript, a game_player_equip entity can be created, used and removed.
Manipulating Weapons
Weapons can be manipulated via I/O, e.g. with ent_fire, and even more using VScript. All weapon entities support the inputs Kill, SetAmmoAmount <int>, SetReserveAmmoAmount <int>, ToggleCanBePickedUp
, for example the command ent_fire weapon_ak47 kill
removes all AK-47s in the map. To give some inspiration, if weapon
is the VScript handle of a weapon entity, we can use weapon.Destroy()
to kill it, weapon.GetOwner() == null
to check whether it is dropped (true) or carried by a player (false), EntFireByHandle(weapon, "SetReserveAmmoAmount", "0", 0, null, null)
to remove its reserve ammo and much more.


"weapon_mp7"
after being spawned, so firing I/O events to weapon_mp5sd
won't have any effect. This problem can be bypassed in VScript: If we find an entity
with the classname "weapon_mp7"
, we can identify whether it is actually an MP5-SD or an MP7 by checking whether entity.GetModelName()
returns either "models/weapons/w_smg_mp5sd_dropped.mdl"
or "models/weapons/w_smg_mp7_dropped.mdl"
. Other entities whose classname changes on spawn are the USP-S, CZ75-Auto, R8 Revolver, M4A1-S, Rescue Kit, Wrench, Hammer, Axe and all knives except weapon_knife and weapon_knifegg.Pages in category "Counter-Strike: Global Offensive Weapons"
The following 9 pages are in this category, out of 9 total.