Pawno stops to work
#1

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{

    if(Holding(KEY_FIRE) || newkeys == KEY_FIRE)
    if(Tazer[playerid] = 1;
    if(!IsPlayerTazed(Target) && !IsPlayerCuffed(Target) && !IsPlayerTied(Target))
    {
    ApplyAnimation(playerid,"KNIFE","knife_3",4.1,0,1,1,0,0,1);
    new Float:HP, Float:Armor;
    GetPlayerHealth(Target, HP);
    GetPlayerArmour(Target, Armor);
    SetPlayerHealth(Target, HealthLost+HP);
    SetPlayerArmour(Target, ArmourLost+Armor);
    if(!IsPlayerNearPlayer(Shooter, Target, 8.3)) return SendClientMessage(Shooter, COLOR_GREY, "You are too far away from that player.");
    //if(IsHoldingFirearm(Target)) return SendClientMessage(Shooter, COLOR_GREY, "You can't taze someone with a gun in hand.");
    // Got Tazed
    format(string, sizeof(string), "* %s aims their tazer on %s and tazes them.", RPN(Shooter), RPN(Target));
    SendNearbyMessage(Shooter, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    GameTextForPlayer(Target, "~r~Tazed", 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", 1000, true, "d", Target);
           }
        }
    }
    return 1;
  }
My pawno stops to work when i try to complie, any idea why?
when i try to delete this its works fine
Reply
#2

Fixed your code, try this.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(Holding(KEY_FIRE) || newkeys == KEY_FIRE)
    {
        if(Tazer[playerid] == 1)
        {
            if(!IsPlayerTazed(Target) && !IsPlayerCuffed(Target) && !IsPlayerTied(Target))
            {
                ApplyAnimation(playerid,"KNIFE","knife_3",4.1,0,1,1,0,0,1);
                new Float:HP, Float:Armor;
                GetPlayerHealth(Target, HP);
                GetPlayerArmour(Target, Armor);
                SetPlayerHealth(Target, HealthLost+HP);
                SetPlayerArmour(Target, ArmourLost+Armor);
                if(!IsPlayerNearPlayer(Shooter, Target, 8.3)) return SendClientMessage(Shooter, COLOR_GREY, "You are too far away from that player.");
                //if(IsHoldingFirearm(Target)) return SendClientMessage(Shooter, COLOR_GREY, "You can't taze someone with a gun in hand.");
                // Got Tazed
                format(string, sizeof(string), "* %s aims their tazer on %s and tazes them.", RPN(Shooter), RPN(Target));
                SendNearbyMessage(Shooter, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(Target, "~r~Tazed", 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", 1000, true, "d", Target);
            }
        }
    }
    return 1;
}
Reply
#3

Count the number of '{'. Then count the number of '}'.

http://www.damnlol.com/pics/31/ec1a4...9f3040f087.jpg
Reply
#4

same
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
Count the number of '{'. Then count the number of '}'.

http://www.damnlol.com/pics/31/ec1a4...9f3040f087.jpg
ah never knew this way.
Thanks both!
Reply
#6

here is my commad, but i taze my self lol.
can anyone help?

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Target;
    if(Holding(KEY_FIRE) || newkeys == KEY_FIRE)
    {
        if(Tazer[playerid] == 1)
        {
            if(!IsPlayerTazed(Target) && !IsPlayerCuffed(Target) && !IsPlayerTied(Target))
            {
                ApplyAnimation(playerid,"KNIFE","knife_3",4.1,0,1,1,0,0,1);
                if(!IsPlayerNearPlayer(playerid, Target, 5)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
                //if(IsHoldingFirearm(Target)) return SendClientMessage(Shooter, COLOR_GREY, "You can't taze someone with a gun in hand.");
                // Got Tazed
                /*format(string, sizeof(string), "* %s aims their tazer on %s and tazes them.", RPN(Shooter), RPN(Target));
                SendNearbyMessage(Shooter, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);*/

                GameTextForPlayer(Target, "~r~Tazed", 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", 1000, true, "d", Target);
            }
        }
    return 1;
}
Reply
#7

pawn Код:
forward Float:GetDistanceBetweenPlayers(p1,p2);
public Float:GetDistanceBetweenPlayers(p1,p2)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2)) {
        return -1.00;
    }
    GetPlayerPos(p1,x1,y1,z1);
    GetPlayerPos(p2,x2,y2,z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}

stock GetClosestPlayer(p1)
{
    new x,Float:dis,Float:dis2,player;
    player = -1;
    dis = 99999.99;
    for (x=0;x<MAX_PLAYERS;x++)
    {
        if(IsPlayerConnected(x) && GetPlayerState(x) != PLAYER_STATE_SPECTATING)
        {
            if(x != p1)
            {
                dis2 = GetDistanceBetweenPlayers(x,p1);
                if(dis2 < dis && dis2 != -1.00)
                {
                    dis = dis2;
                    player = x;
                }
            }
        }
    }
    return player;
}
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Target = GetClosestPlayer(playerid);
    if(Holding(KEY_FIRE) || newkeys == KEY_FIRE)
    {
        if(Tazer[playerid] == 1)
        {
            if(!IsPlayerTazed(Target) && !IsPlayerCuffed(Target) && !IsPlayerTied(Target))
            {
                ApplyAnimation(playerid,"KNIFE","knife_3",4.1,0,1,1,0,0,1);
                if(!IsPlayerNearPlayer(playerid, Target, 5)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
                //if(IsHoldingFirearm(Target)) return SendClientMessage(Shooter, COLOR_GREY, "You can't taze someone with a gun in hand.");
                // Got Tazed
                /*format(string, sizeof(string), "* %s aims their tazer on %s and tazes them.", RPN(Shooter), RPN(Target));
                SendNearbyMessage(Shooter, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);*/

                GameTextForPlayer(Target, "~r~Tazed", 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", 1000, true, "d", Target);
            }
        }
    return 1;
}
Reply
#8

Take note that the compiler is the one that crashes, not pawno. If it freezez, just end the pawncc.exe
Reply
#9

Quote:
Originally Posted by Turn
Посмотреть сообщение
pawn Код:
newkeys == KEY_FIRE
This is not the correct way to check for a key.

Please read this: https://sampwiki.blast.hk/wiki/OnPlayerK...heck_for_a_key
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)