• Custom Hold Types refuses to work [Read More]
    2 replies, posted
Hello, and thank you for reading Recently ive been trying to make a custom holdtype function from the weapon_base sh_anim file The only problem seems to be that the function refuses to use the animation index i provided When I test it in game, I get a mixed result for the size of the animation index, and it usually just defaults to normal I even tried storing the index as a SWEP value, same shit I cant think of anything else I can do! Heres the Code Segments for my sh_anim.lua: Top of the file def. [code] local ActIndex = {} ActIndex[ "pistol" ] = ACT_HL2MP_IDLE_PISTOL -- NOT PURE PISTOL ActIndex[ "onehand" ] = ACT_HL2MP_IDLE_PISTOL -- PURE HL2/DOD PISTOL ActIndex[ "smg" ] = ACT_HL2MP_IDLE_SMG1 ActIndex[ "grenade" ] = ACT_HL2MP_IDLE_GRENADE ActIndex[ "ar2" ] = ACT_HL2MP_IDLE_AR2 ActIndex[ "shotgun" ] = ACT_HL2MP_IDLE_SHOTGUN ActIndex[ "rpg" ] = ACT_HL2MP_IDLE_RPG ActIndex[ "physgun" ] = ACT_HL2MP_IDLE_PHYSGUN ActIndex[ "crossbow" ] = ACT_HL2MP_IDLE_CROSSBOW ActIndex[ "melee" ] = ACT_HL2MP_IDLE_MELEE ActIndex[ "slam" ] = ACT_HL2MP_IDLE_SLAM ActIndex[ "normal" ] = ACT_HL2MP_IDLE ActIndex[ "fist" ] = ACT_HL2MP_IDLE_FIST ActIndex[ "melee2" ] = ACT_HL2MP_IDLE_MELEE2 ActIndex[ "passive" ] = ACT_HL2MP_IDLE_PASSIVE ActIndex[ "knife" ] = ACT_HL2MP_IDLE_KNIFE ActIndex[ "duel" ] = ACT_HL2MP_IDLE_DUEL ActIndex[ "dual" ] = ACT_HL2MP_IDLE_DUEL ActIndex[ "camera" ] = ACT_HL2MP_IDLE_CAMERA ActIndex[ "magic" ] = ACT_HL2MP_IDLE_MAGIC ActIndex[ "revolver" ] = ACT_HL2MP_IDLE_REVOLVER ActIndex[ "357" ] = ACT_HL2MP_IDLE_REVOLVER -- Add alias ActIndex["rifle"] = ACT_HL2MP_IDLE_AR2 ActIndex["grip"] = ACT_HL2MP_IDLE_SMG1 ActIndex["mg"] = ACT_HL2MP_IDLE_RPG ActIndex["hipfire1"] = ACT_HL2MP_IDLE_CROSSBOW ActIndex["hipfire2"] = ACT_HL2MP_IDLE_SHOTGUN ActIndex["magnum"] = ACT_HL2MP_IDLE_REVOLVER ActIndex["revolver"] = ACT_HL2MP_IDLE_REVOLVER -- Add Special Dynamic Holdtype ActIndex["pistol_police"] = ACT_HL2MP_IDLE_REVOLVER ActIndex["csspistol"] = ACT_HL2MP_IDLE_REVOLVER ActIndex["autopistol"] = ACT_HL2MP_IDLE_PISTOL -- Add Keys for Automation ActIndex["ducking_rifle_aim"] = ACT_HL2MP_IDLE_AR2 ActIndex["ducking_rifle_hipfire"] = ACT_HL2MP_IDLE_CROSSBOW ActIndex["ducking_handgun_hipfire"] = ACT_HL2MP_IDLE_REVOLVER ActIndex[ "ducking_handgun_aim" ] = ACT_HL2MP_IDLE_PISTOL ActIndex[ "jumping_handgun_hipfire" ] = ACT_HL2MP_IDLE_PISTOL ActIndex[ "jumping_handgun_aim"] = ACT_HL2MP_IDLE_REVOLVER ActIndex[ "grenade_idle" ] = ACT_HL2MP_IDLE_SLAM SWEP.HoldIndex = ActIndex [/code] CheckActIndex loops through either a provided table or self.HoldIndex, printing the Key and Value Just some debuging stuff function SetWeaponHoldType [code] function SWEP:SetWeaponHoldType(t) if ( (game.SinglePlayer() && SERVER) or ( !game.SinglePlayer() && SERVER ) ) then ErrorNoHalt("Testing who can see me!") ErrorNoHalt("Testing who can see me!") ErrorNoHalt("Testing who can see me!") ErrorNoHalt("Testing who can see me!") end if not t then self:Talk("?Wheres the Key? <<<<<<<<<<<<<") t = "357" end --local ActIndex = self.HoldIndex local size = table.Count(ActIndex) local str1 = "HoldType Index Size: " .. tostring(size) local str2 = ActIndex[3] local index = nil if not (SERVER) then self:Talk(str1) end --[[ for i = 0, size, 1 do if not (SERVER) then str2 = "#" .. i .. " = " .. tostring(ActIndex[i]) self:Talk(str2) end end --]] --self:CheckActIndex() t = string.lower( t ) local keyt = table.GetKeys(ActIndex) self:CheckActIndex(keyt) index = ActIndex[ t ] if (index == nil) then Msg("SWEP:SetWeaponHoldType ~~ ActIndex[ \""..t.."\" ] isn't set! ActIndex has a dim of" .. tostring(#ActIndex) .."\n") --PrintTable( table.GetKeys( ActIndex ) ) --PrintTable( ActIndex ) self:Beep("BAD INDEX @ SH_ANIM ~ " .. tostring(t)) if ( t == "csspistol" ) then index = 1663 else index = ActIndex[tostring(t)] self:Beep("Elsing this shit") end end index = ACT_HL2MP_IDLE_DUEL self.ActivityTranslate = {} self.ActivityTranslate [ACT_HL2MP_IDLE] = index self.ActivityTranslate [ACT_HL2MP_WALK] = index + 1 self.ActivityTranslate [ACT_HL2MP_RUN] = index + 2 self.ActivityTranslate [ACT_HL2MP_IDLE_CROUCH] = index + 3 self.ActivityTranslate [ACT_HL2MP_WALK_CROUCH] = index + 4 -- ACT_HL2MP_WALK_CROUCH_PISTOL self.ActivityTranslate [ACT_HL2MP_GESTURE_RANGE_ATTACK] = index + 5 self.ActivityTranslate [ACT_HL2MP_GESTURE_RELOAD] = index + 6 self.ActivityTranslate [ACT_HL2MP_JUMP] = index + 7 self.ActivityTranslate [ACT_RANGE_ATTACK1] = index + 8 -- "normal" jump animation doesn't exist if t == "normal" then self.ActivityTranslate [ ACT_MP_JUMP ] = ACT_HL2MP_JUMP_SLAM end -- create schemes if t == "pistol_police" or t == "csspistol" then self.ActivityTranslate [ACT_HL2MP_WALK_CROUCH] = ACT_HL2MP_WALK_CROUCH_PISTOL self.ActivityTranslate [ACT_HL2MP_JUMP] = ACT_HL2MP_WALK_CROUCH_PISTOL elseif t == "pistol" then self.ActivityTranslate [ACT_HL2MP_GESTURE_RELOAD] = ACT_HL2MP_GESTURE_RELOAD_PISTOL end -- NPC SHIT if self.Owner:IsNPC() then self:SetupWeaponHoldTypeForAI(t) MsgAll("Setting NPC Hold Type to:" .. t) end end [/code] Here is the output from console, for the Mac10, which has the holdtype "autopistol" [code] HoldType Index Size: 38 Key: 1 |V: physgun Key: 2 |V: ducking_rifle_aim Key: 3 |V: 357 Key: 4 |V: melee Key: 5 |V: ducking_rifle_hipfire Key: 6 |V: smg Key: 7 |V: rifle Key: 8 |V: revolver Key: 9 |V: fist Key: 10 |V: crossbow Key: 11 |V: magnum Key: 12 |V: magic Key: 13 |V: hipfire1 Key: 14 |V: jumping_handgun_aim Key: 15 |V: dual Key: 16 |V: pistol Key: 17 |V: csspistol Key: 18 |V: hipfire2 Key: 19 |V: grenade_idle Key: 20 |V: shotgun Key: 21 |V: knife Key: 22 |V: jumping_handgun_hipfire Key: 23 |V: ducking_handgun_aim Key: 24 |V: ducking_handgun_hipfire Key: 25 |V: onehand Key: 26 |V: autopistol Key: 27 |V: normal Key: 28 |V: grip Key: 29 |V: grenade Key: 30 |V: passive Key: 31 |V: camera Key: 32 |V: ar2 Key: 33 |V: duel Key: 34 |V: mg Key: 35 |V: melee2 Key: 36 |V: rpg Key: 37 |V: slam Key: 38 |V: pistol_police SWEP:SetWeaponHoldType ~~ ActIndex[ "autopistol" ] isn't set! ActIndex has a dim of0 BAD INDEX @ SH_ANIM ~ autopistol !BEEP! <-- Custom function, dont worry Elsing this shit [/code] For weapons like the AWP, which has a custom hold type "sniper", there also is no error Any help is greatly appreciated [i](also i think i accidently reported my own post x,x)[\i]
[code] t = string.lower( t ) local keyt = table.GetKeys(ActIndex) self:CheckActIndex(keyt) index = keyt[ t ][/code] should be [code] t = string.lower( t ) local keyt = table.GetKeys(ActIndex) self:CheckActIndex(keyt) index = ActIndex[ t ][/code]
[QUOTE=Robotboy655;44721572][code] t = string.lower( t ) local keyt = table.GetKeys(ActIndex) self:CheckActIndex(keyt) index = keyt[ t ][/code] should be [code] t = string.lower( t ) local keyt = table.GetKeys(ActIndex) self:CheckActIndex(keyt) index = ActIndex[ t ][/code][/QUOTE] Thanks, however I actually wrote that peice of the code today for debuging, its been a persistent problem, for weeks now Good Eye tho, The code has been updated and retested... same issues
Sorry, you need to Log In to post a reply to this thread.