drag help
#8

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;
}
Dirty and untested, but try it.

E:
You might want to remove the timer when there are no dragged players. I'll leave this to you and wiki
Reply


Messages In This Thread
drag help - by BurgerWoman - 29.07.2012, 13:20
Re: drag help - by Misiur - 29.07.2012, 13:29
Re: drag help - by BurgerWoman - 29.07.2012, 13:51
Re: drag help - by Misiur - 29.07.2012, 13:56
Re: drag help - by BurgerWoman - 29.07.2012, 14:01
Re: drag help - by Misiur - 29.07.2012, 14:09
Re: drag help - by BurgerWoman - 29.07.2012, 14:13
Re: drag help - by Misiur - 29.07.2012, 15:25

Forum Jump:


Users browsing this thread: 1 Guest(s)