SA-MP Forums Archive
/ar cmd - 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: /ar cmd (/showthread.php?tid=502889)



/ar cmd - Sergeant - 26.03.2014

Hey guys, I've been trying for 5 days now, to make an arrest command. I have looked on other ppls arrest commands and I have tried to make my own, without any success and I'm getting very frustrated over this.

If you can help me that would be A W E S O M E.

Here's my Cuff and Uncuff cmd:

pawn Код:
CMD:cuff(playerid, params[])
{
    if(gTeam[playerid] != Cops) return SendClientMessage(playerid, -1, "   * You aren't a cop *");
    new targetid;
    if(sscanf(params, "r", targetid)) return SendClientMessage(playerid, -1, "   * /cuff  Name/ID *");
    if(IsPlayerConnected(targetid))
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        if(IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))
        {
            new str[60];
            new name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            new target[MAX_PLAYER_NAME];
            GetPlayerName(targetid, target, sizeof(target));
            format(str, sizeof(str), "   * You have cuffed %s *",target);
            SendClientMessage(playerid, 0xE01B1B, str);
            format(str, sizeof(str), "   * You have been cuffed by %s *",name);
            SendClientMessage(targetid, 0xE01B1B, str);
            SetPlayerAttachedObject(targetid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000);
            SetPlayerSpecialAction(targetid,SPECIAL_ACTION_CUFFED);
        }

    }
    return 1;
}

CMD:uncuff(playerid, params[])
{
    if(gTeam[playerid] != Cops) return SendClientMessage(playerid, -1, "   * You aren't a cop *");
    new targetid;
    if(sscanf(params, "r", targetid)) return SendClientMessage(playerid, -1, "   * /uncuff  Name/ID *");
    if(IsPlayerConnected(targetid))
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        if(IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))
        {
            if(!SetPlayerAttachedObject(targetid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000))
            return SendClientMessage(playerid,-1,"ERROR: The player is not cuffed!");
            SetPlayerSpecialAction(targetid,SPECIAL_ACTION_NONE);
            new str[60];
            new name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));
            new target[MAX_PLAYER_NAME];
            GetPlayerName(targetid, target, sizeof(target));
            format(str, sizeof(str), "   * You have uncuffed %s *",target);
            SendClientMessage(playerid, 0xE01B1B, str);
            format(str, sizeof(str), "   * You have been uncuffed by %s *",name);
            SendClientMessage(targetid, 0xE01B1B, str);
        }

    }
    return 1;
}
They work perfectly , Just posted them here if that may help you with helping me, if you need anymore information let me know and I will provide it.

My idea of an /arrest command is that the player will be sent to jail with a timer displayed how long he will stay in there, depending on his wanted level when he got arrested. It will be only for cops to use, ofc and the player must be Cuffed first in order to arrest him. When he has done his time in jail he will respawn outside LSPD.

I have tried to understand others arrest command but I fail at it.

I don't want you to provide me full script for me(unless you want to!). I want you to guide me to make my own as I prefer to learn and not just Copy/paste.


Much thanks in advance!.


Re: /ar cmd - AhmedMohamed - 26.03.2014

top of the script:
pawn Код:
new pCuffed[MAX_PLAYERS];
pawn Код:
CMD:arrest(playerid, params[])
{
new targetid, time, string[128];
if(gTeam[playerid] != Cops) return SendClientMessage(playerid, -1, "   * You aren't a cop *");
if(sscanf(params, "ui", targetid, time)) return SendClientMessage(playerid, -1, "   * /arrest  Name/ID *");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xAFAFAFFF, "Invalid player id.");
if(!IsPlayerNearPlayer(playerid, targetid, 2)) return SendClientMessage(playerid, 0xAFAFAFFF, "You are too far away from that player.");
if(!pCuffed(playerid) == 1) return SendClientMessage(playerid, 0xAFAFAFFF, "Player Isn't Cuffed!");
format(str, sizeof(str), "   * You have arrested %s *",GetPlayerName(targetid));
SendClientMessage(playerid, 0xE01B1B, str);
format(str, sizeof(str), "   * You have been arrested by %s *",GetPlayerName(playerid));
SendClientMessage(targetid, 0xE01B1B, str);
SetPlayerInterior(targetid, 0);
SetPlayerVirtualWorld(targetid, 0);
SetPlayerPos(targetid, 263.343597, 77.532028, 1001.039062);
RemovePlayerAttachedObject(playerb, 0);
SetTimer("Arrest", time, true);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_NONE);
return 1;
}
and here is the Stock
pawn Код:
stock IsPlayerNearPlayer(playerid, targetid, Float:radius)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(targetid, x, y, z);
    if(IsPlayerInRangeOfPoint(playerid, radius ,x, y, z))
    {
        return 1;
    }
    return 0;
}
Read it well and you will understand.

