Quick Question.
#2

Код:
CMD:rape(playerid, params[])
{
	new rapedid = GetClosestPlayerToPlayer(playerid);

    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).");


forward GetClosestPlayerToPlayer(playerid);
public GetClosestPlayerToPlayer(playerid)
{
    new Float:dist = 1000.0;
    new targetid = INVALID_PLAYER_ID;
    new Float:x1,Float:y1,Float:z1;
    new Float:x2,Float:y2,Float:z2;
    new Float:tmpdis;
    GetPlayerPos(playerid,x1,y1,z1);
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(i == playerid) continue;
        GetPlayerPos(i,x2,y2,z2);
        tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
        if(tmpdis < dist)
        {
            dist = tmpdis;
            targetid = i;
        }
    }
    return targetid;
}
try this
Reply


Messages In This Thread
Quick Question. - by Ritzy2K - 03.05.2016, 14:20
Re: Quick Question. - by ReD_HunTeR - 03.05.2016, 14:55
Re: Quick Question. - by Sjn - 03.05.2016, 14:56
Re: Quick Question. - by Ritzy2K - 03.05.2016, 15:00
Re: Quick Question. - by xTURBOx - 03.05.2016, 15:55
Re: Quick Question. - by Ritzy2K - 03.05.2016, 17:01
Re: Quick Question. - by jlalt - 03.05.2016, 19:32
Re: Quick Question. - by Ritzy2K - 03.05.2016, 19:41
Re: Quick Question. - by jlalt - 03.05.2016, 19:52

Forum Jump:


Users browsing this thread: 1 Guest(s)