Closest Player Help?
#1

pawn Код:
dcmd_rape(playerid, params[])
{
        new ID = strval(params);
        if(!strlen(params))
        {
                SendClientMessage(playerid, COLOR_ERROR, "USAGE: /rape [ID]");
        }
        else
        {
                if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_ERROR, "That player is not connected!");
                if(ID == playerid) return SendClientMessage(playerid, COLOR_ERROR, "You cannot rape yourself!");
                if(rapespam[playerid] == 0)
                {
                        if(GetDistanceBetweenPlayers(playerid,ID) > RAPE_DISTANCE) return SendClientMessage(playerid, COLOR_ERROR, "You are not close enough to eachother!");
I just want it to rape the closest player near him
Not rape [ID]
Reply
#2

add this to your script:

pawn Код:
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;
}
search ****** and you will find the answers

http://lmgtfy.com/?q=rape+closeset+player+samp

just so you don't get heaps of reply's saying search before you post
Reply
#3

Ahh I already have that thanks :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)