Help with /drag command. -
Zachlive - 07.10.2012
Hello, I need help with my /drag command, it doesn't drag the player..
Here is the timer..
Код:
SetTimerEx("ExecuteDrag", 1000, true); //It will run once a second
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;
}
Here are the /drag commands
Код:
CMD:drag(playerid, params[])
{
if(IsACop(playerid))
{
new string[128], giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /drag [playerid]");
if(IsPlayerConnected(giveplayerid))
{
if(GetPVarInt(giveplayerid, "PlayerCuffed") == 2)
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_WHITE, " You must be out of the vehicle to use this command.");
if(GetPVarInt(giveplayerid, "BeingDragged") == 1) return SendClientMessage(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 SendClientMessage(playerid, COLOR_GRAD2, " That suspect is not near you.");
format(string, sizeof(string), "* %s has is now dragging you.", GetPlayerNameEx(playerid));
SendClientMessage(giveplayerid, COLOR_WHITE, string);
format(string, sizeof(string), "* You are now dragging %s, you may move them now.", GetPlayerNameEx(giveplayerid));
SetTimer("ExecuteDrag", 1000, true);
SendClientMessage(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);
SetPVarInt(giveplayerid, "BeingDragged", 1);
SetPVarInt(playerid, "DraggingPlayer", giveplayerid);
return 1;
}
else return SendClientMessage(playerid, COLOR_WHITE, " The player is not cuffed !");
} else return SendClientMessage(playerid, COLOR_WHITE, " The player is not connected !");
}
else return SendClientMessage(playerid, COLOR_GREY, " You are not a Cop ! ");
}
CMD:stopdrag(playerid, params[])
{
if(IsACop(playerid))
{
new string[128], giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /stopdrag [playerid]");
if(IsPlayerConnected(giveplayerid))
{
if(GetPVarInt(giveplayerid, "PlayerCuffed") == 2)
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_WHITE, " You must be out of the vehicle to use this command.");
new Float:dX, Float:dY, Float:dZ;
GetPlayerPos(giveplayerid, dX, dY, dZ);
if(!IsPlayerInRangeOfPoint(playerid, 5.0, dX, dY, dZ)) return SendClientMessage(playerid, COLOR_GRAD2, " That suspect is not near you.");
SendClientMessage(giveplayerid, COLOR_WHITE, string);
SetTimer("ExecuteDrag", 1000, false);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "* %s releases his drag on %s", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
else return SendClientMessage(playerid, COLOR_WHITE, " The player is not cuffed !");
} else return SendClientMessage(playerid, COLOR_WHITE, " The player is not connected !");
}
else return SendClientMessage(playerid, COLOR_GREY, " You are not a Cop ! ");
}
Re: Help with /drag command. -
WuMing - 11.11.2013
Hi Try this one
Код HTML:
CMD:drag(playerid, params[])
{
if(IsACop(playerid))
{
new string[128], giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /drag [playerid]");
if(IsPlayerConnected(giveplayerid))
{
if(GetPVarInt(giveplayerid, "PlayerCuffed") == 2)
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_WHITE, " You must be out of the vehicle to use this command.");
if(GetPVarInt(giveplayerid, "BeingDragged") == 1)
{
SendClientMessageEx(playerid, COLOR_WHITE, " That player is already being dragged. ");
return 1;
}
new Float:dX, Float:dY, Float:dZ;
GetPlayerPos(giveplayerid, dX, dY, dZ);
if(!IsPlayerInRangeOfPoint(playerid, 5.0, dX, dY, dZ))
{
SendClientMessageEx(playerid, COLOR_GRAD2, " That suspect is not near you.");
return 1;
}
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, "BeingDragged", playerid);
SetPVarInt(playerid, "DraggingPlayer", 1);
}
else
{
SendClientMessageEx(playerid, COLOR_WHITE, " The specified player is not cuffed !");
}
}
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, " You are not a LEO ! ");
return 1;
}
return 0;
}
Re: Help with /drag command. -
FaZeRs - 02.02.2014
Got this kind of errors
PHP код:
C:\Users\Euronics Latvija\Desktop\LCRP\gamemodes\nlrp.pwn(7233 -- 7234) : error 029: invalid expression, assumed zero
C:\Users\Euronics Latvija\Desktop\LCRP\gamemodes\nlrp.pwn(7234) : warning 215: expression has no effect
C:\Users\Euronics Latvija\Desktop\LCRP\gamemodes\nlrp.pwn(11355) : warning 202: number of arguments does not match definition
C:\Users\Euronics Latvija\Desktop\LCRP\gamemodes\nlrp.pwn(15817) : error 029: invalid expression, assumed zero
Lines
PHP код:
if(GetPVarInt(ID,"BeingDraggedBy") != playerid)
KillTimer(GetPVarInt(ID,"DragTimer")),