06.06.2009, 09:40
Put this at the top of your script:
Put this in OnPlayerCommandText:
Put this anywhere in your script:
Not tested and I'm not 100% sure what will happen if more than one person drags. Also I've not added any messages so you might want to.
Код:
new DragTimer[MAX_PLAYERS]; forward Drag(draggerid, playerid);
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[30];
new tmp[30];
new idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/drag", false)==0)
{
if(DragTimer[playerid] < 0)
{
tmp = strtok(cmdtext, idx);
new draggedid = strval(tmp);
if(IsPlayerConnected(draggedid) == 1)
{
DragTimer[playerid] = SetTimerEx("Drag", 2000, 1, "ii", draggedid, playerid);
return 1;
}
}
}
if(strcmp(cmd, "/undrag", false) == 0)
{
if(DragTimer[playerid] >= 0)
{
KillTimer(DragTimer[playerid]);
DragTimer[playerid] = 0;
return 1;
}
}
return 0
}
Код:
public Drag(draggerid, playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(draggerid, x, y, z);
SetPlayerPos(playerid, x, y, z + 2);
SetPlayerInterior(playerid, GetPlayerInterior(draggerid));
}
}

