[HELP] Tazer
#1

Dear users,

I'm trying to make a taser cmd for my server. And it complies fine but I've got a problem. When I pull the trigger of the SD Pistol and I ain't aiming properly on a person it tazes myself.

This is under KeyStateChange
Код:
    if(((oldkeys & KEY_FIRE) && !(newkeys & KEY_FIRE)) || ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE)) ||  (newkeys & KEY_FIRE))
    {
         for(new i = 0; i < GetMaxPlayers(); i++)
        {
            if(IsPlayerAiming(playerid, i))
            {
                if(Groups[Player[playerid][Group]][CommandTypes] == 1)
                {
                    if(GetPlayerWeapon(playerid) == 23)
                    {
                        //SetPlayerHealth(i, 0);
                        TogglePlayerControllable(i, 0);
                         ApplyAnimation(i, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
                        GameTextForPlayer(i, "You got Tazed", 3000, 3);
                        GameTextForPlayer(playerid, "Inmate got tazed", 3000, 3);
                        SetTimerEx("UntazePlayer", 12000, false, "d", i);
                        return 1;
                    }
                }
            }
        }
    }
And this is the cmd taking it out.

Код:
command(taser, playerid, params[])
{
    if(IsPlayerConnected(playerid))
     {
        if(Groups[Player[playerid][Group]][CommandTypes] == 1)
        {
            GivePlayerWeaponEx(playerid, 23);
             new string[128];
             format(string, sizeof(string), "* %s unholsters his tazer.", UnderscoreToSpaceName( playerid ));
            NearByMessage(playerid, PURPLE, string);
            return 1;
        }
    }
    return 0;
}
Does anyone knows how to stop tazing yourself?
Reply
#2

try adding a if statement to makesure playerid != i
like
http://notesbin.com/1137955257
Reply
#3

That file ain't working.
Reply
#4

Anyone knows a solution for this?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)