[HELP] Stuning and arresting player!
#1

Dont get whats wrong! So, basicaly, you shoot player with Country Rifle and player gets stunned! Stuning player works perfect, but i have problems with command -> /arrest <stuned-playerid>! Please take a look and help if you know whats the problem!

pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid) //Works
{
    if(Enforcer[playerid] == 1)
    {
        if(GetPlayerWeapon(playerid) == 33)
        {
            StunPlayer(damagedid);
            SetTimer("StunTime",7000,false);
        }
        return 1;
    }
    return 0;
}

public StunTime() //Works
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(Stuned[i] == 1)
        {
            TogglePlayerControllable(i,1);
            Stuned[i] = 0;
            ClearAnimations(i);
            return 1;
        }
    }
    return 1;
}
COMMAND:arrest(playerid, params[]) //Dont works
{
    new stunedid;
    if (Enforcer[playerid] == 1)
    {
        if (!sscanf(params, "u", stunedid))
        {
          if (Stuned[stunedid] == 1) //This is the problem
          {
            SetPlayerScore(stunedid,GetPlayerScore(stunedid)-10);
            GivePlayerMoney(stunedid,-10000);
            new rand = random(sizeof(RandomCrimSpawns));
            SetPlayerPos(stunedid, RandomCrimSpawns[rand][0], RandomCrimSpawns[rand][1], RandomCrimSpawns[rand][2]);
            SetPlayerFacingAngle(stunedid, RandomCrimSpawns[rand][3]);
            SetCameraBehindPlayer(stunedid);
            SendClientMessage(stunedid,GCOLOR_GREY,"* You have been arrested! You lost 10000$ and 10 Score");
            SetPlayerScore(playerid,GetPlayerScore(playerid)+10);
            GivePlayerMoney(playerid,10000);
            SendClientMessage(stunedid,GCOLOR_GREY,"* You arrested Criminal and received 10000$ and 10 Score");
          }
          else SendClientMessage(playerid, GCOLOR_RED, "ERROR: That player is not stunned!");
        }
        else SendClientMessage(playerid, GCOLOR_RED, "Usage: /arrest <stuned-playerid>");
    }
    else SendClientMessage(playerid, GCOLOR_RED, "ERROR: Only Enforcers can use this command!");
    return 1;
}

stock StunPlayer(playerid)
{
    TogglePlayerControllable(playerid,0);
    GameTextForPlayer(playerid,"~r~STUNNED!",7000,3);
    Stuned[playerid] = 1;
    ApplyAnimation(playerid, "ped", "cower", 3.0, 1, 0, 0, 0, 0);
    return 1;
}
Even though if the player is stunned, its returns an error -> "That player is not stunned!"
Reply
#2

Show me your StunPlayer function and also, set the timer for person, not for everyone because basically if one person gets stunned it does a timer to everyone who is stunned and there might be bugs like player unstuns after 0,1sec
Reply
#3

Try this:

pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid) //Works
{
    if(Enforcer[playerid] == 1)
    {
        if(GetPlayerWeapon(playerid) == 33)
        {
            StunPlayer(damagedid);
            SetTimerEx("StunTime",7000,false,"d",damagedid);
        }
        return 1;
    }
    return 0;
}

