Author Topic: Switching crosshairs through binded keys  (Read 1026 times)

I'm attempting to make this work, but I'm having some trouble.  The options show up in the "Controls" menu, but when I press the binded keys, the crosshiar does not change from the default file.  Here is the code frim the "client" file:

Code: [Select]
if (!$CrossSwitch)
{
$remapDivision[$remapCount] = "Crosshairs";
$remapName[$remapCount] = "Default";
$remapCmd[$remapCount] = "Default_Switch";
$remapCount++;
$remapName[$remapCount] = "GunAim";
$remapCmd[$remapCount] = "GunAim_Switch";
$remapCount++;
$remapName[$remapCount] = "GunAim_RedDot";
$remapCmd[$remapCount] = "GunAim_RedDot_Switch";
$remapCount++;
$remapName[$remapCount] = "LargeScope";
$remapCmd[$remapCount] = "LargeScope_Switch";
$remapCount++;
$MyGuiBinds = 1;
}

function Default_Switch()
{
Crosshair.bitmap = "Add-ons/Script_SwitchCrosshairs/Default/crossHair";
}

function GunAim_Switch()
{
Crosshair.bitmap = "Add-ons/Script_SwitchCrosshairs/GunAim/crossHair";
}

function GunAim_RedDot_Switch()
{
Crosshair.bitmap = "Add-ons/Script_SwitchCrosshairs/GunAim_RedDot/crossHair";
}

function LargeScope_Switch()
{
Crosshair.bitmap = "Add-ons/Script_SwitchCrosshairs/LargeScope/crossHair";
}
« Last Edit: October 27, 2008, 09:36:10 PM by Quantum »

Well, isn't it setBitmap?

As in:
Code: [Select]
crosshair.setBitmap("Add-ons/Script_SwitchCrosshairs/Default/crossHair");

You would need to use setBitmap if you're in the middle of gameplay.
I forgot to mention that.


if (!$CrossSwitch)
$MyGuiBinds = 1;

This doesn't really have to do with switching the crosshairs themselves, but shouldn't these be the same variable?

Yes, they should. However that only matters if you're going to be executing this mod more than once.

It still isn't workin.  Here is the current code:

Code: [Select]
if (!$CrossSwitch)
{
$remapDivision[$remapCount] = "Crosshairs";
$remapName[$remapCount] = "Default";
$remapCmd[$remapCount] = "Default_Switch";
$remapCount++;
$remapName[$remapCount] = "GunAim";
$remapCmd[$remapCount] = "GunAim_Switch";
$remapCount++;
$remapName[$remapCount] = "GunAim_RedDot";
$remapCmd[$remapCount] = "GunAim_RedDot_Switch";
$remapCount++;
$remapName[$remapCount] = "LargeScope";
$remapCmd[$remapCount] = "LargeScope_Switch";
$remapCount++;
$CrossSwitch = 1;
}

function Default_Switch()
{
Crosshair.setBitmap = "Add-ons/Script_SwitchCrosshairs/Default/crossHair";
}

function GunAim_Switch()
{
Crosshair.setBitmap = "Add-ons/Script_SwitchCrosshairs/GunAim/crossHair";
}

function GunAim_RedDot_Switch()
{
Crosshair.setBitmap = "Add-ons/Script_SwitchCrosshairs/GunAim_RedDot/crossHair";
}

function LargeScope_Switch()
{
Crosshair.setBitmap = "Add-ons/Script_SwitchCrosshairs/LargeScope/crossHair";
}

Should the functions be like this?

Code: [Select]
function LargeScope_Switch(%val)
{
     if(%val)
          Crosshair.setBitmap = "Add-ons/Script_SwitchCrosshairs/LargeScope/crossHair";
}

I had to do that for my client.cs to work, but I'm a noob at scripting so I don't know why.

You're using setBitmap incorrectly. It should be:

Crosshair.setBitmap("Add-Ons/BlahBlah");

Well, isn't it setBitmap?

As in:
Code: [Select]
crosshair.setBitmap("Add-ons/Script_SwitchCrosshairs/Default/crossHair");

It's working perfectly now.  Thank you!