SA-MP Forums Archive
Help with IsPlayerNearAnyVehicle (rep+) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with IsPlayerNearAnyVehicle (rep+) (/showthread.php?tid=322488)



Help with IsPlayerNearAnyVehicle (rep+) - Join7 - 02.03.2012

Not work IsPlayerNearAnyVehicle

Код:
if(strcmp("/elegy", cmdtext, true, 10) == 0)
{
    if(IsPlayerNearAnyVehicle(playerid, 35))
    {
        new Float:X,Float:Y,Float:Z,Float:Angle, carid;
        GetPlayerPos(playerid,X,Y,Z);
        GetPlayerFacingAngle(playerid,Angle);
        carid = GetPlayerVehicleID(playerid);
        carid = CreateVehicle(562,X,Y,Z,Angle,-1,-1,600);
        PutPlayerInVehicle(playerid,carid,0);
        TogglePlayerControllable(playerid, true);
        return SendClientMessage(playerid, COLOR_GREY, "Elegy was spawned!");
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "Not spawned, 35 distance!");
    }
    return 1;
}
stock IsPlayerNearAnyVehicle(playerid, Float:distance)
{
    new Float:x, Float:y, Float:z;
    for(new i; i < MAX_VEHICLES; i++)
    {
        if(GetVehicleModel(i))
        {
            GetVehiclePos(i, x, y, z);
            if(GetPlayerDistanceFromPoint(playerid, x, y, z) <= distance) return 1;
        }
    }
    return 0;
}



AW: Help with IsPlayerNearAnyVehicle (rep+) - Drebin - 02.03.2012

pawn Код:
if(GetVehicleModel(i))
        {
            GetVehiclePos(i, x, y, z);
            if(GetPlayerDistanceFromPoint(playerid, x, y, z) <= distance) return 1;
        }
I hope you know that GetVehicleModel() returns the MODEL ID of the vehicle, not the vehicle ID?


Re: Help with IsPlayerNearAnyVehicle (rep+) - Join7 - 02.03.2012

Well this applies to all model ID