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;
}
forward Draggingt(playerid, ID);
public Draggingt(playerid, ID)
{
new Float:dX, Float:dY, Float:dZ;
GetPlayerPos(playerid, dX, dY, dZ);
SetPlayerPos(ID, dX+1, dY, dZ);
}
CMD:drag(playerid, params[])
{
new ID, string[26+MAX_PLAYER_NAME], string2[20+MAX_PLAYER_NAME];
if(sscanf(params, "u", ID)) return SendClientMessage(playerid, GREY, "CMD:/drag [playerid]");
if(pCuffed[ID] == 0) return SendClientMessage(playerid, GREY, "This player must first be cuffed");
if(Dragged[ID] == 0 && Dragging[playerid] == 0)
{
Dragged[ID] = 1;
Dragging[playerid] = 1;
format(string, sizeof(string), "You are being dragged by %s.", RemoveUnderScore(playerid));
format(string2, sizeof(string2), " You are dragging %s.", RemoveUnderScore(ID));
SCM(playerid, PURPLE, string2);
SCM(ID, PURPLE, string);
draggedtimer[ID] = SetTimerEx("Draggingt", 1000, 1, "dd", playerid,ID);
}
else
{
Dragged[ID] = 0;
Dragging[playerid] = 0;
SCM(playerid, PURPLE, "You have stopped dragging your target.");
SCM(ID, PURPLE, "You aren't being dragged anymore.");
KillTimer(draggedtimer[ID]);
}
return 1;
}
So can i do like this?
PHP код:
|
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
forward Draggingt(playerid, ID);
public Draggingt(playerid, ID)
{
if(Dragged[ID] != playerid)
KillTimer(draggedtimer[ID]),
return 1; //just in case.
new Float:fX, Float:fY, Float:fZ;
GetPlayerPos(playerid, fX,fY,fZ);
GetXYInFrontOfPlayer(playerid, fX,fY,1.0);
SetPlayerPos(ID, fX,fY,fZ);
return 1;
}
//little improvement
CMD:drag(playerid, params[])
{
new ID, string[26+MAX_PLAYER_NAME], string2[20+MAX_PLAYER_NAME];
if(sscanf(params, "u", ID)) return SendClientMessage(playerid, GREY, "CMD:/drag [playerid]");
if(pCuffed[ID] == 0) return SendClientMessage(playerid, GREY, "This player must first be cuffed");
if(Dragged[ID] == INVALID_PLAYER_ID && Dragging[playerid] == INVALID_PLAYER_ID)
{
Dragged[ID] = playerid;
Dragging[playerid] = ID;
format(string, sizeof(string), "You are being dragged by %s.", RemoveUnderScore(playerid));
format(string2, sizeof(string2), " You are dragging %s.", RemoveUnderScore(ID));
SCM(playerid, PURPLE, string2);
SCM(ID, PURPLE, string);
draggedtimer[ID] = SetTimerEx("Draggingt", 1000, 1, "dd", playerid,ID);
}
else if(Dragged[ID] == playerid && Dragging[playerid] == ID)
{
Dragged[ID] = INVALID_PLAYER_ID;
Dragging[playerid] = INVALID_PLAYER_ID;
SCM(playerid, PURPLE, "You have stopped dragging your target.");
SCM(ID, PURPLE, "You aren't being dragged anymore.");
KillTimer(draggedtimer[ID]);
}
return 1;
}
Dragged[playerid] = INVALID_PLAYER_ID;
Dragging[playerid] = INVALID_PLAYER_ID;
if(Dragging[playerid] != INVALID_PLAYER_ID)
{
KillTimer(draggedtimer[Dragging[playerid]]);
Dragged[Dragging[playerid]] = INVALID_PLAYER_ID;
Dragging[playerid] = INVALID_PLAYER_ID;
}
if(Dragged[playerid] != INVALID_PLAYER_ID)
{
Dragging[Dragged[playerid]] = INVALID_PLAYER_ID;
Dragged[playerid] = INVALID_PLAYER_ID;
KillTimer(draggedtimer[playerid]);
}
C:\Users\Euronics Latvija\Desktop\LCRP\gamemodes\nlrp.pwn(106718) : error 017: undefined symbol "draggedtimer"
C:\Users\Euronics Latvija\Desktop\LCRP\gamemodes\nlrp.pwn(106718) : warning 215: expression has no effect
C:\Users\Euronics Latvija\Desktop\LCRP\gamemodes\nlrp.pwn(106718) : error 001: expected token: ";", but found "]"
C:\Users\Euronics Latvija\Desktop\LCRP\gamemodes\nlrp.pwn(106718) : error 029: invalid expression, assumed zero
C:\Users\Euronics Latvija\Desktop\LCRP\gamemodes\nlrp.pwn(106718) : fatal error 107: too many error messages on one line
PHP код:
|
C:\Users\Euronics Latvija\Desktop\LCRP\gamemodes\nlrp.pwn(106736) : error 017: undefined symbol "RemoveUnderScore"
C:\Users\Euronics Latvija\Desktop\LCRP\gamemodes\nlrp.pwn(106737) : error 017: undefined symbol "RemoveUnderScore"
Did it. But now i got
PHP код:
|
stock RemoveUnderScore(playerid)
{
new name[MAX_PLAYER_NAME],pos;
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
while(strfind(name,"_",true) != -1)
{
pos = strfind(name,"_",true);
name[pos] = ' ';
}
return name;
}