29.07.2012, 15:25
pawn Код:
#define DRAG_RANGE 5
//Global variable
forward ExecuteDrag();
//in ongamemodeinit
SetTimer("ExecuteDrag", 1000, true); //It will run once a second
//Outside any callbacks
public ExecuteDrag() {
for(new playerid = 0; playerid < MAX_PLAYERS; playerid++) {
if(1 != GetPVarInt(playerid, "BeingDragged")) continue;
else {
new draggerid = GetPVarInt(playerid, "DraggingPlayer"), Float:dpos[3], Float:ppos[3];
GetPlayerPos(draggerid, dpos[0], dpos[1], dpos[2]);
GetPlayerPos(playerid, ppos[0], ppos[1], ppos[2]);
new Float:diff[3], Float:tmp, Float:newpos[3];
for(new i = 0; i < 3; i++) {
tmp = dpos[i] - ppos[i];
diff[i] = ((tmp < 0) ? (-tmp) : (tmp));
if(diff[i] > DRAG_RANGE) {
newpos[i] = (dpos[i] + (DRAG_RANGE - 3));
}
}
}
}
return 1;
}
E:
You might want to remove the timer when there are no dragged players. I'll leave this to you and wiki