if(IsPlayerInVehicle(playerid, ID))
#1

Im trying to make a cmd only able when in vehicleid 476, but it still works in all vehicles, how come?
i have tried this, but then it doesnt work at all
pawn Код:
if(IsPlayerInVehicle(playerid, 476))
But with this it does work..in ALL vehicles and not just in ID 476
pawn Код:
if(!IsPlayerInVehicle(playerid, 476))
This is the commands, and they are dont being restricted to ID 476 as it should be, they works in all vehicles.
CODE:
pawn Код:
COMMAND:unload(playerid,vehicleid, params[])
{
    if(!IsPlayerInVehicle(playerid, 476))
    {
        new id = GetPlayerVehicleID(playerid);
        DestroyObject(VehicleBomb[id][0]);
        DestroyObject(VehicleBomb[id][1]);
        VehicleFire[vehicleid] = 1;
    }
    return 1;
}
COMMAND:load(playerid,vehicleid, params[])
{
    if(!IsPlayerInVehicle(playerid, 476))
    {
        new id = GetPlayerVehicleID(playerid);
        new
            Float:x,
            Float:y,
            Float:z;

        GetPlayerPos(playerid,x,y,z);

        AddVehicleMissiles(id,2.0,-1.05,0.0);
    }
    return 1;
}
Reply
#2

You are confused, vehicleid is the server ID of the vehicle which starts from 0 - 1999. The model of the vehicle is what you're going for, 476 is Rustler. To target a Rustler, you need to use GetVehicleModel and GetPlayerVehicleID.

pawn Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 476) {
    // The player is in a Rustler.
}
Reply
#3

Quote:
Originally Posted by JamesC
Посмотреть сообщение
You are confused, vehicleid is the server ID of the vehicle which starts from 0 - 1999. The model of the vehicle is what you're going for, 476 is Rustler. To target a Rustler, you need to use GetVehicleModel and GetPlayerVehicleID.

pawn Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 476) {
    // The player is in a Rustler.
}
Ah! what a fail.. Thanks!
but that did make some errors so i needed to use this instead. And this disable the function of some reason.
pawn Код:
if(GetVehicleModel(vehicleid) == 476)
But when do you use it like this way?
pawn Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 476) {
Reply
#4

When you don't want to use IsPlayerInVehicle. They both do the same thing, but you evaluate the vehicleid in different ways. IsPlayerInVehicle checks if the player is in the provided vehicleid whereas GetPlayerVehicleID simply returns the player's current vehicleid.
Reply
#5

Quote:
Originally Posted by JamesC
Посмотреть сообщение
When you don't want to use IsPlayerInVehicle. They both do the same thing, but you evaluate the vehicleid in different ways. IsPlayerInVehicle checks if the player is in the provided vehicleid whereas GetPlayerVehicleID simply returns the player's current vehicleid.
Ah ok thanks again!

But GetVehicleModel did disable the commands funktion, so nothing did happen when i added model 476 and was sitting in a rustler.

And why does these commands call every player? if you and i sits in a rustler..both of us gets the rockets and if you /unload, you also unload for me. I have tried to fix this for like 2 hours now and im stuck.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)