Dragging random peoples when they are connecting. why? :( ( BUG ) at my server
#1

A /drag cmd and when someone use it and the dragged player disconnect then when a random people connect to server they are being drag with a random player. Why? Thanks guys

pawn Код:
CMD:grab(playerid, params[]) return cmd_restrain(playerid, params);
CMD:drag(playerid, params[]) return cmd_restrain(playerid, params);
CMD:unrestrain(playerid, params[]) return cmd_restrain(playerid, params);
CMD:restrain(playerid, params[])
{
    if(IsACop(playerid) || PlayerInfo[playerid][pFaction] == 5 && PlayerInfo[playerid][pDivision] == 5 || PlayerInfo[playerid][pFaction] == 5 && PlayerInfo[playerid][pDivision] == 2) {
        new id, string[ 128 ];
        if( sscanf( params, "u", id ) )
            return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /drag [playerid/partofname]");

        if(!IsPlayerConnected(id))
            return SendClientMessage(playerid, COLOR_GREY, "Invalid player specified.");

        if(GetDistanceBetweenPlayers(id, playerid) > 4)
            return SendClientMessage(playerid, COLOR_GREY, "You're not close enough to the player!");

        if(PlayerCuffed[id] == 0)
            return SendClientMessage(playerid, COLOR_GREY, "That person isn't cuffed.");

        if(PlayerCuffed[id] == 1)
            return SendClientMessage(playerid, COLOR_GREY, "You can't drag a tazed player.");

        if(id == playerid)
            return SendClientMessage(playerid, COLOR_GREY, "You can't restrain yourself!");

        if(GetPlayerState(id) != PLAYER_STATE_ONFOOT)
            return SendClientMessage(playerid, COLOR_GREY, "That person is in a car - get them out first.");

        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT)
            return SendClientMessage(playerid, COLOR_GREY, "You're in a car - get out first.");

        if(GetPVarInt(playerid, "PBM") > 0)
            return SendClientMessage(playerid, COLOR_WHITE, "You're not able to do this while in a paintball game.");

        if(GetPVarInt(playerid, "EventToken") != 0)
            return SendClientMessage(playerid, COLOR_GREY, "You can't use the tazer while you're in an event.");

        if(PlayerCuffedTime[playerid] > 0)
            return SendClientMessage(playerid, COLOR_GREY, "You can't do this right now.");

        if(GetPVarInt(playerid, "Injured") == 1)
            return SendClientMessage(playerid, COLOR_GREY, "You can't do this right now.");

        if(PlayerInfo[playerid][pJailed] > 0)
            return SendClientMessage(playerid, COLOR_WHITE, "You can't use this in jail/prison.");

        if(PlayerCuffed[playerid] >= 1)
            return SendClientMessage(playerid, COLOR_WHITE, "You can't use this while tazed/cuffed.");

        if(GetPVarInt(id, "Injured") == 1)
            return SendClientMessage(playerid, COLOR_GREY, "You can't cuff injured people.");

        if(PlayerDragged[id] == 1) {
            format(string, sizeof(string), "* %s looks into %s's eyes and then slowly releases them.", GetPlayerNameEx(playerid), GetPlayerNameEx(id));
            ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            GameTextForPlayer(id, "~r~Released!", 2500, 3);
            IsCopDragging[PlayerDraggedBy[id]] = INVALID_PLAYER_ID;
            PlayerDragged[id] = 0;
            PlayerDraggedBy[id] = INVALID_PLAYER_ID;
            DeletePVar(playerid, "Dragging");
            KillTimer(draggedtimer[id]);
        } else {
            format(string, sizeof(string), "* %s quickly grabs %s by the right arm, restraining them.", GetPlayerNameEx(playerid), GetPlayerNameEx(id));
            ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            GameTextForPlayer(id, "~r~Restrained!", 2500, 3);
            ApplyAnimation(id, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0, 1);
            SetPlayerSpecialAction(id, SPECIAL_ACTION_CUFFED);
            PlayerDragged[id] = 1;
            PlayerDraggedBy[id] = playerid;
            IsCopDragging[playerid] = id;
            SetPVarInt(playerid, "Dragging", id);
            draggedtimer[id] = SetTimerEx("Draggingt", 1000, 1, "dd", playerid,id);
        }
    }
    else SendClientMessage(playerid, COLOR_GREY, "   You're not a Cop / FBI!");
    return true;
}

forward Draggingt(playerid, ID);
public Draggingt(playerid, ID)
{
        new Float:dX, Float:dY, Float:dZ;
        GetPlayerPos(playerid, dX, dY, dZ);
        SetPlayerPos(ID, dX+1, dY, dZ);
}
Reply
#2

