Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: Unknown command give

  1. #21

    Default


    spring:
    if (!self || self.dmteam == "spectator" || self.mef_spectator == 1) {
    end
    }
    if (self.raising == 1) {
    end
    }
    self.raising = 1

    local.weaponName = "weapon" + self.entnum

    self weaponcommand mainhand targetname (local.weaponName)

    local.weapon = $(local.weaponName)

    if (local.weapon){
    local.weapon.targetname = ""

    switch (local.weapon.model) {
    case "models/weapons/bazooka.tik":
    case "models/weapons/colt45.tik":
    case "models/weapons/m2frag_grenade.tik":
    case "models/weapons/RDG-1_Smoke_grenade.tik":
    self take "models/weapons/bazooka.tik"
    self take "models/weapons/colt45.tik"
    self take "models/weapons/m2frag_grenade.tik"
    self take "models/items/binoculars.tik"
    self take "models/weapons/RDG-1_Smoke_grenade.tik"
    self give "models/weapons/springfield.tik"
    waitframe
    self useweaponclass rifle
    }
    }
    self.raising = 0
    end


    Second switch was redundant as it would always give a springfield (default means "in all other cases"). Did you also mean for it to be inside the first switch? If so, it's valid code, but it is redundant.

    As I mention before don't access the self object before checking if the self object is NULL. Order of events matter. You also had braces in random locations. Why have them at the end encompassing self.raising and end of function?

    local.weapon in the first switch isn't defined anywhere. Plus you will want to check the model of the weapon, not the weapon object itself, as that is what you are comparing.

    Also, the check that the weapon exists before clearing the targetname is good, but you will want to encompass the switch too as that also accesses the weapon object.

    And for readability purposes, please please please use indentation.
    Last edited by 1337Smithy; November 3rd, 2022 at 12:17 PM.

  2. #22

    Default

    Quote Originally Posted by chrissstrahl View Post
    I am not sure if having a switch inside a switch like that is even valid.
    Have you tried if the sitch works if they are seperate on their own ?
    well i was thinking that but i just CRACKED THE CODE!!!!!!!!




    main:

    if ( self.weapon )



    case "models/weapons/bazooka.tik":
    case "models/weapons/colt45.tik":
    case "models/weapons/m2frag_grenade.tik":
    case "models/items/binoculars.tik":
    case "models/weapons/RDG-1_Smoke_grenade.tik":

    self take "models/weapons/bazooka.tik"
    self take "models/weapons/colt45.tik"
    self take "models/weapons/m2frag_grenade.tik"
    self take "models/items/binoculars.tik"
    self take "models/weapons/RDG-1_Smoke_grenade.tik"




    if (self.model)



    case "models/player/allied_oss.tik":
    case "models/player/allied_sas.tik":
    case "models/player/allied_manon.tik":
    case "models/player/american_army.tik":
    case "models/player/american_ranger.tik":
    case "models/player/allied_airborne.tik":
    case "models/player/allied_101st_Scout.tik":
    case "models/player/allied_101st_Captain.tik":
    case "models/player/allied_russian_seaman.tik":
    case "models/player/allied_101st_Infantry.tik":
    case "models/player/allied_501st_PIR_Scout.tik":
    case "models/player/allied_russian_corporal.tik":
    case "models/player/allied_501st_PIR_Soldier.tik":
    case "models/player/allied_russian_seaman_fps.tik":
    case "models/player/allied_russian_crazy_boris.tik":
    case "models/player/allied_russian_recon_scout.tik":
    case "models/player/allied_british_tank_corporal.tik":
    case "models/player/allied_russian_recon_soldier.tik":
    case "models/player/allied_british_6th_airborne_captain.tik":
    case "models/player/allied_british_6th_airborne_paratrooper.tik":


    waitframe
    self give "models/weapons/springfield.tik"

    waitframe

    self use "models/weapons/springfield.tik"

    default:

    waitframe
    self give "models/weapons/springfield.tik"

    waitframe

    self use "models/weapons/springfield.tik"


    self.raising = 0
    end




    MAN, THIS MAKES ME PROUD!!! I FEEL ACOMPLISHED! its nothing special but it's a start and it works!!!! test it out and left me know what you all think


    still the same glitch i was getting as far as weapon selection if you select the bazooka, you get the spring. if you select the spring you are supposed to get the Mosin and well you do but now it is giving it to the bazooka slot because you're raising the spring so it thinks that what you selected and swaps to the Mosin which I can't find a work around
    Last edited by assasin5469; November 3rd, 2022 at 01:00 PM.

  3. #23

    Default

    Quote Originally Posted by 1337Smithy View Post
    Second switch was redundant as it would always give a Springfield (default means "in all other cases"). Did you also mean for it to be inside the first switch? If so, it's valid code, but it is redundant.
    Well, I've moved the original Springfield down to the bazooka slot and made the original Springfield slot the Mosin, but it would cause a glitch making the bazooka pull up the Mosin as it is now the Springfield. So, my thought was the default but that was a dead end as well.

    let me test your line of code out and see how it works and ill touch back in with you. Thanks a lot for the reply in code snippet means a lot man!!!

  4. #24

    Default

    Quote Originally Posted by 1337Smithy View Post

    spring:
    if (!self || self.dmteam == "spectator" || self.mef_spectator == 1) {
    end
    }
    if (self.raising == 1) {
    end
    }
    self.raising = 1

    local.weaponName = "weapon" + self.entnum

    self weaponcommand mainhand targetname (local.weaponName)

    local.weapon = $(local.weaponName)

    if (local.weapon){
    local.weapon.targetname = ""

    switch (local.weapon.model) {
    case "models/weapons/bazooka.tik":
    case "models/weapons/colt45.tik":
    case "models/weapons/m2frag_grenade.tik":
    case "models/weapons/RDG-1_Smoke_grenade.tik":
    self take "models/weapons/bazooka.tik"
    self take "models/weapons/colt45.tik"
    self take "models/weapons/m2frag_grenade.tik"
    self take "models/items/binoculars.tik"
    self take "models/weapons/RDG-1_Smoke_grenade.tik"
    self give "models/weapons/springfield.tik"
    waitframe
    self useweaponclass rifle
    }
    }
    self.raising = 0
    end

    So, I was able to test this code tonight it to will not fire off. Alternatively, I found a solution, but it still will not fix the weapon raising issue I'm running into. here's the code noting fancy, but it does work.

    I just need to figure out a way to stop the bazooka on raising the Mosin or seeing the Mosin first since we change the Springfield to Mosin and the bazooka to Springfield it has a weapon raise glitch because the bazooka thinks we are pulling up the Mosin as the Mosin was put into the Springfield slot.





    main:

    if ( self.weapon )



    case "models/weapons/springfield.tik":
    case "models/weapons/colt45.tik":
    case "models/weapons/m2frag_grenade.tik":
    case "models/items/binoculars.tik":
    case "models/weapons/RDG-1_Smoke_grenade.tik":

    self take "models/weapons/springfield.tik"
    self take "models/weapons/colt45.tik"
    self take "models/weapons/m2frag_grenade.tik"
    self take "models/items/binoculars.tik"
    self take "models/weapons/RDG-1_Smoke_grenade.tik"




    if (self.model)



    case "models/player/allied_oss.tik":
    case "models/player/allied_sas.tik":
    case "models/player/allied_manon.tik":
    case "models/player/american_army.tik":
    case "models/player/american_ranger.tik":
    case "models/player/allied_airborne.tik":
    case "models/player/allied_101st_Scout.tik":
    case "models/player/allied_101st_Captain.tik":
    case "models/player/allied_russian_seaman.tik":
    case "models/player/allied_101st_Infantry.tik":
    case "models/player/allied_501st_PIR_Scout.tik":
    case "models/player/allied_russian_corporal.tik":
    case "models/player/allied_501st_PIR_Soldier.tik":
    case "models/player/allied_russian_seaman_fps.tik":
    case "models/player/allied_russian_crazy_boris.tik":
    case "models/player/allied_russian_recon_scout.tik":
    case "models/player/allied_british_tank_corporal.tik":
    case "models/player/allied_russian_recon_soldier.tik":
    case "models/player/allied_british_6th_airborne_captain.tik":
    case "models/player/allied_british_6th_airborne_paratrooper.tik":


    waitframe
    self give "models/weapons/Mosin_Nagant_Rifle.tik"

    waitframe

    self useweaponclass rifle

    default:

    waitframe
    self give "models/weapons/Mosin_Nagant_Rifle.tik"

    waitframe

    self useweaponclass rifle

    end


  5. #25

    Default

    I quickly tested my code and it worked for me so you must not be testing properly. I feel like I'm repeating myself. What did I say about braces? What did I say about the redundant switch? And here you removed the switch and braces but left the cases for some reason so it makes things extra redundant. Go back and re read all my comments as I'm not going to go round in circles lol.

  6. #26

    Default

    Quote Originally Posted by 1337Smithy View Post
    I quickly tested my code and it worked for me so you must not be testing properly. I feel like I'm repeating myself. What did I say about braces? What did I say about the redundant switch? And here you removed the switch and braces but left the cases for some reason so it makes things extra redundant. Go back and re read all my comments as I'm not going to go round in circles lol.


    Appologies my friend im fairly new to this coding and stilll learning heres how i called for your code






    main:

    thread spring

    end


    spring:
    if (!self || self.dmteam == "spectator" || self.mef_spectator == 1) {
    end
    }
    if (self.raising == 1) {
    end
    }
    self.raising = 1

    local.weaponName = "weapon" + self.entnum

    self weaponcommand mainhand targetname (local.weaponName)

    local.weapon = $(local.weaponName)

    if (local.weapon){
    local.weapon.targetname = ""

    switch (local.weapon.model) {
    case "models/weapons/bazooka.tik":
    case "models/weapons/colt45.tik":
    case "models/weapons/m2frag_grenade.tik":
    case "models/weapons/RDG-1_Smoke_grenade.tik":
    self take "models/weapons/bazooka.tik"
    self take "models/weapons/colt45.tik"
    self take "models/weapons/m2frag_grenade.tik"
    self take "models/items/binoculars.tik"
    self take "models/weapons/RDG-1_Smoke_grenade.tik"
    self give "models/weapons/springfield.tik"
    waitframe
    self useweaponclass rifle
    }
    }
    self.raising = 0
    end






    //==============================================================================
    //==============================================================================
    //
    // RAISE_WEAPON
    //
    //==============================================================================
    state RAISE_WEAPON
    {
    movetype legs

    entrycommands
    {
    viewmodelanim pullout

    // just to make sure nothing funky's
    // attached that shouldn't be.
    correctweaponattachments
    }

    states
    {
    RAISE_KAR98_FOR_M1 : IS_NEW_WEAPON "mainhand" "M1 Garand"
    RAISE_MOSIN_FOR_SPRING : IS_NEW_WEAPON "mainhand" "Springfield '03 Sniper" //| This Mosin is causing the bazooka to pull up the Mosin as well
    RAISE_ENFIELD_FOR_THOMP : IS_NEW_WEAPON "mainhand" "Thompson"
    RAISE_KSNIPER_FOR_BAR : IS_NEW_WEAPON "mainhand" "BAR"
    RAISE_SPRING_FOR_BAZOOKA : IS_NEW_WEAPON "mainhand" "Bazooka" //|New raise added here
    RAISE_KAR98_FOR_SHOTGUN : IS_NEW_WEAPON "mainhand" "Shotgun"



    RAISE_PISTOL : IS_NEW_WEAPONCLASS "mainhand" "pistol"
    RAISE_RIFLE : IS_NEW_WEAPONCLASS "mainhand" "rifle"
    RAISE_GRENADE : IS_NEW_WEAPONCLASS "mainhand" "grenade"
    RAISE_SMG : IS_NEW_WEAPONCLASS "mainhand" "smg"
    RAISE_MG : IS_NEW_WEAPONCLASS "mainhand" "mg"
    // RAISE_PISTOL : IS_NEW_WEAPONCLASS "mainhand" "item" // hold all items like a pistol for now
    RAISE_HEAVY : IS_NEW_WEAPONCLASS "mainhand" "heavy"
    RAISE_PAPERS : IS_NEW_WEAPON "mainhand" "Papers"

    // RAISE_RIFLE : default
    RAISE_NOANIM : default
    }
    }

    state RAISE_NOANIM
    {
    entrycommands
    {
    // delay the activation for a frame so that the player
    // spends at least one frame without a weapon, thus
    // letting the legs state know that we've switched
    commanddelay 0.05 activatenewweapon
    commanddelay 0.05 forcetorsostate "STAND_REAL"
    }

    // states
    // {
    // STAND_REAL : default
    // }
    }




    state RAISE_SPRING_FOR_BAZOOKA
    {

    movetype legs

    entrycommands
    {

    exec global/weapScr/bazooka.scr //|exec here
    }

    states
    {
    STAND : !NEW_WEAPON


    }
    }




    if this is the incorrect way to use it please help to understand how
    Last edited by assasin5469; November 5th, 2022 at 12:54 AM.

Posting Permissions

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