Vehicle help.
#1

How could I check if someone is in a specific vehicle?

Like, how could I put on this command:

pawn Код:
command(sweep, playerid, params[])
{
    if(//Here get the vehicle ID, of 574.)
    {
        Sweepcp[playerid] = 1;
        SetPlayerCheckpoint(playerid, -269.1287,2610.6057,63.2069, 3.0);
        SendClientMessage(playerid, 0xFFFFFFFF, "You have started to sweep the streets, Please follow the           checkpoints.");
    }
    else
    {
        SendClientMessage(playerid, WHITE, "You must be in a sweeper to sweep the streets.");
    }
    return 1;
}
Thanks for all the help, and the people who help will get +1 reputation.
Reply
#2

pawn Код:
command(sweep, playerid, params[])
{
new Model = GetVehicleModel(vehicleid);
    if(Model == 574)
    {
        Sweepcp[playerid] = 1;
        SetPlayerCheckpoint(playerid, -269.1287,2610.6057,63.2069, 3.0);
        SendClientMessage(playerid, 0xFFFFFFFF, "You have started to sweep the streets, Please follow the           checkpoints.");
    }
    else
    {
        SendClientMessage(playerid, WHITE, "You must be in a sweeper to sweep the streets.");
    }
    return 1;
}
Reply
#3

THanks mate, appreciated. +1 rep.
Reply
#4

it cant work because vehicleid isnt defined
this is correct

pawn Код:
command(sweep, playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
new Model = GetVehicleModel(vehicleid);
 if(Model == 574)
{
Sweepcp[playerid] = 1;
SetPlayerCheckpoint(playerid, -269.1287,2610.6057,63.2069, 3.0);
SendClientMessage(playerid, 0xFFFFFFFF, "You have started to sweep the streets, Please follow thecheckpoints.");
 }
 else
 {
SendClientMessage(playerid, WHITE, "You must be in a sweeper to sweep the streets.");
 }
 return 1;
}
Reply
#5

pawn Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 574)
Reply
#6

yes this works too bu with the other option he can see the models easter and the line is not to long
Reply
#7

You can also make a stock for that if you need to check it in many places

pawn Код:
stock IsSweeper(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 574: return 1;
    }
    return 0;
}
pawn Код:
command(sweep, playerid, params[])
{
    if(IsSweeper(GetPlayerVehicleID(playerid)))
    {
        Sweepcp[playerid] = 1;
        SetPlayerCheckpoint(playerid, -269.1287,2610.6057,63.2069, 3.0);
        SendClientMessage(playerid, 0xFFFFFFFF, "You have started to sweep the streets, Please follow the           checkpoints.");
    }
    else
    {
        SendClientMessage(playerid, WHITE, "You must be in a sweeper to sweep the streets.");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)