Taser/Beanbag system problem
#1

I had a full-working taser system, and that always worked.
So i made a beanbag system, i just copied the taser system and changed all the values to beanbag values instead, and defined them and all the other stuff that the taser has.

The problem is, only one of them works, first the taser system worked, but beanbag didn't, where the taser system was above the beanbag system under OnPlayerShootPlayer.
I tried switching them around, so the beanbag system is above, but then the beanbag system works, but the taser doesn't.
So i'm quite confused as to why this is, here's the OnPlayerShootPlayer taser/beanbag scripting:

pawn Код:
if(IsAPDFBIHGGOV(Shooter))
    {
        if(Beanbag[Shooter])
        {
            if(GetPlayerWeapon(Shooter) == 25)
            {
                if(!IsPlayerBeanbagged(Target) && !IsPlayerCuffed(Target) && !IsPlayerTied(Target))
                {
                    new Float:HP, Float:Armor;
                    GetPlayerHealth(Target, HP);
                    GetPlayerArmour(Target, Armor);
                    SetPlayerHealth(Target, HealthLost+HP);
                    SetPlayerArmour(Target, ArmourLost+Armor);
                    if(!IsPlayerNearPlayer(Shooter, Target, 12)) return SendClientMessage(Shooter, COLOR_GREY, "The target was too far away for the beanbag to hit.");
                    // Got Beanbagged
                    format(string, sizeof(string), "* %s was hit by a beanbag round and falls to the ground in pain.", RPN(Target));
                    SendNearbyMessage(Shooter, 12, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                    GameTextForPlayer(Target, "~r~Beanbagged", 3500, 3);
                    // Custom Freeze
                    ApplyAnimation(Target,"PED","KO_shot_stom",4.0,0,1,1,1,0);
                    TogglePlayerControllable(Target, 0);
                    // Beanbagged Detecting
                    TogglePlayerBeanbagged(Target, 1);
                    // Beanbag Timeout
                    BeanbagTimeout[Target] = 11;
                    BeanbagCountDown[Target] = SetTimerEx("BeanbagTimer", 1500, true, "d", Target);
                }

            }
        }
    }
    return 1;
    if(IsAPDFBIHGGOV(Shooter))
    {
        if(Tazer[Shooter])
        {
            if(GetPlayerWeapon(Shooter) == 23)
            {
                if(!IsPlayerTazed(Target) && !IsPlayerCuffed(Target) && !IsPlayerTied(Target))
                {
                    new Float:HP, Float:Armor;
                    GetPlayerHealth(Target, HP);
                    GetPlayerArmour(Target, Armor);
                    SetPlayerHealth(Target, HealthLost+HP);
                    SetPlayerArmour(Target, ArmourLost+Armor);
                    if(!IsPlayerNearPlayer(Shooter, Target, 12)) return SendClientMessage(Shooter, COLOR_GREY, "The target was too far away for the taser to hit.");
                    // Got Tazed
                    format(string, sizeof(string), "* %s was hit by a taser and gets electrocuted.", RPN(Target));
                    SendNearbyMessage(Shooter, 30, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                    GameTextForPlayer(Target, "~r~Tased", 3500, 3);
                    // Custom Freeze
                    ApplyAnimation(Target,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
                    TogglePlayerControllable(Target, 0);
                    // Tazed Detecting
                    TogglePlayerTazed(Target, 1);
                    // Tazer Timeout
                    TazeTimeout[Target] = 11;
                    TazeCountDown[Target] = SetTimerEx("TazeTimer", 3000, true, "d", Target);
                }

            }
        }
    }
    return 1;
}
There's a sniper system just above the beanbag one though, but that works fine.
And yes, i've called the values "Tazer" instead of taser, i know, that's because i was too lazy to change them when i changed the name to Taser.
And yes, i've made commands for them, and defined them, so i really have no idea what's causing this.
Reply
#2

You're using the same if statement for both.

pawn Код:
if(IsAPDFBIHGGOV(Shooter))
Why? Why not just place it all under the same if and switch between each using else if?
Reply
#3

Because it has to be correct with all of them, not just one of them, as far as i remember, "else if" doesn't require all of them to be correct?
Reply
#4

I believe the first return command is not placed well. And I think that you should do what AlphaPac told you, place them under the same
if(IsAPDFBIHGGOV(Shooter))
and switch between each using else if. This should fix the problem.

If you need more help, add me on skype : Kelzano (I'm the Tiger picture)
If I helped you, please rep+.
Reply
#5

Alright, he helped me to fix it on skype, some other problems occured.
Solved.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)