GetWeapon
str GetWeapon (void)
Usage
Retrieves the class name of the weapon currently equipped by the script activator. As only the player can have weapons, the function returns meaningful results only if the activator is a player.
Return value
Returns the class name of the weapon currently equipped by the script activator, as a string, if the activator is a player. If not, the function returns "None".
Examples
This script gives the player a little bit of ammunition depending on the currently equipped weapon.
script "AmmoProvider" (void) { str weapon = GetWeapon(); if (StrIcmp(weapon, "Pistol") == 0 || StrIcmp(weapon, "Chaingun") == 0) { GiveInventory("Clip", 10); Log(s:"Received a clip."); } else if (StrIcmp(weapon, "Shotgun") == 0 || StrIcmp(weapon, "SuperShotgun") == 0) { GiveInventory("Shell", 4); Log(s:"Received 4 shotgun shells."); } else if (StrIcmp(weapon, "RocketLauncher") == 0) { GiveInventory("RocketAmmo", 1); Log(s:"Received a rocket."); } else if (StrIcmp(weapon, "PlasmaRifle") == 0 || StrIcmp(weapon, "BFG9000") == 0) { GiveInventory("Cell", 20); Log(s:"Received an energy cell."); } else Print(s:"A firearm needs to be equipped first to receive ammo for it"); }
This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.