SA-MP Forums Archive
This doesn't work well (GetPlayerVehicleID) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: This doesn't work well (GetPlayerVehicleID) (/showthread.php?tid=431857)



This doesn't work well (GetPlayerVehicleID) - LeeXian99 - 20.04.2013

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 "


Re: This doesn't work well (GetPlayerVehicleID) - Faisal_khan - 20.04.2013

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.


Re: This doesn't work well (GetPlayerVehicleID) - newbienoob - 20.04.2013

vehicle id is not vehicle name


Re: This doesn't work well (GetPlayerVehicleID) - LeeXian99 - 20.04.2013

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


AW: This doesn't work well (GetPlayerVehicleID) - BigETI - 20.04.2013

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.


Re: This doesn't work well (GetPlayerVehicleID) - czop1223 - 20.04.2013

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);



Re: This doesn't work well (GetPlayerVehicleID) - LeeXian99 - 20.04.2013

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

Anyway, thanks for helping and it works!


Re: This doesn't work well (GetPlayerVehicleID) - czop1223 - 20.04.2013

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