public StunTime(damagedid) //Works
{
    if(Stuned[damagedid] == 1)
    {
        TogglePlayerControllable(damagedid,1);
        Stuned[damagedid] = 0;
        ClearAnimations(damagedid);
        return 1;
    }
    return 1;
}
COMMAND:arrest(playerid, params[]) //Dont works
{
    new stunedid;
    if (Enforcer[playerid] == 1)
    {
        if (strlen(params)>0)
        {
          stuneid = strval(params);
          if (Stuned[stunedid] == 1) //This is the problem
          {
            SetPlayerScore(stunedid,GetPlayerScore(stunedid)-10);
            GivePlayerMoney(stunedid,-10000);
            new rand = random(sizeof(RandomCrimSpawns));
            SetPlayerPos(stunedid, RandomCrimSpawns[rand][0], RandomCrimSpawns[rand][1], RandomCrimSpawns[rand][2]);
            SetPlayerFacingAngle(stunedid, RandomCrimSpawns[rand][3]);
            SetCameraBehindPlayer(stunedid);
            SendClientMessage(stunedid,GCOLOR_GREY,"* You have been arrested! You lost 10000$ and 10 Score");
            SetPlayerScore(playerid,GetPlayerScore(playerid)+10);
            GivePlayerMoney(playerid,10000);
            SendClientMessage(stunedid,GCOLOR_GREY,"* You arrested Criminal and received 10000$ and 10 Score");
          }
          else SendClientMessage(playerid, GCOLOR_RED, "ERROR: That player is not stunned!");
        }
        else SendClientMessage(playerid, GCOLOR_RED, "Usage: /arrest <stuned-playerid>");
    }
    else SendClientMessage(playerid, GCOLOR_RED, "ERROR: Only Enforcers can use this command!");
    return 1;
}
Reply
#4

Quote:
Originally Posted by wildcookie007
Посмотреть сообщение
Show me your StunPlayer function and also, set the timer for person, not for everyone because basically if one person gets stunned it does a timer to everyone who is stunned and there might be bugs like player unstuns after 0,1sec
Jesus christ, look at code! StunPlayer is already there, and timer wont unstun/stun every player cause there is this:
pawn Код:
if(Stuned[i] == 1)
This will just unstun players that are stunned!
Reply
#5

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
Try this:

pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid) //Works
{
    if(Enforcer[playerid] == 1)
    {
        if(GetPlayerWeapon(playerid) == 33)
        {
            StunPlayer(damagedid);
            SetTimerEx("StunTime",7000,false,"d",damagedid);
        }
        return 1;
    }
    return 0;
}

public StunTime(damagedid) //Works
{
    if(Stuned[damagedid] == 1)
    {
        TogglePlayerControllable(damagedid,1);
        Stuned[damagedid] = 0;
        ClearAnimations(damagedid);
        return 1;
    }
    return 1;
}
COMMAND:arrest(playerid, params[]) //Dont works
{
    new stunedid;
    if (Enforcer[playerid] == 1)
    {
        if (strlen(params)>0)
        {
          stuneid = strval(params);
          if (Stuned[stunedid] == 1) //This is the problem
          {
            SetPlayerScore(stunedid,GetPlayerScore(stunedid)-10);
            GivePlayerMoney(stunedid,-10000);
            new rand = random(sizeof(RandomCrimSpawns));
            SetPlayerPos(stunedid, RandomCrimSpawns[rand][0], RandomCrimSpawns[rand][1], RandomCrimSpawns[rand][2]);
            SetPlayerFacingAngle(stunedid, RandomCrimSpawns[rand][3]);
            SetCameraBehindPlayer(stunedid);
            SendClientMessage(stunedid,GCOLOR_GREY,"* You have been arrested! You lost 10000$ and 10 Score");
            SetPlayerScore(playerid,GetPlayerScore(playerid)+10);
            GivePlayerMoney(playerid,10000);
            SendClientMessage(stunedid,GCOLOR_GREY,"* You arrested Criminal and received 10000$ and 10 Score");
          }
          else SendClientMessage(playerid, GCOLOR_RED, "ERROR: That player is not stunned!");
        }
        else SendClientMessage(playerid, GCOLOR_RED, "Usage: /arrest <stuned-playerid>");
    }
    else SendClientMessage(playerid, GCOLOR_RED, "ERROR: Only Enforcers can use this command!");
    return 1;
}
Give this error:
pawn Код:
C:\Users\Bruno\Downloads\GTA San Andreas\SAMP 0.3D\APB\apb.pwn(3765) : error 025: function heading differs from prototype
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
And btw, you forgot forward();




EDIT: Nvm, works! Thank you!
Reply
#6

Quote:
Originally Posted by fiki574_CRO
Посмотреть сообщение
Give this error:
And btw, you forgot forward();
EDIT: Nvm, works! Thank you!
Ah, that was the forward. Thought you got that added already.
Nice it works.

Have a Merry Christmas.
Jeffry
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)