Your OnPlayerConnect Please, it is detecting wrongly there. As far as i know you should have anti drag or similar avoid system.
Reply
#3

Quote:
Originally Posted by Laurey
Посмотреть сообщение
Your OnPlayerConnect Please, it is detecting wrongly there. As far as i know you should have anti drag or similar avoid system.

pawn Код:
public OnPlayerConnect(playerid) {

//================== Custom Removed Objects in map =============================


    pMask[playerid] = 0;
   
    if(IsCopDragging[playerid] != INVALID_PLAYER_ID)
    {
        PlayerDraggedBy[IsCopDragging[playerid]] = INVALID_PLAYER_ID;
        PlayerDragged[IsCopDragging[playerid]] = 0;
        KillTimer(draggedtimer[playerid]);
       
        IsCopDragging[playerid] = INVALID_PLAYER_ID;
        PlayerDraggedBy[playerid] = INVALID_PLAYER_ID;
        PlayerDragged[playerid] = 0;
    }
Reply
#4

My bad, Post the OnPlayerDisconnect too :P
Reply
#5

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
   
    if(IsCopDragging[playerid] != INVALID_PLAYER_ID)
    {
        PlayerDraggedBy[IsCopDragging[playerid]] = INVALID_PLAYER_ID;
        PlayerDragged[IsCopDragging[playerid]] = 0;
        KillTimer(draggedtimer[playerid]);
       
        IsCopDragging[playerid] = INVALID_PLAYER_ID;
        PlayerDraggedBy[playerid] = INVALID_PLAYER_ID;
        PlayerDragged[playerid] = 0;
    }
Reply
#6

Try using foreach that looks confusing, give it a try and let me know.
Reply
#7

Quote:
Originally Posted by Laurey
Посмотреть сообщение
Try using foreach that looks confusing, give it a try and let me know.
With this foreach, im so very confused

I try this code.

pawn Код:
foreach(Player, i)
    {
        if(IsCopDragging[playerid] != INVALID_PLAYER_ID)
        {
            PlayerDraggedBy[IsCopDragging[playerid]] = INVALID_PLAYER_ID;
            PlayerDragged[IsCopDragging[i]] = 0;
            KillTimer(draggedtimer[playerid]);

            IsCopDragging[i] = INVALID_PLAYER_ID;
            PlayerDraggedBy[i] = INVALID_PLAYER_ID;
            PlayerDragged[i] = 0;
        }
    }
Reply
#8

Your OnPlayerDisconnect and OnPlayerConnect doesn't make any sense.
How can the playerid be the cop dragging and the player dragged?
Reply
#9

pawn Код:
CMD:drag(playerid, params[])
{
    if(IsACop(playerid))
    {
        new string[128], giveplayerid;
        if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /drag [playerid]");

        if(IsPlayerConnected(giveplayerid))
        {
            if(GetPVarInt(giveplayerid, "PlayerCuffed") == 2)
            {
                if(IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_WHITE, " You must be out of the vehicle to use this command.");
                if(GetPVarInt(giveplayerid, "BeingDragged") == 1)
                {
                    SendClientMessageEx(playerid, COLOR_WHITE, " That person is already being dragged. ");
                    return 1;
                }
                new Float:dX, Float:dY, Float:dZ;
                GetPlayerPos(giveplayerid, dX, dY, dZ);
                if(!IsPlayerInRangeOfPoint(playerid, 5.0, dX, dY, dZ))
                {
                    SendClientMessageEx(playerid, COLOR_GRAD2, " That suspect is not near you.");
                    return 1;
                }
                format(string, sizeof(string), "* %s is now dragging you.", GetPlayerNameEx(playerid));
                SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
                format(string, sizeof(string), "* You are now dragging %s, you may move them now.", GetPlayerNameEx(giveplayerid));
                SendClientMessageEx(playerid, COLOR_WHITE, string);
                format(string, sizeof(string), "* %s grabs ahold of %s and begins to move them.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                SendClientMessageEx(playerid, COLOR_WHITE, "You are now dragging the suspect, press the '{AA3333}FIRE{FFFFFF}' button to stop.");
                SetPVarInt(giveplayerid, "BeingDragged", 1);
                SetPVarInt(playerid, "DraggingPlayer", giveplayerid);
                SetTimerEx("DragPlayer", 1000, 0, "ii", playerid, giveplayerid);
            }
            else
            {
                SendClientMessageEx(playerid, COLOR_WHITE, " The specified person is not cuffed !");
            }
        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GREY, "You are not a Law Enforcement Official!");
        return 1;
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Your OnPlayerDisconnect and OnPlayerConnect doesn't make any sense.
How can the playerid be the cop dragging and the player dragged?
Please bring the code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)