This doesn't work well (GetPlayerVehicleID)
#1

I coded this code out!

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new string[128],string2[128], name[56];
    format(string, sizeof(string), "[INFO]: You've entered %s", GetPlayerVehicleID(playerid));
    SendClientMessage(playerid, -1, string);
    format(string2, sizeof(string2), "[INFO]: %s exited %s", name, GetPlayerVehicleID(playerid));
    print(string2);
    return 1;
}
But in the log,

"[09:08:10] [INFO]: Xian entered "
Reply
#2

Try this:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new string[128],string2[64], name[56];
    format(string, sizeof(string), "[INFO]: You've entered %s", GetPlayerVehicleID(playerid));
    SendClientMessage(playerid, -1, string);
    format(string2, sizeof(string2), "[INFO]: %s exited %s", name, GetPlayerVehicleID(playerid));
    print(string2);
    return 1;
}
maybe this will work out.
Reply
#3

vehicle id is not vehicle name
Reply
#4

So, what's the function to show the vehicle name?
Reply
#5

OnPlayerEnterVehicle will be only called, if the player attempts to enter a vehicle.
Means that, if a player applies the "enter vehicle" animation, the player is sill not inside the vehicle. Players can refuse or getting smashed from the vehicle after the "enter vehicle" animation.

You should use OnPlayerStateChange to check, if the player has entered or exited a vehicle safely.
Reply
#6

pawn Код:
new VehicleNames[][] =
{
    "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
    "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
    "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
    "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
    "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
    "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
    "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
    "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
    "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
    "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
    "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
    "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
    "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
    "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
    "Blista Compact", "Police Maverick", "Boxville", "Benson", "Mesa", "RC Goblin",
    "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
    "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
    "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
    "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
    "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
    "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
    "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
    "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
    "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratium",
    "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
    "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
    "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
    "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
    "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
    "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
    "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs", "Boxville",
    "Tiller", "Utility Trailer"
};
somewhere

pawn Код:
stock GetVehicleName(vehicleid)
{
    format(String,sizeof(String),"%s",VehicleNames[GetVehicleModel(vehicleid) - 400]);
    return String;
}
And now
pawn Код:
new string[128],string2[64], name[56];
    format(string, sizeof(string), "[INFO]: You've entered %s", GetVehicleName(vehicleid));
    SendClientMessage(playerid, -1, string);
    format(string2, sizeof(string2), "[INFO]: %s exited %s", name, GetVehicleName(vehicleid));
    print(string2);
Reply
#7

You forgot to add new string[128] (or less) in the stock.

Anyway, thanks for helping and it works!
Reply
#8

Not add [128], it's too big, use [30] max.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)