Results 1 to 3 of 3

Thread: Switching between vehicle weapons, online.

  1. #1
    Azarael
    Guest

    Switching between vehicle weapons, online.

    I'll admit first-hand that my experience with coding is limited. I currently have a vehicle descended from ONSAttackCraft which switches between weapons with altfire. This all works fine offline, but doesn't work online. For the second weapon (which is a lift of the Goliath's machinegun) tracers are spawned along with the lasers of the first weapon in the array. The other weapons, which fire projectiles, spawn relevant muzzle flashes at the correct intervals...while firing lasers. The localised messages saying which weapon is active work fine, and the charging bar appears and disappears correctly. Using VehicleFire instead of AltFire causes no projectiles to be spawned and no traces for damage to be done, suggesting that the server isn't registering a weapon at all.

    Code:
    function AltFire(optional float F)
    {
    CurrentWeapon++;
    if(CurrentWeapon > 5){
    CurrentWeapon = 0;
    }
    SetActiveWeapon(CurrentWeapon);
    if(CurrentWeapon == 0)
    bShowChargingBar=True;
    else bShowChargingBar=False;
    if (PlayerController(Controller) != None){
    PlayerController(Controller).ReceiveLocalizedMessage(class'VenomSwitchMessage', CurrentWeapon);
    }
    }
    I'm vaguely aware of the concept of replication, but I'm not sure what exactly I need to replicate. Looking at the Leviathan, which switches weapons when it deploys and undeploys, I can't see any replication for weapon changing, and even removing the CurrentWeapon variable and replacing it with, for example, "1" has no effect, so I doubt I need to replicate that variable. Edit: ActiveWeapon is replicated in ONSVehicle...

    I may be doing something extremely stupid and/or hackish here, so try not to lay into me if that's the case. :P

    Thanks in advance for any help.

    Edit: Fixed.

  2. #2
    GreatEmerald
    Guest
    What kind of a variable is CurrentWeapon and where is it defined?

  3. #3
    Azarael
    Guest
    CurrentWeapon is a global int. It's always worked, since I had logging code to check that the server and the client's version of CurrentWeapon was the same when doing some replication.

    It works now, using VehicleFire() instead of AltFire(), doing the code above if bWasAltFire, else bWeaponIsFiring = true.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •