03.05.2016, 14:20
Hello, I wana make a /rape command, In that i want that If player does /rape, it infects the closest player, but if player does /rape [id] it infects that specified player only.
How do i do that.
I have done this yet -
I've only coded till this because i got stuck in this issue.
and this my stock to get the closest player
How do i do that.
I have done this yet -
Код:
/*CMD:rape(playerid, params[])
{
new rapedid;
if (!IsPlayerSpawned(playerid) || PlayerData[playerid][pJailTime] > 0)
return SendErrorMessage(playerid, "You Cannot Use This Command Right Now");
if (PlayerData[playerid][pOnDuty])
return SendErrorMessage(playerid, "You Cannot Use This Command Whilst On-Duty.");
if (sscanf(params, "u", rapedid))
return SendSyntaxMessage(playerid, "/rape (playerid / Name).");
*/
and this my stock to get the closest player
Код:
stock GetNearestPlayerInView(playerid, Float:distance = 2.0)
{
new
Float:fAngle,
Float:fPosX,
Float:fPosY,
Float:fPosZ;
GetPlayerFacingAngle(playerid, fAngle);
GetPlayerPos(playerid, fPosX, fPosY, fPosZ);
fPosX += distance * floatsin(-fAngle, degrees);
fPosY += distance * floatcos(-fAngle, degrees);
foreach (new i : Player) if (IsPlayerInRangeOfPoint(i, 5.0, fPosX, fPosY, fPosZ)) {
return i;
}
return INVALID_PLAYER_ID;
}


