You cant enter This car
#3

You can always use RemovePlayerFromVehicle(playerid); in conjugation with OnPlayerStateChange to remove a player from a vehicle.

Here's a small example: (Please note that attempting to compile this will just fail, this is just so you can guide yourself around a bit, I haven't tested this)
pawn Код:
//#define MAX_VEHICLES 2000
#define DEF_RESPAWN_DELAY 600 //Your respawn time

enum EVehicleType {
    EVehicleType_None,
    EVehicleType_Owned,
    EVehicleType_Faction,
};

enum EVehicleInfo {
    EVehicleType:EVType,
    EVFuel,
    EVEngine,
    EVOwner,
};
new VehicleInfo[MAX_VEHICLES][EVehicleInfo];

LoadFactionVehicles() {
    /* Enter your vehicles here */
        /* Faction ID would be a decimal number for a certain faction, it's used to compare if the player is or is not in a faction later on */
    createFactionVehicle(factionid, 517, 1941.4482, -1131.4258, 25.2050, 90.5242, 211, 211);
}

forward createFactionVehicle(factionid, modelid, Float: X, Float: Y, Float: Z, Float: Angle, c1, c2);
public createFactionVehicle(factionid, modelid, Float: X, Float: Y, Float: Z, Float: Angle, c1, c2) {
    new carid = CreateVehicle(modelid,X,Y,Z,Angle,c1,c2,DEF_RESPAWN_DELAY);
    new engine,lights,alarm,doors,bonnet,boot,objective;
    GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(carid,VehicleInfo[carid][EVEngine],lights,alarm,doors,bonnet,boot,objective);
    VehicleInfo[carid][EVOwner] = factionid;
    VehicleInfo[carid][EVFuel] = 100;
    VehicleInfo[carid][EVType] = EVehicleType_Faction; //This is how you would set that specific car to a faction type of car
}

public OnPlayerStateChange(playerid, newstate, oldstate) {
    if(newstate == PLAYER_STATE_DRIVER) {
        new newcar = GetPlayerVehicleID(playerid);
        if(VehicleInfo[newcar][EVType] == EVehicleType_Faction) {
            new faction = GetPVarInt(playerid, "Faction"); //This would be your actual player variable containing the faction he / she is in
            if(VehicleInfo[newcar][EVOwner] != faction) { //Compare: If we aren't in that faction
                SendClientMessage(playerid, COLOR_GREY, "You don't have the keys to this vehicle!");
                RemovePlayerFromVehicle(playerid); //Remove the player from the vehicle.
            }
        }
    }
}
This way you can keep everything organized and you don't have to bother with the range vehicle id's do
Reply


Messages In This Thread
You cant enter This car - by lulo356 - 04.11.2013, 17:19
Re: You cant enter This car - by ikbenremco - 04.11.2013, 17:42
Re : You cant enter This car - by InglewoodRoleplay - 04.11.2013, 18:00

Forum Jump:


Users browsing this thread: 1 Guest(s)