Grabbing Current Offhand...
-
Similar to my "Grabbing A Weapon's Camo..." post, i want to be able to return your current TACTICAL grenade.
getcurrentoffhand()
grabs your lethal, and i believe your tactical but only if you don't have any lethals. This isn't what i want, i want to be able to grab tactical grenades from your player.getsecondaryoffhandclass()
Certainly sounds like what i'm looking for, but it returns "smoke" and that's it. I can't find this function anywhere in the dumps either, making it built-in so i'm unable to see the source code for it. Dead end here.I have thought of doing a check using
self hasweapon("weapon_name");
and then using that, but i haven't tested it. You could do this with all of the equipment and it might work. I'm unsure.Something like this probably.
if(self hasweapon("proximity_grenade_mp") || self hasweapon("tactical_insertion_mp") //Etc etc
There also may be a way to do this by using
GetWeaponsList()
.I.E:
foreach( weapon in self GetWeaponsList()) { if( issubstr( weapon, "proximity" ) || issubstr( weapon, "insertion" ) || issubstr( weapon, "sensor" ) || issubstr( weapon, "hack" ) || issubstr( weapon, "trophy" ) || issubstr( weapon, "emp" ) || issubstr( weapon, "willy" ) || issubstr( weapon, "flash" ) || issubstr( weapon, "concussion" ) ) { self.tac = weapon; } }
I have tested this already and it didn't work out. Perhaps i have the wrong idea here. Thank you for any help you can offer me. I also apologize for the rapid threads, but i think they all needed their own space. If not, any mods can feel free to take all three of my threads and put them together. I don't mind. It's 3:21AM and i gotta get to sleep. Night y'all. Thank you again.
-
The class of tacticals is the same as the class of lethals, namely weapon_grenade. Could you specify your use case as there's one or two different trains of thought with approach.
-
birchy said in Grabbing Current Offhand...:
The class of tacticals is the same as the class of lethals, namely weapon_grenade. Could you specify your use case as there's one or two different trains of thought with approach.
I'm trying to develop a function to refill grenades, both lethal and tactical to their original amounts from when you spawned.
Edit: I found a solution to this issue. Ill post it now. This script seems to work just fine. Be sure to include maps/mp/gametypes/_weapons.
ReloadmyfuckinggrenadesNOW() { primary_weapons = self getweaponslistprimaries(); offhand_weapons_and_alts = array_exclude( self getweaponslist( 1 ), primary_weapons ); arrayremovevalue( offhand_weapons_and_alts, "knife_mp" ); offhand_weapons_and_alts = array_reverse( offhand_weapons_and_alts ); self playsound( "fly_equipment_pickup_npc" ); self playlocalsound( "fly_equipment_pickup_plr" ); loadout_primary = self loadout_get_offhand_weapon( "primarygrenade" ); loadout_primary_count = self loadout_get_offhand_count( "primarygrenadecount" ); loadout_secondary = self loadout_get_offhand_weapon( "specialgrenade" ); loadout_secondary_count = self loadout_get_offhand_count( "specialgrenadeCount" ); i = 0; while ( i < offhand_weapons_and_alts.size ) { weapon = offhand_weapons_and_alts[ i ]; if ( maps\mp\gametypes\_weapon_utils::ishackweapon( weapon ) ) { i++; continue; } switch ( weapon ) { case "satchel_charge_mp": if ( self maps/mp/gametypes/_weaponobjects::anyobjectsinworld( weapon ) ) { break; } case "bouncingbetty_mp": case "claymore_mp": case "frag_grenade_mp": case "hatchet_mp": case "sticky_grenade_mp": if ( isDefined( self.grenadetypeprimarycount ) && self.grenadetypeprimarycount < 1 ) { break; } case "concussion_grenade_mp": case "emp_grenade_mp": case "flash_grenade_mp": case "nightingale_mp": case "pda_hack_mp": case "proximity_grenade_mp": case "sensor_grenade_mp": case "tabun_gas_mp": case "trophy_system_mp": case "willy_pete_mp": if ( isDefined( self.grenadetypesecondarycount ) && self.grenadetypesecondarycount < 1 ) { break; } maxammo = weaponmaxammo( weapon ); stock = self getweaponammostock( weapon ); if ( weapon == loadout_primary ) { maxammo = loadout_primary_count; } else if ( weapon == loadout_secondary ) { maxammo = loadout_secondary_count; } if ( stock < maxammo ) { ammo = stock + 4; if ( ammo > maxammo ) { ammo = maxammo; } self setweaponammostock( weapon, ammo ); } break; } i++; } }
Have fun! This post may be closed or marked as answered.