/ar cmd
#1

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!.
Reply
#2

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;
Reply
#3

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

you there?
Reply
#5

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.
Reply
#6

ah okay sorry , check it any errors while complie?
Reply
#7

you there?
Reply
#8

so +rep me please
Reply
#9

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)