SA-MP Forums Archive
hacer un comando cerca de ... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: hacer un comando cerca de ... (/showthread.php?tid=406256)



hacer un comando cerca de ... - GranaT3 - 09.01.2013

hola. ps no me gusta. hacer esto xD de pedir codigo o funciones pero es que . no la encuentro y soy novato en pawn
ademas en la wiki algunas funciones no salen. si es que eso es una funcion . bueno es hacer una funcion cerca del carro solo si esta cerca del carro
igual que si esta cerca de la persona

bueno que mas da no me gusta pedir codigos. pero llevo rato buscandolo

igual gracias


Respuesta: hacer un comando cerca de ... - OTACON - 09.01.2013

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/comando", cmdtext, true, 10) == 0)
    {
        new counter = 0;
        new result;
        for(new i; i != MAX_VEHICLES; i++)
        {
            new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i);
            if(dist)
            {
                result = i;
                counter++;
            }
        }
        switch(counter)
        {
            case 0:
            {
                SendClientMessage(playerid, -1, "    No ahi coche cerca tuyo");
            }
            case 1:
            {
                // aca tu funcion
                return 1;
            }
            default:
            {
                SendClientMessage(playerid, -1, "   Se han encontrado mбs de un coche en el rango");
                return 1;
            }
        }
        return 1;
    }
    return 0;
}
pawn Код:
stock CheckPlayerDistanceToVehicle(Float:radi, playerid, vehicleid)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z ;
        GetPlayerPos(playerid,PX,PY,PZ);
        GetVehiclePos(vehicleid, X,Y,Z);
        new Float:Distance = (X-PX)*(X-PX)+(Y-PY)*(Y-PY)+(Z-PZ)*(Z-PZ);
        if(Distance <= radi*radi)
        {
            return 1;
        }
    }
    return 0;
}
Saludos .


Respuesta: hacer un comando cerca de ... - GranaT3 - 09.01.2013

gracias otacon xd

papasito