InVision Posted August 9, 2013 Share Posted August 9, 2013 NoAimerWeaponIDs = { [28] = true, [32] = true, [29] = true, [22] = true, [23] = true, [24] = true, } function disableAimer( prevSlot, newSlot ) if NoAimerWeaponIDs[getPedWeapon(getLocalPlayer(), newSlot)] then showPlayerHudComponent("crosshair", false) else showPlayerHudComponent("crosshair", true) end end addEventHandler("onClientPlayerWeaponSwitch", getRootElement(), disableAimer) addCommandHandler ( "togtarget", disableAimer ) I'm trying to make a script that will allow you to disable and enable your crosshair, but the command handler is not working what am I doing wrong? Link to comment
Castillo Posted August 10, 2013 Share Posted August 10, 2013 You are writing the new slot along with the command, right? also, the "newSlot" result will be always a string, convert it to a number. Link to comment
InVision Posted August 10, 2013 Author Share Posted August 10, 2013 You are writing the new slot along with the command, right? also, the "newSlot" result will be always a string, convert it to a number. Could you give me an example? And I want the command to make permanent changes on the event whether there's a transition to a new, or previous slot. Link to comment
Castillo Posted August 10, 2013 Share Posted August 10, 2013 What exactly are you trying to achieve? Link to comment
InVision Posted August 10, 2013 Author Share Posted August 10, 2013 (edited) What exactly are you trying to achieve? I'm trying to make it so a player can enable/disable their crosshair NoAimerWeaponIDs = { [28] = true, [32] = true, [29] = true, [22] = true, [23] = true, [24] = true, } function disableAimer( prevSlot, newSlot ) if NoAimerWeaponIDs[getPedWeapon(getLocalPlayer(), newSlot)] then showPlayerHudComponent("crosshair", false) end end addEventHandler("onClientPlayerWeaponSwitch", getRootElement(), disableAimer) function enableAimer( prevSlot, newSlot ) if NoAimerWeaponIDs[getPedWeapon(getLocalPlayer(), newSlot)] then showPlayerHudComponent("crosshair", true) end end addEventHandler("onClientPlayerWeaponSwitch", getRootElement(), enableAimer) addCommandHandler ( "togtarget", disableAimer ) I changed the code to this, when I have my Deagle out, I execute /togtarget, and the crosshair will dissapear, I'll then do /togtarget in an attempt to enable the crosshair, but it does nothing at that time, I'll then switch to another weapon, and back to my deagle, and the crosshair will be enabled. But I just want to disable / enable the crosshair without having to transition through weapons "I know it has something to do with the EventHandler, and possibly the New Slot / Previous Slot when it tries to collect the whether you have a weapon with the No Aimer Weapon IDs Edited August 10, 2013 by Guest Link to comment
Castillo Posted August 10, 2013 Share Posted August 10, 2013 You want to let the player choose which weapons will have crosshair? Link to comment
InVision Posted August 10, 2013 Author Share Posted August 10, 2013 You want to let the player choose which weapons will have crosshair? NoAimerWeaponIDs = { [28] = true, [32] = true, [29] = true, [22] = true, [23] = true, [24] = true, } No, I have listed the weapon ID's above in which they can disable... I want them to be able to enable / disable their crosshair without having to switch weapons after executing the command to get the function to work. Link to comment
Castillo Posted August 10, 2013 Share Posted August 10, 2013 NoAimerWeaponIDs = { [28] = true, [32] = true, [29] = true, [22] = true, [23] = true, [24] = true, } function crosshair ( ) if NoAimerWeaponIDs [ getPedWeapon ( localPlayer ) ] then showPlayerHudComponent ( "crosshair", false ) else showPlayerHudComponent ( "crosshair", true ) end end addEventHandler ( "onClientPlayerWeaponSwitch", getRootElement(), crosshair ) addCommandHandler ( "togtarget", crosshair ) Link to comment
InVision Posted August 10, 2013 Author Share Posted August 10, 2013 NoAimerWeaponIDs = { [28] = true, [32] = true, [29] = true, [22] = true, [23] = true, [24] = true, } function crosshair ( ) if NoAimerWeaponIDs [ getPedWeapon ( localPlayer ) ] then showPlayerHudComponent ( "crosshair", false ) else showPlayerHudComponent ( "crosshair", true ) end end addEventHandler ( "onClientPlayerWeaponSwitch", getRootElement(), crosshair ) addCommandHandler ( "togtarget", crosshair ) Your code didn't work But I changed my code some, and got it to work, although I would like to disable / enable it with just one command... NoAimerWeaponIDs = { [28] = true, [32] = true, [29] = true, [22] = true, [23] = true, [24] = true, } function disableAimer( prevSlot, newSlot ) if NoAimerWeaponIDs[getPedWeapon(getLocalPlayer(), newSlot)] then showPlayerHudComponent("crosshair", true) end end addEventHandler("onClientPlayerJoin", getRootElement(), disableAimer) addCommandHandler ( "targeton", disableAimer ) function enableAimer( prevSlot, newSlot ) if NoAimerWeaponIDs[getPedWeapon(getLocalPlayer(), newSlot)] then showPlayerHudComponent("crosshair", false) end end addEventHandler("onClientPlayerJoin", getRootElement(), enableAimer) addCommandHandler ( "targetoff", enableAimer ) Link to comment
Castillo Posted August 10, 2013 Share Posted August 10, 2013 I don't understand now, you want to disable the crosshair for the weapons in that table or enable it? Link to comment
InVision Posted August 10, 2013 Author Share Posted August 10, 2013 (edited) I don't understand now, you want to disable the crosshair for the weapons in that table or enable it? I want people to be able to disable the crosshair and enable it all under ONE command. Right now I've only managed to be able to do that under TWO SEPARATE commands. ED: I am new to scripting, so my style / format may be different than other peoples, so please excuse me. Think of it as a clapping light, you clap the light turns on, you clap again the light turns off clap = command light = crosshair Edited August 10, 2013 by Guest Link to comment
Castillo Posted August 10, 2013 Share Posted August 10, 2013 NoAimerWeaponIDs = { [28] = true, [32] = true, [29] = true, [22] = true, [23] = true, [24] = true, } function crosshair ( ) if NoAimerWeaponIDs [ getPedWeapon ( localPlayer ) ] then showPlayerHudComponent ( "crosshair", not isPlayerHudComponentVisible ( "crosshair" ) ) end end addCommandHandler ( "togtarget", crosshair ) Link to comment
InVision Posted August 10, 2013 Author Share Posted August 10, 2013 NoAimerWeaponIDs = { [28] = true, [32] = true, [29] = true, [22] = true, [23] = true, [24] = true, } function crosshair ( ) if NoAimerWeaponIDs [ getPedWeapon ( localPlayer ) ] then showPlayerHudComponent ( "crosshair", not isPlayerHudComponentVisible ( "crosshair" ) ) end end addCommandHandler ( "togtarget", crosshair ) Worked perfectly, thank you so much, you saved me a lot of headaches! Link to comment
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