SA-MP Forums Archive
Arrest per Keyboard - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Arrest per Keyboard (/showthread.php?tid=643808)



Arrest per Keyboard - pulsare - 28.10.2017

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;
}
}
}




Re: Arrest per Keyboard - Logic_ - 28.10.2017

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;

^^.


Re: Arrest per Keyboard - pulsare - 28.10.2017

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


Re: Arrest per Keyboard - Arbico - 28.10.2017

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


Re: Arrest per Keyboard - pulsare - 28.10.2017

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


Re: Arrest per Keyboard - Bruno13 - 28.10.2017

PHP код:
if(newkeys KEY_CROUCH



Re: Arrest per Keyboard - pulsare - 28.10.2017

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?


Re: Arrest per Keyboard - Logic_ - 28.10.2017

Have you edited anything in the code?


Re: Arrest per Keyboard - Lucases - 28.10.2017

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;
}



Re: Arrest per Keyboard - pulsare - 28.10.2017

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