03.02.2014, 13:13
When i drag player it don't moves. http://www.bildites.lv/images/d8tcc32mu927us27942z.png
Drag System
Drag System
PHP код:
// Dragging
new Drag[MAX_PLAYERS];
new Dragged[MAX_PLAYERS];
forward Draggingt(playerid);
public Draggingt(playerid)
{
if(GetPVarInt(playerid,"BeingDraggedBy") != playerid)
{
KillTimer(GetPVarInt(playerid,"DragTimer"));
return 1;
}
new Float:fX, Float:fY, Float:fZ, int, vw;
vw = GetPlayerVirtualWorld(playerid);
int = GetPlayerInterior(playerid);
SetPlayerVirtualWorld(playerid, vw);
SetPlayerInterior(playerid, int);
GetPlayerPos(playerid, fX,fY,fZ);
GetXYInFrontOfPlayer(playerid, fX,fY,1.0);
SetPlayerPos(playerid, fX,fY,fZ);
return 1;
}
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid, "BeingDraggedBy", INVALID_PLAYER_ID);
SetPVarInt(playerid, "DraggingPlayer", INVALID_PLAYER_ID);
Drag[playerid] = -1; Dragged[playerid] = -1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(GetPVarInt(playerid,"DraggingPlayer") != -1)
{
new dragging = GetPVarInt(playerid,"DraggingPlayer");
KillTimer(GetPVarInt(dragging,"DragTimer"));
SetPVarInt(dragging, "BeingDraggedBy", -1);
SetPVarInt(dragging, "DraggingPlayer", -1);
}
if(GetPVarInt(playerid,"BeingDraggedBy") != -1)
{
new cop = GetPVarInt(playerid,"BeingDraggedBy");
KillTimer(GetPVarInt(playerid,"DragTimer"));
SetPVarInt(playerid, "BeingDraggedBy", -1);
SetPVarInt(cop, "DraggingPlayer", -1);
}
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_FIRE)
{
if(GetPVarInt(playerid,"DraggingPlayer") != -1)
{
new string[128];
new giveplayerid = GetPVarInt(playerid, "DraggingPlayer");
SetPVarInt(playerid, "DraggingPlayer", -1);
SetPVarInt(giveplayerid, "BeingDragged", -1);
KillTimer(GetPVarInt(giveplayerid,"DragTimer"));
format(string, sizeof(string), "You have stopped dragging %s.", GetPlayerNameEx(giveplayerid));
SendClientMessageEx(playerid, COLOR_GRAD3, string);
format(string, sizeof(string), "* Officer %s has stopped dragging you.", GetPlayerNameEx(playerid));
SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
format(string, sizeof(string), "* %s stops dragging %s - letting them free.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
}
CMD:drag(playerid, params[])
{
if(!IsACop(playerid))
return SendClientMessageEx(playerid, COLOR_GREY, " You are not a LEO ! ");
new string[128], giveplayerid;
if(sscanf(params, "u", giveplayerid))
return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /drag [playerid]");
if(!IsPlayerConnected(giveplayerid))
return 1;
if(GetPVarInt(giveplayerid, "PlayerCuffed") != 2)
return SendClientMessageEx(playerid, COLOR_WHITE, " The specified player is not cuffed !");
if(IsPlayerInAnyVehicle(playerid))
return SendClientMessageEx(playerid, COLOR_WHITE, " You must be out of the vehicle to use this command.");
if(GetPVarInt(giveplayerid, "BeingDraggedBy") != INVALID_PLAYER_ID)
return SendClientMessageEx(playerid, COLOR_WHITE, " That player is already being dragged. ");
new Float:dX, Float:dY, Float:dZ;
GetPlayerPos(giveplayerid, dX, dY, dZ);
if(!IsPlayerInRangeOfPoint(playerid, 5.0, dX, dY, dZ))
return SendClientMessageEx(playerid, COLOR_GRAD2, " That suspect is not near you.");
format(string, sizeof(string), "* %s has is now dragging you.", GetPlayerNameEx(playerid));
SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
format(string, sizeof(string), "* You are now dragging %s, you may move them now.", GetPlayerNameEx(giveplayerid));
SendClientMessageEx(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "* %s grabs ahold of %s and begins to move them.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SendClientMessageEx(playerid, COLOR_WHITE, "You are now dragging the suspect, press the '{AA3333}FIRE{FFFFFF}' button to stop.");
SetPVarInt(giveplayerid, "BeingDraggedBy", playerid);
SetPVarInt(playerid, "DraggingPlayer", giveplayerid);
SetPVarInt(giveplayerid,"DragTimer", SetTimerEx("dragplayer", 1000, true, "ii", playerid,giveplayerid));
return 1;
}