Urby Posted May 17, 2015 Share Posted May 17, 2015 My mind is tearing itself apart I know it can be done but could some one throw me a bone and point out the statement I need to check for a specific mod on the players primary hand weapon. By mod I mean attachment (Slings, chokes and the like.) Link to comment Share on other sites More sharing options...
ethanwdp Posted May 17, 2015 Share Posted May 17, 2015 When in doubt, download JD (or any Java class decompiler) and check the code for functions you can call.In this particular case, zombie/inventory/types/HandWeapon.class would come in handy. If it declares a function there, you can use it.So let's say you wanted to check for a scope on the player's currently equipped item. You could use something like... if getPlayer():getPrimaryHandItem():getScope() then print("Successfully retrieved "..getPlayer():getPrimaryHandItem():getScope():getName())end It's like a chain, if getPlayer() returns true then it goes on to call getPrimaryHandItem(), and if that returns true then it calls getScope, etc etc.Usually, if you want to be able to use a classes functions, you have to get it first. Usually you just plonk get before the class name, so say you're trying to access a VirtualZombieManager function, so you use getVirtualZombieManager():getBlahBlah(). But let's say that you wanted to check for, say, an 8x scope only. You could use something like... if getPlayer():getPrimaryHandItem():getScope():getName() == "x8 Scope" then print("Successfully retrieved "..getPlayer():getPrimaryHandItem():getScope():getName())end getName() obtains the name of the item in a string. AFAIK, it is case sensitive. Or, if you want it to print only when there's a scope and a stock of some sort, then you could do... if getPlayer():getPrimaryHandItem():getScope() and getPlayer():getPrimaryHandItem():getStock() then print("Successfully retrieved "..getPlayer():getPrimaryHandItem():getScope():getName().." And "..getPlayer():getPrimaryHandItem():getStock():getName()) end And, if you wanted to make that even shorter and easier, you could just save the first part of the chain (as in, getPlayer():getPrimaryHandItem()) into a function.So, for example... local weapon = getPlayer():getPrimaryHandItem() Because it's not technically a function, there's no need to use brackets or anything, just call it like so... local weapon = getPlayer():getPrimaryHandItem() if weapon:getScope() and weapon:getStock() then print("Successfully retrieved "..weapon:getScope():getName().." And "..weapon:getStock():getName())end And so on.If there's anything I left unclear, feel free to ask. Link to comment Share on other sites More sharing options...
Urby Posted May 18, 2015 Author Share Posted May 18, 2015 You are my hero, thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now