Arrest per Keyboard
#1

Hey,

I just want to make a Arrest Command for Cops so they can arrest players per key for example "Crouch"

this players must be in near. Idk exactly how to handle pid & playerid on this. If I try to arrest people in my near

its always saying "not in range"

Can you help me?

Quote:

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new pid;
if(IsPlayerCop(playerid))
if(newkeys == KEY_CROUCH)
{
new Float: x, Float:y, Float:z;
GetPlayerPos(pid, x,y,z);
if(IsPlayerInRangeOfPoint(playerid, 2, x, y, z))
{
Arrest(pid);
return 1;
}
}
else
{
SendClientMessage(playerid,COLOR_RED,"Not in range!");
}
else
{
SendClientMessage(playerid,COLOR_RED,"Not a Cop!");
}
return 1;
}


My arrest stock:

Quote:

stock Arrest(playerid)
{
SetPlayerInterior(playerid,6);
SetPlayerPos(playerid,264.5287,77.6026,1001.0391);
return 1;
}


Thats my normal arrest command: (working fine)

Quote:

ocmd:arrest(playerid,params[])
{
new pid;
if(sscanf(params,"u", pid))
{
return SendClientMessage(playerid,BLAU,"*USAGE:{f0e68c}/arrest [ID]");
}
if(!IstSpielerInFraktion(playerid, 1)) return SendClientMessage(playerid,BLAU,"NOT IN LSPD!");
{
if(pid == INVALID_PLAYER_ID)
{
return SendClientMessage(playerid,ROT,"[Server]: Player is not connected");
}
if(loggedin[playerid] == 0)
{
SendClientMessage(playerid,COLOR_RED,"Not logged in!");
}
{
new Float: x, Float:y, Float:z;
GetPlayerPos(pid, x,y,z);
if(IsPlayerInRangeOfPoint(playerid, 2, x, y, z))
{
SetPlayerInterior(pid,6);
SetPlayerPos(pid,264.5287,77.6026,1001.0391);
new string[128];
new cuff[128];
format(string, sizeof(string), "Officer %s arrested you ", GetName(playerid));
SendClientMessage(pid, BLAU,string);
GameTextForPlayer(pid, "Cuffed", 5000, 6);
format(cuff, sizeof(cuff), "You arrested %s ", GetName(pid));
SendClientMessage(playerid, BLAU, cuff);
return 1;
}
}
{
SendClientMessage(playerid,BLAU,"Not in range of this Player!"); return 1;
}
}
}

Reply
#2

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{    
    if(
newkeys KEY_CROUCH)
    {
        if(
IsPlayerCop(playerid))
        {
            new 
FloatxFloat:yFloat:zFloatdistancepid INVALID_PLAYER_ID;
            
GetPlayerPos(pidxyz);
            for(new 
iGetPlayerPoolSize(); <= ji++)
            {
                if(!
IsPlayerConnected(i)) continue;
                
distance GetPlayerDistanceFromPoint(ixyz);
                if(
floatabs(distance) < 2.0)
                {
                    
pid i;
                    break;
                }
            }
            if(
pid != INVALID_PLAYER_ID)
            {
                
Arrest(pid);
                
// format a message maybe? and send it
            
}
            else
            {
                
SendClientMessage(playeridcolor"NOT IN RANGE");
            }
        }
    }
    return 
1;

^^.
Reply
#3

Quote:
Originally Posted by Logic_
Посмотреть сообщение
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{    
    if(
newkeys == KEY_CROUCH)
    {
        if(
IsPlayerCop(playerid))
        {
            new 
FloatxFloat:yFloat:zFloatdistancepid INVALID_PLAYER_ID;
            
GetPlayerPos(pidxyz);
            for(new 
iGetPlayerPoolSize(); <= ji++)
            {
                if(!
IsPlayerConnected(i)) continue;
                
distance GetPlayerDistanceFromPoint(ixyz);
                if(
floatabs(distance) < 2)
                {
                    
pid i;
                    break;
                }
            }
            if(
pid != INVALID_PLAYER_ID)
            {
                
Arrest(pid);
                
// format a message maybe? and send it
            
}
            else
            {
                
SendClientMessage(playeridcolor"NOT IN RANGE");
            }
        }
    }
    return 
1;

^^.
thx but Its still saying "not in range" when I stand next to the player
Reply
#4

Quote:
Originally Posted by pulsare
Посмотреть сообщение
thx but Its still saying "not in range" when I stand next to the player
Try increasing the range.
Reply
#5

Quote:
Originally Posted by Arbico
Посмотреть сообщение
Try increasing the range.
Not working too
Reply
#6

PHP код:
if(newkeys KEY_CROUCH
Reply
#7

Quote:
Originally Posted by Bruno13
Посмотреть сообщение
PHP код:
if(newkeys KEY_CROUCH
https://www.pic-upload.de/view-34186...p-087.png.html


Is it okay that the player is desktop?
Reply
#8

Have you edited anything in the code?
Reply
#9

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new pid;
if(IsPlayerCop(playerid))
if(newkeys == KEY_CROUCH)
{
new Float: x, Float:y, Float:z;
GetPlayerPos(pid, x,y,z);
for(new i=-1; i<MAX_PLAYERS, i++)
{
       if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i, 2, x, y, z))
       {
       Arrest(pid);
       return 1;
       }
}
}
else
{
SendClientMessage(playerid,COLOR_RED,"Not in range!");
}
else
{
SendClientMessage(playerid,COLOR_RED,"Not a Cop!");
}
return 1;
}
Reply
#10

Quote:
Originally Posted by Lucases
Посмотреть сообщение
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new pid;
if(IsPlayerCop(playerid))
if(newkeys == KEY_CROUCH)
{
new Float: x, Float:y, Float:z;
GetPlayerPos(pid, x,y,z);
for(new i=-1; i<MAX_PLAYERS, i++)   error 001: expected token: ";", but found ")"
{
       if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i, 2, x, y, z))  error 076: syntax error in the expression, or invalid function call
       {
       Arrest(pid);
       return 1;
       }
}
}
else
{
SendClientMessage(playerid,COLOR_RED,"Not in range!");
}
else
{
SendClientMessage(playerid,COLOR_RED,"Not a Cop!");
}
return 1;
}
errors
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)