manve1 Posted January 2, 2013 Posted January 2, 2013 How can i apply my own crosshair so when i aim a gun i see my crosshair?
Cadu12 Posted January 2, 2013 Posted January 2, 2013 Please do not double-post some hours. You must wait anyone to post.
manve1 Posted January 2, 2013 Author Posted January 2, 2013 Please do not double-post some hours. You must wait anyone to post. I know that, but people don't offten look at the middle or bottom posts, so i just moved it up.
manve1 Posted January 2, 2013 Author Posted January 2, 2013 I got a problem as it didn't apply the crosshair to any weapon LUA: addEventHandler( "onClientResourceStart", resourceRoot, function() local texture = dxCreateTexture ("hud/aimer.png") local shader = dxCreateShader ( "hud/shader.fx" ) dxSetShaderValue ( shader, "gTexture", texture ) engineApplyShaderToWorldTexture ( shader, "sitem16") end ) SHADER: texture gTexture; technique TexReplace { pass P0 { Texture[0] = gTexture; } } And i need one for weapons like deagle, m4 and a sniper, but for sniper a different crosshair
manawydan Posted January 2, 2013 Posted January 2, 2013 has a resource in the community. https://community.multitheftauto.com/ind ... ls&id=6210
manve1 Posted January 2, 2013 Author Posted January 2, 2013 but how do i use that resource as there is no example, not even a picture
Blaawee Posted January 2, 2013 Posted January 2, 2013 this resource has an exports function's https://community.multitheftauto.com/ind ... ls&id=6210 exports.crosshairreplace:register(weaponid, newcrosshairpath)Sets the new crosshair for 'weaponid'. 'newcrosshairpath' should be a path to an image file exports.crosshairreplace:unregister(weaponid) Restores the default crosshair for 'weaponid' try something like this : client: addEventHandler( "onClientResourceStart", resourceRoot, function ( startedRes ) exports.crosshairreplace:register( 34, "sniperCH.png" ) end )
manve1 Posted January 2, 2013 Author Posted January 2, 2013 Last thing: How can i make it for a sniper rifle not other weapons?
Blaawee Posted January 2, 2013 Posted January 2, 2013 exports.crosshairreplace:register( weaponid, newcrosshairpath )Sets the new crosshair for 'weaponid'. 'newcrosshairpath' should be a path to an image file exports.crosshairreplace:register( 34, crossHairPath ) https://wiki.multitheftauto.com/wiki/Weapon
manve1 Posted January 2, 2013 Author Posted January 2, 2013 It still looks original although the pic is a lot different
Blaawee Posted January 2, 2013 Posted January 2, 2013 i think you should edit the script to : * EDIT Crosshair = { crosshairs = {}; shader = {}; default = dxCreateTexture("siteM16.png"); register = function(weaponid, crosshairpath) if not crosshairpath:find(":") then crosshairpath = (":%s/%s"):format(getResourceName(sourceResource), crosshairpath) end assert(fileExists(crosshairpath), "Invalid File for Crosshair.register") if Crosshair.crosshairs[weaponid] then destroyElement(Crosshair.crosshairs[weaponid]) end Crosshair.crosshairs[weaponid] = dxCreateTexture(crosshairpath) end, unregister = function(weaponid) if Crosshair.crosshairs[weaponid] then destroyElement(Crosshair.crosshairs[weaponid]) end Crosshair.crosshairs[weaponid] = nil end, init = function() Crosshair.shader = dxCreateShader("texreplace.fx") assert(Crosshair.shader, "Could not create Crosshair Replacement Shader") engineApplyShaderToWorldTexture(Crosshair.shader, "siteM16") dxSetShaderValue(Crosshair.shader, "gTexture", Crosshair.default) addEventHandler("onClientPlayerWeaponSwitch", localPlayer, Crosshair.weaponSwitch) end, weaponSwitch = function( prev, now ) weapon = getPedWeapon( localPlayer, now ) if weapon == 34 then dxSetShaderValue( Crosshair.shader, "gTexture", Crosshair.crosshairs[weapon] ) else dxSetShaderValue( Crosshair.shader, "gTexture", Crosshair.default ) end end } Crosshair.init() -- Exports register = Crosshair.register unregister = Crosshair.unregister
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