Doesn't get the vehicle name (+REP) [quick one]
#1

When i'm using the command /test it's just saying the command is unknown.
but if i'll put the same function when you enter a vehicle it'd work. It doesn't get the vehicle name if it's a vehicle that IS exists

PHP код:
CMD:test(playerid,params[]){
LoggedCMD OwnerCMD
new String[128];
format(String,sizeof(String),"You got a: %s",GetVehicleName(DB[playerid][Vehicle1]));
MSG(playerid,-1,String);
return 
1;} 
PHP код:
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",
    
"Squallo""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"
};
stock GetVehicleName(vehicleid)
{
    new 
String[32];
    
format(String,sizeof(String),"%s",VehicleNames[GetVehicleModel(vehicleid) - 400]);
    return 
String;

Reply
#2

Hi!

We can check which number is written in Vehicle1.
PHP код:
CMD:test(playerid,params[])
{
    
printf("Vehicle1: %d",DB[playerid][Vehicle1]);
    new 
String[128];
    
format(String,sizeof(String),"You got a: %s",GetVehicleName(DB[playerid][Vehicle1]));
    
MSG(playerid,-1,String);
    return 
1;

What will print in the console (server.log) when you write it like this?
Reply
#3

The vehicle specified does not exist, GetVehicleModel returns 0 and subtracting from it goes to invalid index -400.

PHP код:
#if !defined strcpy
    #define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)
#endif 
PHP код:
GetVehicleName(vehicleid)
{
    new 
String[32] = "N/A"modelid GetVehicleModel(vehicleid);
    if (!
modelid) return String;
    
strcpy(StringVehicleNames[modelid 400], sizeof(String));
    return 
String;

Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The vehicle specified does not exist, GetVehicleModel returns 0 and subtracting from it goes to invalid index -400.

PHP код:
#if !defined strcpy
    #define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)
#endif 
PHP код:
GetVehicleName(vehicleid)
{
    new 
String[32] = "N/A"modelid GetVehicleModel(vehicleid);
    if (!
modelid) return String;
    
strcpy(StringVehicleNames[modelid 400], sizeof(String));
    return 
String;

It shows the vehicle as N/A even when i've a vehicle on the file
Reply
#5

It shows N/A that the vehicle does not exist and prevents the run time error 4.
DB[playerid][Vehicle1] is 0, you need to assign a vehicle ID on it.
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The vehicle specified does not exist, GetVehicleModel returns 0 and subtracting from it goes to invalid index -400.

PHP код:
#if !defined strcpy
    #define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)
#endif 
PHP код:
GetVehicleName(vehicleid)
{
    new 
String[32] = "N/A"modelid GetVehicleModel(vehicleid);
    if (!
modelid) return String;
    
strcpy(StringVehicleNames[modelid 400], sizeof(String));
    return 
String;

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It shows N/A that the vehicle does not exist and prevents the run time error 4.
DB[playerid][Vehicle1] is 0, you need to assign a vehicle ID on it.
nope mate, my DB[playerid][Vehicle1] = 522 which is NRG
Reply
#7

That's the mistake, the function is supposed to get a vehicle ID and not a vehicle model ID.

PHP код:
GetVehicleName(vehicleidmodel 0)
{
    new 
String[32] = "N/A";
    if(!
model)
    {
        new 
modelid GetVehicleModel(vehicleid);
        if(
modelidstrcpy(StringVehicleNames[modelid 400], sizeof(String));
    }
    else
    {
        if(
400 <= vehicleid <= 611strcpy(StringVehicleNames[modelid 400], sizeof(String));
    }
    return 
String;

Use the second parameter when you want to pass the model ID. Examples:
pawn Код:
GetVehicleName(vehicleid)
GetVehicleName(modelid, 1)
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
That's the mistake, the function is supposed to get a vehicle ID and not a vehicle model ID.

PHP код:
GetVehicleName(vehicleidmodel 0)
{
    new 
String[32] = "N/A";
    if(!
model)
    {
        new 
modelid GetVehicleModel(vehicleid);
        if(
modelidstrcpy(StringVehicleNames[modelid 400], sizeof(String));
    }
    else
    {
        if(
400 <= vehicleid <= 611strcpy(StringVehicleNames[modelid 400], sizeof(String));
    }
    return 
String;

Use the second parameter when you want to pass the model ID. Examples:
pawn Код:
GetVehicleName(vehicleid)
GetVehicleName(modelid, 1)
so how can I do it over here?

PHP код:
if(IsPlayerInRangeOfPoint(playerid,3,1481.9901,-1796.1001,17.0359)){
format(String,sizeof(String),"Slot 1: %s\n\
Slot 2: %s\n\
Slot 3: %s\n\
Slot 4: %s\n\
Slot 5: %s\n\
Slot 6: %s\n\
Slot 7: %s\n\
Slot 8: %s\n\
Slot 9: %s\n\
Slot 10: %s"
,GetVehicleName(DB[playerid][Vehicle1],1),
GetVehicleName(DB[playerid][Vehicle2]),
GetVehicleName(DB[playerid][Vehicle3]),
GetVehicleName(DB[playerid][Vehicle4]),
GetVehicleName(DB[playerid][Vehicle5]),
GetVehicleName(DB[playerid][Vehicle6]),
GetVehicleName(DB[playerid][Vehicle7]),
GetVehicleName(DB[playerid][Vehicle8]),
GetVehicleName(DB[playerid][Vehicle9]),
GetVehicleName(DB[playerid][Vehicle10]));
DLG(playerid,17,DIALOG_STYLE_LIST,"Pick a slot",String,"Pick","Cancel"); 
Reply
#9

I don't know what those variables are meant to store.

If you store the model ID (such as 411 for infernus, 562 for elegy etc), then use the second parameter and set it to 1.
If you store the vehicle ID (which is returned by CreateVehicle or AddStaticVehicle(ex)), then don't use the second parameter at all.
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
I don't know what those variables are meant to store.

If you store the model ID (such as 411 for infernus, 562 for elegy etc), then use the second parameter and set it to 1.
If you store the vehicle ID (which is returned by CreateVehicle or AddStaticVehicle(ex)), then don't use the second parameter at all.
like this or? xD sorry for my retardness
PHP код:
if(IsPlayerInRangeOfPoint(playerid,3,1481.9901,-1796.1001,17.0359)){ 
format(String,sizeof(String),"Slot 1: %s\n\ 
Slot 2: %s\n\ 
Slot 3: %s\n\ 
Slot 4: %s\n\ 
Slot 5: %s\n\ 
Slot 6: %s\n\ 
Slot 7: %s\n\ 
Slot 8: %s\n\ 
Slot 9: %s\n\ 
Slot 10: %s"
,GetVehicleName(DB[playerid][Vehicle1],1), 
GetVehicleName(DB[playerid][Vehicle2],1), 
GetVehicleName(DB[playerid][Vehicle3],1), 
GetVehicleName(DB[playerid][Vehicle4],1), 
GetVehicleName(DB[playerid][Vehicle5],1), 
GetVehicleName(DB[playerid][Vehicle6],1), 
GetVehicleName(DB[playerid][Vehicle7],1), 
GetVehicleName(DB[playerid][Vehicle8],1), 
GetVehicleName(DB[playerid][Vehicle9],1), 
GetVehicleName(DB[playerid][Vehicle10],1)); 
DLG(playerid,17,DIALOG_STYLE_LIST,"Pick a slot",String,"Pick","Cancel"); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)