02.02.2014, 01:55
Quote:
So can i do like this?
PHP код:
|
Use this function
pawn Код:
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
forward Draggingt(playerid, ID);
public Draggingt(playerid, ID)
{
if(Dragged[ID] != playerid)
KillTimer(draggedtimer[ID]),
return 1; //just in case.
new Float:fX, Float:fY, Float:fZ;
GetPlayerPos(playerid, fX,fY,fZ);
GetXYInFrontOfPlayer(playerid, fX,fY,1.0);
SetPlayerPos(ID, fX,fY,fZ);
return 1;
}
//little improvement
CMD:drag(playerid, params[])
{
new ID, string[26+MAX_PLAYER_NAME], string2[20+MAX_PLAYER_NAME];
if(sscanf(params, "u", ID)) return SendClientMessage(playerid, GREY, "CMD:/drag [playerid]");
if(pCuffed[ID] == 0) return SendClientMessage(playerid, GREY, "This player must first be cuffed");
if(Dragged[ID] == INVALID_PLAYER_ID && Dragging[playerid] == INVALID_PLAYER_ID)
{
Dragged[ID] = playerid;
Dragging[playerid] = ID;
format(string, sizeof(string), "You are being dragged by %s.", RemoveUnderScore(playerid));
format(string2, sizeof(string2), " You are dragging %s.", RemoveUnderScore(ID));
SCM(playerid, PURPLE, string2);
SCM(ID, PURPLE, string);
draggedtimer[ID] = SetTimerEx("Draggingt", 1000, 1, "dd", playerid,ID);
}
else if(Dragged[ID] == playerid && Dragging[playerid] == ID)
{
Dragged[ID] = INVALID_PLAYER_ID;
Dragging[playerid] = INVALID_PLAYER_ID;
SCM(playerid, PURPLE, "You have stopped dragging your target.");
SCM(ID, PURPLE, "You aren't being dragged anymore.");
KillTimer(draggedtimer[ID]);
}
return 1;
}
pawn Код:
Dragged[playerid] = INVALID_PLAYER_ID;
Dragging[playerid] = INVALID_PLAYER_ID;
pawn Код:
if(Dragging[playerid] != INVALID_PLAYER_ID)
{
KillTimer(draggedtimer[Dragging[playerid]]);
Dragged[Dragging[playerid]] = INVALID_PLAYER_ID;
Dragging[playerid] = INVALID_PLAYER_ID;
}
if(Dragged[playerid] != INVALID_PLAYER_ID)
{
Dragging[Dragged[playerid]] = INVALID_PLAYER_ID;
Dragged[playerid] = INVALID_PLAYER_ID;
KillTimer(draggedtimer[playerid]);
}