SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/04/2017, 11:27 AM   #1
Imbalo
Big Clucker
 
Join Date: Mar 2017
Location: Indonesia
Posts: 66
Reputation: 0
Default Please help me

PHP Code:
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"
};

GetVehicleModelFromName(vehicle_name[])
{
    new 
vehicleid = -1;
    if (
sscanf(vehicle_name"i"vehicleid))
    {
        for (new 
0sizeof (VehicleNames); i++)
        {
            if (
strfind(VehicleNames[i], vehicle_nametrue) != -1)
            {
                
vehicleid 400;
            }
        }
    }
    else if (!(
400 <= vehicleid <= 611)) vehicleid = -1;
    return 
vehicleid;
}
new 
Text3D:satu[MAX_VEHICLES];
CMD:v(playeridparams[])
{
    if(!
IsPlayerAdmin (playerid)) return SendClientMessage(playerid, -1"{0000CD}[SERVER]: {FFFFFF} You don't have acces to makes this commands");

    new 
carname[50];
    if(
sscanf(params"s[50]"carname)) return SendClientMessage(playerid, -1"{0000CD} [SERVER]: {FFFFFF}/v [Vehicle Name]");

    new 
carmodel GetVehicleModelFromName(carname);
    if(
carmodel == -1) return SendClientMessage(playerid, -1"{0000CD} [SERVER]: {FFFFFF}Invalid vehicle name.");
    if(
carmodel == 400)
    {
    new 
id GetPlayerVehicleID(playerid);
    
satuid ] = Create3DTextLabel"{FF0000}Lanstalker\n{00FF00}$4500", -10.00.00.050.00);
    
Attach3DTextLabelToVehiclesatuid ] , id0.00.02.0);
    } 
Why i use /v 400, the 3DTextLabel don't show, what the problem ?

#Sorry for my bad english
Imbalo is offline   Reply With Quote
Old 12/04/2017, 11:49 AM   #2
Meller
Banned
 
Join Date: Dec 2016
Posts: 578
Reputation: 132
Default Re: Please help me

Because you're checking in your code for /v vehiclename but you're using it like /v modelid
try typing

/v Landstalker

Edit:
Nevermind, read the code wrong, gimme a sec.
Meller is offline   Reply With Quote
Old 12/04/2017, 11:51 AM   #3
GangstaSunny.
Huge Clucker
 
GangstaSunny.'s Avatar
 
Join Date: Apr 2010
Location: Hamburg - Germany
Posts: 244
Reputation: 41
Default Re: Please help me

You need to type /v Landstalker
GangstaSunny. is offline   Reply With Quote
Old 12/04/2017, 11:53 AM   #4
Meller
Banned
 
Join Date: Dec 2016
Posts: 578
Reputation: 132
Default Re: Please help me

Quote:
Originally Posted by GangstaSunny. View Post
You need to type /v Landstalker
I made the same mistake as you,he's checking if the vehicle is an int or string.
Meller is offline   Reply With Quote
Old 12/04/2017, 12:11 PM   #5
GangstaSunny.
Huge Clucker
 
GangstaSunny.'s Avatar
 
Join Date: Apr 2010
Location: Hamburg - Germany
Posts: 244
Reputation: 41
Default Re: Please help me

Quote:
Originally Posted by Meller View Post
I made the same mistake as you,he's checking if the vehicle is an int or string.
He is checking nothing. Because his function is bullshit.

Code:
stock GetVehicleModelFromName(const vname[])
{
for(new i = 0; i < 211; i++)
{
if(strfind(VehicleNames[i], vname, true) != -1) 
{
return i + 400;
}
}
return -1;
}
GangstaSunny. is offline   Reply With Quote
Old 12/04/2017, 12:36 PM   #6
Meller
Banned
 
Join Date: Dec 2016
Posts: 578
Reputation: 132
Default Re: Please help me

Quote:
Originally Posted by GangstaSunny. View Post
He is checking nothing. Because his function is bullshit.

Code:
stock GetVehicleModelFromName(const vname[])
{
for(new i = 0; i < 211; i++)
{
if(strfind(VehicleNames[i], vname, true) != -1) 
{
return i + 400;
}
}
return -1;
}
That's not even his code lol.

PHP Code:
    if (sscanf(vehicle_name"i"vehicleid)) 
    { 
        for (new 
0sizeof (VehicleNames); i++) 
        { 
            if (
strfind(VehicleNames[i], vehicle_nametrue) != -1
            { 
                
vehicleid 400
            } 
        } 
    } 
    else if (!(
400 <= vehicleid <= 611)) vehicleid = -1
if (sscanf(vehicle_name, "i", vehicleid))
Checking if vehicle_name is a string

other wise check if the vehicle id is between 400 and 611
else if (!(400 <= vehicleid <= 611))


So his code seems to be fine to me.
Meller is offline   Reply With Quote
Old 12/04/2017, 12:42 PM   #7
GangstaSunny.
Huge Clucker
 
GangstaSunny.'s Avatar
 
Join Date: Apr 2010
Location: Hamburg - Germany
Posts: 244
Reputation: 41
Default Re: Please help me

Quote:
Originally Posted by Meller View Post
That's not even his code lol.

PHP Code:
    if (sscanf(vehicle_name"i"vehicleid)) 
    { 
        for (new 
0sizeof (VehicleNames); i++) 
        { 
            if (
strfind(VehicleNames[i], vehicle_nametrue) != -1
            { 
                
vehicleid 400
            } 
        } 
    } 
    else if (!(
400 <= vehicleid <= 611)) vehicleid = -1
if (sscanf(vehicle_name, "i", vehicleid))
Checking if vehicle_name is a string

other wise check if the vehicle id is between 400 and 611
else if (!(400 <= vehicleid <= 611))


So his code seems to be fine to me.
The code i posted is the working one.
GangstaSunny. is offline   Reply With Quote
Old 12/04/2017, 12:51 PM   #8
Spoookymon
Little Clucker
 
Join Date: Apr 2017
Posts: 47
Reputation: 2
Default Re: Please help me

I was mindblown, i have no idea why would you do smf like that.
Unless this is part of another system ported to this CMD ( car dealer ?? );

a) Why would u need to type vehicle name or id when you r sitting in it. ( do you want to add that label "Lanstalker price xxx" to amm, let's say Infernus, what for ? Is this a meme ? )
b) How much time do you have on your hands to make it for all vehicles individualy, when you can automate it.

PS.
You have to sit in vehicle to add this.
Does testLOS interfere with vehicles ? ( i don't remember ) Try to set it to 0.
Spoookymon is offline   Reply With Quote
Old 12/04/2017, 04:18 PM   #9
Imbalo
Big Clucker
 
Join Date: Mar 2017
Location: Indonesia
Posts: 66
Reputation: 0
Default Re: Please help me

so, what should I do now?
Imbalo is offline   Reply With Quote
Old 12/04/2017, 04:37 PM   #10
Meller
Banned
 
Join Date: Dec 2016
Posts: 578
Reputation: 132
Default Re: Please help me

Quote:
Originally Posted by Imbalo View Post
so, what should I do now?
Well first off:
LAbels that are attached to a vehicle cannot be seen if you're inside the vehicle.
Step out.

Second,
You should read your code again and recreate the command aswell as the function as you havef unneeded shit in it, nothing too much for a harm doe.
Meller is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 04:59 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.