Hi, how to check whether the player on the machine hood
#1

Hi, how to check whether the player on the machine hood
Reply
#2

what?
Reply
#3

I need a function that player back-loaded to the front of the machine ( hood )
Reply
#4

In order to use this, you need this include.

pawn Код:
CMD:isonhood(playerid, params[])
{
    new Float:posX, Float:posY, Float:posZ;
    GetVehicleHood(vehicleid, posX, poxY, posZ);
    if(IsPlayerInRangeOfPoint(playerid, 3.0, posX, poxY, posZ));

    print("player is on hood of vehicle");
        return 1;
}
Just think the command stuff away.
Reply
#5

how to get include ?
Reply
#6

Same as above, get this include: https://sampforum.blast.hk/showthread.php?tid=486060

Then this is for general use (all vehicles):
pawn Код:
CMD:isonhood(playerid, params[])
{
    new Float:x, Float:y, Float:z, bool:found = false;
    for(new i = 1; i < MAX_VEHICLES; i ++)
    {
        GetVehicleHood(i, x, y, z);
        if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
        {
            found = true;
            break;
        }
    }

    if(found) SendClientMessage(playerid, -1, "You're by a vehicle's hood!")
    else SendClientMessage(playerid, -1, "You're NOT by a vehicle's hood!")
    return 1;
}
Reply
#7

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Same as above, get this include: https://sampforum.blast.hk/showthread.php?tid=486060

Then this is for general use (all vehicles):
pawn Код:
CMD:isonhood(playerid, params[])
{
    new Float:x, Float:y, Float:z, bool:found = false;
    for(new i = 1; i < MAX_VEHICLES; i ++)
    {
        GetVehicleHood(i, x, y, z);
        if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
        {
            found = true;
            break;
        }
    }

    if(found) SendClientMessage(playerid, -1, "You're by a vehicle's hood!")
    else SendClientMessage(playerid, -1, "You're NOT by a vehicle's hood!")
    return 1;
}
I totally forgot to check the vehicle id, oops!
But in your case, it isn't necessary to loop through all vehicles, just use a function that gets the nearest vehicle ID.
Reply
#8

Quote:
Originally Posted by Jimmy0wns
Посмотреть сообщение
I totally forgot to check the vehicle id, oops!
But in your case, it isn't necessary to loop through all vehicles, just use a function that gets the nearest vehicle ID.
But most nearest vehicle functions do use loops, rendering your statement quite illogical.
Reply
#9

Quote:
Originally Posted by Jimmy0wns
Посмотреть сообщение
In order to use this, you need this include.

pawn Код:
CMD:isonhood(playerid, params[])
{
    new Float:posX, Float:posY, Float:posZ;
    GetVehicleHood(vehicleid, posX, poxY, posZ);
    if(IsPlayerInRangeOfPoint(playerid, 3.0, posX, poxY, posZ));

    print("player is on hood of vehicle");
        return 1;
}
Just think the command stuff away.
Wouldn't this also tell you the player is on the hood when he is standing beside the vehicle?
Reply
#10

Quote:
Originally Posted by Sellize
Посмотреть сообщение
Wouldn't this also tell you the player is on the hood when he is standing beside the vehicle?
I'm not sure how the range is in GTA:SA, so OP can change it himself, my post wasn't very accurate either since I forgot to do a few things.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)