Arrest command problems
#1

So i made a command but it dosent do anything
whats the problem i am getting the x y z of the player that is near but nothing works

here is my code
pawn Код:
if(Civilian[id] == 1)
        {
           if(Cuffed[id] == 1)
           {
              new Float:X, Float:Y, Float:Z;
              GetPlayerPos(id,X,Y,Z);
              if(IsPlayerInRangeOfPoint(playerid,2.0,X,Y,Z))
              {
                  if(pwl >= 4)
                  {
                      GivePlayerMoney(playerid, 3000);
                      IncreaseScore(playerid, 1);
                      IncreaseCoprank(playerid, 1);
                      Jailed[id] = 1;
                      JailTime[id] = 60;
                      Cuffed[id] = 0;
                      SetPlayerInterior(id, 6);
                      SetPlayerPos(id, 264.29999, 77.4, 1001);
                      SendClientMessage(id, COLOR_LIGHTBLUE, "**LOS SANTOS PRISON**");
                      SendClientMessage(id, COLOR_LIGHTBLUE, "[PRISON] You have been sent to prison, you will be out of prison in 60 seconds");
                      SetPlayerWantedLevel(id, 0);
                      SetPlayerHealth(id,99999);
                      SetPlayerSpecialAction(id,SPECIAL_ACTION_NONE);
                      ResetPlayerWeapons(id);
                      format(string,sizeof(string),"Police Officer %s(%d) Has arrested wanted suspect %s(%d) and was given $3000 for arresting him.",GetName(playerid),playerid,GetName(id),id);
                      SendClientMessageToAll(COLOR_ORANGE,string);
                      return 1;
                  }
              }  
           }
        }
Reply
#2

Код:
stock PlayerToPlayer(playerid,targetid,Float:distance)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid,x,y,z);
    if(IsPlayerInRangeOfPoint(targetid,distance,x,y,z))
    {
        return true;
    }
    return false;
}
Use this stock. I can't remember who created it but this will help you a lot quicker.

So it'd be:
pawn Код:
if(PlayerToPlayer(playerid, id, 8.0)
{
// Code here
}
Reply
#3

-Deleted-
Reply
#4

Are you completely sure that the part failing is the IsPlayerInRangeOf, if so, are you completely sure that you're correctly defining the other player? (sscanf)
Reply
#5

Same problem dosent work
Reply
#6

Can you show your full command code please?
Reply
#7

Sorry for late reply i was eating in a resturant

here is the full command

pawn Код:
CMD:ar(playerid,params[])
{
    new id, string[128], pwl = GetPlayerWantedLevel(id);
    if(GetPlayerTeam(playerid) != Cops)
    {
        SendClientMessage(playerid, COLOR_RED,"Only law enforcement can arrest wanted suspects.");
        return 1;
    }
    if(!IsPlayerConnected(id))
    {
        format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot arrest them.",id);
        SendClientMessage(playerid, COLOR_RED,string);
        return 1;
    }
    if(Jailed[id] == 1)
    {
       SendClientMessage(playerid, COLOR_RED, "You cannot arrest players that are already jailed.");
       return 1;
    }
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
    {
        SendClientMessage(playerid,COLOR_RED,"You cannot arrest a suspect while in a vehicle. Exit the vehicle first.");
        return 1;
    }
    if(GetPlayerState(id) == PLAYER_STATE_DRIVER || GetPlayerState(id) == PLAYER_STATE_PASSENGER)
    {
        SendClientMessage(playerid,COLOR_RED,"You cannot arrest a suspect they are in a vehicle. Get them to exit the vehicle first.");
        return 1;
    }
        if(Civilian[id] == 1)
        {
           if(Cuffed[id] == 1)
           {
              if(PlayerToPlayer(playerid, id, 2.0))
              {
                  if(pwl >= 4)
                  {
                      GivePlayerMoney(playerid, 3000);
                      IncreaseScore(playerid, 1);
                      IncreaseCoprank(playerid, 1);
                      Jailed[id] = 1;
                      JailTime[id] = 60;
                      Cuffed[id] = 0;
                      SetPlayerInterior(id, 6);
                      SetPlayerPos(id, 264.29999, 77.4, 1001);
                      SendClientMessage(id, COLOR_LIGHTBLUE, "**LOS SANTOS PRISON**");
                      SendClientMessage(id, COLOR_LIGHTBLUE, "[PRISON] You have been sent to prison, you will be out of prison in 60 seconds");
                      SetPlayerWantedLevel(id, 0);
                      SetPlayerHealth(id,99999);
                      SetPlayerSpecialAction(id,SPECIAL_ACTION_NONE);
                      ResetPlayerWeapons(id);
                      format(string,sizeof(string),"Police Officer %s(%d) Has arrested wanted suspect %s(%d) and was given $3000 for arresting him.",GetName(playerid),playerid,GetName(id),id);
                      SendClientMessageToAll(COLOR_ORANGE,string);
                      return 1;
                  }
              }  
           }
        }  
    return 1;
}
Reply
#8

I hate to quote myself but...

Quote:
Originally Posted by CuervO
Посмотреть сообщение
Oh I saw your mistake.

You're never getting the ID of the other player... you just created the variable "id" but you don't assign any value into it, there for you will always be arresting id 0
https://sampforum.blast.hk/showthread.php?tid=500602&page=2

?..
Reply
#9

But this is a different problem not only it dosent check if everyone are near me it also dosent work at all
can you please help me fix this ?

Its my first time scripting a command that needs to check if someone i near you
Reply
#10

Quote:
Originally Posted by DarkLored
Посмотреть сообщение
But this is a different problem not only it dosent check if everyone are near me it also dosent work at all
can you please help me fix this ?

Its my first time scripting a command that needs to check if someone i near you
You should probably look up more on the basics before attempting something of such... "caliber". It's certain that you copy pasted this command (your objective and the command itself are just completely different), and it's main structure is not made to work for all players, rather than only one player, the one you type.

If you really want to learn you have to script from the scratch, It doesn't matter if you use other commands as models but you have to write it yourself.

For starters you'll need a loop. Combine that with a command and the appropiate variables and you'll get it working.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)