and the
pawn Код:
(sscanf(params, "r", targetid))
on the cuff command must be like that
pawn Код:
if(sscanf(params, "u", targetid))
add that in your cuff command
pawn Код:
pCuffed(playerid) == 1;
and in your uncuff command add this
pawn Код:
pCuffed(playerid) == 0;



Re: /ar cmd - AhmedMohamed - 26.03.2014

you wanna it like
/arrest [id] [time]
or
/arrest [id]??


Re: /ar cmd - AhmedMohamed - 26.03.2014

you there?


Re: /ar cmd - Stinged - 26.03.2014

Quote:
Originally Posted by AhmedMohamed
Посмотреть сообщение
top of the script:
and the
pawn Код:
(sscanf(params, "r", targetid))
on the cuff command must be like that
pawn Код:
if(sscanf(params, "u", targetid))
Read the sscanf page again. u is for PLAYERS & BOTS | r is for PLAYERS
So he probably uses r because he doesn't want people to arrest NPCs.


Re: /ar cmd - AhmedMohamed - 26.03.2014

ah okay sorry , check it any errors while complie?


Re: /ar cmd - AhmedMohamed - 26.03.2014

you there?


Re: /ar cmd - AhmedMohamed - 26.03.2014

so +rep me please


Re: /ar cmd - Sergeant - 27.03.2014

I was away for a while, and yeah there is errors when I compile, on
pCuffed(playerid) == 1;
pCuffed(playerid) == 0;
if(!pCuffed(playerid) == 1) return SendClientMessage(playerid, 0xAFAFAFFF, "Player Isn't Cuffed!");


pawn Код:
C:\Users\Sergeant Schizo\Desktop\Project SA-MP\gamemodes\Project.pwn(1275) : error 012: invalid function call, not a valid address
C:\Users\Sergeant Schizo\Desktop\Project SA-MP\gamemodes\Project.pwn(1275) : warning 215: expression has no effect
C:\Users\Sergeant Schizo\Desktop\Project SA-MP\gamemodes\Project.pwn(1275) : error 001: expected token: ";", but found ")"
C:\Users\Sergeant Schizo\Desktop\Project SA-MP\gamemodes\Project.pwn(1275) : error 029: invalid expression, assumed zero
C:\Users\Sergeant Schizo\Desktop\Project SA-MP\gamemodes\Project.pwn(1275) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.



Re: /ar cmd - RenovanZ - 27.03.2014

Quote:
Originally Posted by AhmedMohamed
Посмотреть сообщение
so +rep me please
Dont bump the post.

Quote:
Originally Posted by Sergeant
Посмотреть сообщение
I was away for a while, and yeah there is errors when I compile, on
pCuffed(playerid) == 1;
pCuffed(playerid) == 0;
if(!pCuffed(playerid) == 1) return SendClientMessage(playerid, 0xAFAFAFFF, "Player Isn't Cuffed!");


pawn Код:
C:\Users\Sergeant Schizo\Desktop\Project SA-MP\gamemodes\Project.pwn(1275) : error 012: invalid function call, not a valid address
C:\Users\Sergeant Schizo\Desktop\Project SA-MP\gamemodes\Project.pwn(1275) : warning 215: expression has no effect
C:\Users\Sergeant Schizo\Desktop\Project SA-MP\gamemodes\Project.pwn(1275) : error 001: expected token: ";", but found ")"
C:\Users\Sergeant Schizo\Desktop\Project SA-MP\gamemodes\Project.pwn(1275) : error 029: invalid expression, assumed zero
C:\Users\Sergeant Schizo\Desktop\Project SA-MP\gamemodes\Project.pwn(1275) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Show us the line.