21.06.2014, 03:42
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);
}