Help With GetVehicleModelInfo ...
#1

Hi all,
quero create a command to detect a vehicle position with GetVehicleModelInfo function and its parameters.

but I've done everything and it does not work: S: (.

Here I give a test of what I did:

pawn Код:
COMMAND:test(playerid, params[])
{
    new newid=0, count=0, Float:pos[3];
    for(new v = 0; v <= MAX_VEHICLES; v++)
    {
        newid= v;
        GetVehicleModelInfo(GetVehicleModel(newid), VEHICLE_MODEL_INFO_PETROLCAP, pos[0], pos[1], pos[2]);
        if(IsPlayerInRangeOfPoint(playerid, 5.0, pos[0],pos[1],pos[2]))
        {
            count++;
            break;
        }
    }
    switch(count)
    {
        case 0:
        {
            SendClientMessage(playerid, -1, "PETROLCAP No Detected");
        }
        case 1:
        {
            SendClientMessage(playerid, -1, "PETROLCAP Yes Detected");
        }
        default:
        {
            SendClientMessage(playerid, -1, "PETROLCAP Over 1 Detected");
        }
    }
    return 1;
}
Thanks in advance.
sorry for my English.
Reply
#2

GetVehicleModelInfo has NOTHING to do with vehicle position. It returns the position of parts of the vehicle in relation to the vehicle, not in relation to the GTA SA world.

You need to use GetVehiclePos
Reply
#3

Try this:
pawn Код:
COMMAND:test(playerid)
{
    new count = 0, Float:pos[3];
    for(new v = 0; v <= MAX_VEHICLES; v++)
    {
        GetVehicleModelInfo(GetVehicleModel(v), VEHICLE_MODEL_INFO_PETROLCAP, pos[0], pos[1], pos[2]);
        if(IsPlayerInRangeOfPoint(playerid, 5.0, pos[0],pos[1],pos[2]))
        {
            count++;
            break;
        }
    }
    switch(count)
    {
        case 0:
        {
            SendClientMessage(playerid, -1, "PETROLCAP No Detected");
        }
        case 1:
        {
            SendClientMessage(playerid, -1, "PETROLCAP Yes Detected");
        }
        case 2..MAX_VEHICLES:
        {
            SendClientMessage(playerid, -1, "PETROLCAP Over 1 Detected");
        }
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Roach_
Посмотреть сообщение
Try this:
pawn Код:
COMMAND:test(playerid)
{
    new count = 0, Float:pos[3];
    for(new v = 0; v <= MAX_VEHICLES; v++)
    {
        GetVehicleModelInfo(GetVehicleModel(v), VEHICLE_MODEL_INFO_PETROLCAP, pos[0], pos[1], pos[2]);
        if(IsPlayerInRangeOfPoint(playerid, 5.0, pos[0],pos[1],pos[2]))
        {
            count++;
            break;
        }
    }
    switch(count)
    {
        case 0:
        {
            SendClientMessage(playerid, -1, "PETROLCAP No Detected");
        }
        case 1:
        {
            SendClientMessage(playerid, -1, "PETROLCAP Yes Detected");
        }
        case 2..MAX_VEHICLES:
        {
            SendClientMessage(playerid, -1, "PETROLCAP Over 1 Detected");
        }
    }
    return 1;
}
returns always in SendClientMessage(playerid, -1, "PETROLCAP No Detected"); :S

@ FUNExtreme GetVehicleModelInfo Returns the position of the part.
Reply
#5

Quote:
Originally Posted by bytytus
Посмотреть сообщение
@ FUNExtreme GetVehicleModelInfo Returns the position of the part.
It returns the position of the part from the center of the vehicle.
Reply
#6

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
It returns the position of the part from the center of the vehicle.
¬¬ https://sampwiki.blast.hk/wiki/GetVehicleModelInfo
https://sampwiki.blast.hk/wiki/Vehicle_information_types

Here I am doing the same but I give it to instead of IsPlayerInRangeOfPoint Attach3DTextLabelToVehicle

pawn Код:
COMMAND:testing(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid), Float:pos[3];
    GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_PETROLCAP, pos[0], pos[1], pos[2]);
    new Text3D:texto = Create3DTextLabel("PETROLCAP", -1, 0.0, 0.0, 0.0, 50.0, 0, 1);
    Attach3DTextLabelToVehicle(texto, vehicleid, pos[0], pos[1], pos[2]);
    return 1;
}
It tests it in a vehicle.
Reply
#7

Read the asterix (*)

Positions are calculated from the center of the vehicle so you have to use GetPlayerVehiclePos in combination with the GetVehicleModelInfo
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)