drag command
#1

i have made this command but it shows error
command:
pawn Код:
new Dragging[MAX_PLAYERS] = 0;
new DraggingID[MAX_PLAYERS] = -1;
new DraggedBy[MAX_PLAYERS] = -1;
new GettingDragged[MAX_PLAYERS] = 0;
new dragtimer[MAX_PLAYERS];
CMD:drag(playerid, params[])
{
    if(IsACop(playerid) || IsANG(playerid) || IsAFBI(playerid))
    {
        new target, Float:X, Float:Y, Float:Z;
        if(sscanf(params, "u", target))
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /drag [playerid/PartOfName]");
            return 1;
        }
        if(IsPlayerInAnyVehicle(target))
        {
            SendClientMessage(playerid, COLOR_GREY, "   Suspect is in a car, get him out first !");
            return 1;
        }
        if(GettingDragged[target] == 1)
        {
            format(string, sizeof(string), "* %s looks into %s's eyes and then slowly releases them.", PlayerRPName(playerid), PlayerRPName(target));
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            KillTimer(dragtimer[DraggedBy[target]]);
            DraggingID[DraggedBy[target]] = -1;
            Dragging[DraggedBy[target]] = 0; //error line
            DraggedBy[target] = -1;
            GettingDragged[target] = 0;
        }
        else
        {
            if(PlayerCuffed[target] > 1)
            {
                GettingDragged[target] = 1;
                DraggedBy[target] = playerid;
                DraggingID[playerid] = target;
                Dragging[playerid] = 1;
                format(string, sizeof(string), "* %s quickly grabs %s by the right arm, restraining them.", PlayerRPName(playerid), PlayerRPName(target));
                ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetPlayerPos(playerid, X Y, Z);
                SetPlayerPos(target, X,Y,Z);
                dragtimer[playerid] = SetTimerEx("Dragging", 1000,0,"ii",playerid, target);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "That player is not cuffed.");
            }
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GRAD2, "   You are not authorized to use that command !");
    }
    return 1;
}
errors:
pawn Код:
C:\Users\John\Desktop\Malek\Amagin\gamemodes\imagine.pwn(32492) : error 028: invalid subscript (not an array or too many subscripts): "Dragging"
C:\Users\John\Desktop\Malek\Amagin\gamemodes\imagine.pwn(32492) : warning 215: expression has no effect
C:\Users\John\Desktop\Malek\Amagin\gamemodes\imagine.pwn(32492) : error 001: expected token: ";", but found "]"
C:\Users\John\Desktop\Malek\Amagin\gamemodes\imagine.pwn(32492) : error 029: invalid expression, assumed zero
C:\Users\John\Desktop\Malek\Amagin\gamemodes\imagine.pwn(32492) : 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
#2

Whats the 32492 string?
Reply
#3

try Playerid in there,as that player would be draging them. Also, your code is A LOT longer than it needs to be, let me clean it up for you at the same time.

pawn Код:
new Dragging[MAX_PLAYERS], DraggingID[MAX_PLAYERS] = -1, DraggedBy[MAX_PLAYERS] = -1, GettingDragged[MAX_PLAYERS], dragtimer[MAX_PLAYERS];

CMD:drag(playerid, params[])
{
    if(IsACop(playerid) || IsANG(playerid) || IsAFBI(playerid))
    {
        new target, Float:X, Float:Y, Float:Z;
        if(sscanf(params, "u", target)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /drag [playerid/PartOfName]");

        if(IsPlayerInAnyVehicle(target)) return SendClientMessage(playerid, COLOR_GREY, "   Suspect is in a car, get him out first !");

        if(GettingDragged[target] == 1)
        {
            format(string, sizeof(string), "* %s looks into %s's eyes and then slowly releases them.", PlayerRPName(playerid), PlayerRPName(target));
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            KillTimer(dragtimer[DraggedBy[target]]);
            DraggingID[DraggedBy[target]] = -1;
            Dragging[playerid] = 0; //error line
            DraggedBy[target] = -1;
            GettingDragged[target] = 0;
        }
        else if(PlayerCuffed[target] > 1)
        {
            GettingDragged[target] = 1;
            DraggedBy[target] = playerid;
            DraggingID[playerid] = target;
            Dragging[playerid] = 1;
            format(string, sizeof(string), "* %s quickly grabs %s by the right arm, restraining them.", PlayerRPName(playerid), PlayerRPName(target));
            ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            GetPlayerPos(playerid, X Y, Z);
            SetPlayerPos(target, X,Y,Z);
            dragtimer[playerid] = SetTimerEx("Dragging", 1000,0,"ii",playerid, target);
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "That player is not cuffed.");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GRAD2, "   You are not authorized to use that command !");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)