SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 22/01/2015, 02:41 PM   #1
kalanerik99
Huge Clucker
 
kalanerik99's Avatar
 
Join Date: Mar 2012
Location: Slovenia
Posts: 473
Reputation: 9
Default /v ([vehicleid])

Hello!

How to make that player could use /v [vehicleid/name] or just /v and dialog will show up
I tried something but it doesnt work!
And how to make that player could enter veh name too.
Thanks

Code:
CMD:v(playerid,params[])
{
if(InDM[playerid]) return GameTextForPlayer(playerid, "~w~You cannot spawn vehicles in ~r~DM",2000,5);
if(params[0])
{
new modelid;
if(sscanf(params, "i", modelid))return GameTextForPlayer(playerid, "~w~/v ~n~~r~[vehicleid]",2000,5);
if(modelid < 400 || modelid > 611) return GameTextForPlayer(playerid, "~w~Invalid ~r~VEHICLE ID!",2000,5);
VehicleSpawner(playerid,modelid);
}
else
{
ShowPlayerDialog(playerid, Dialog_Vehicles, DIALOG_STYLE_LIST, "{ffffff}Vehicle categories:", "Airplanes\nHelicopters\nBikes\nConvertibles\nIndustrial\nLowriders\nOff Road\nPublic Service\nSaloons\nSport Vehicles\nStation Wagons\nBoats\nTrailers\nUnique\nRC Vehicles", "Select", "Back" );
}
return 1;
}
Code:
GetVehicleModelIDFromName(vname[])
{
for(new i = 0; i < 211; i++)
{
if ( strfind(VehicleNames[i], vname, true) != -1 )
return i + 400;
}
return -1;
}
__________________


UGF
Unlimited GTA Freeroam

Freeroam - Deathmach - Race -Stunts



kalanerik99 is offline   Reply With Quote
Old 22/01/2015, 02:52 PM   #2
Schneider
Gangsta
 
Schneider's Avatar
 
Join Date: Jun 2007
Location: Netherlands
Posts: 515
Reputation: 136
Default Re: /v ([vehicleid])

Not tested though...
pawn Code:
CMD:v(playerid,params[])
{
    if(InDM[playerid]) return GameTextForPlayer(playerid, "~w~You cannot spawn vehicles in ~r~DM",2000,5);
    if(params[0])
    {
        new modelid[32];
        if(sscanf(params, "s[32]", modelid)) return GameTextForPlayer(playerid, "~w~/v ~n~~r~[vehicleid/name]",2000,5);
        if(strval(modelid) >= 400 || strval(modelid) < 612)
        {
            VehicleSpawner(playerid,modelid);
        }
        else
        {
            new model = GetVehicleModelIDFromName(modelid);
            if(model >= 400 || model < 612)
            {
                VehicleSpawner(playerid,model);
            }
            else
            {
                GameTextForPlayer(playerid, "~w~Invalid ~r~Name/ID!",2000,5);
            }
        }
    }
    else
    {
        ShowPlayerDialog(playerid, Dialog_Vehicles, DIALOG_STYLE_LIST, "{ffffff}Vehicle categories:", "Airplanes\nHelicopters\nBikes\nConvertibles\nIndustrial\nLowriders\nOff Road\nPublic Service\nSaloons\nSport Vehicles\nStation Wagons\nBoats\nTrailers\nUnique\nRC Vehicles", "Select", "Back" );
    }
    return 1;
}
Schneider is offline   Reply With Quote
Old 22/01/2015, 02:58 PM   #3
kalanerik99
Huge Clucker
 
kalanerik99's Avatar
 
Join Date: Mar 2012
Location: Slovenia
Posts: 473
Reputation: 9
Default Re: /v ([vehicleid])

Code:
new modelid[32];
if(sscanf(params, "s[32]", modelid)) return GameTextForPlayer(playerid, "~w~/v ~n~~r~[vehicleid/name]",2000,5);
if(strval(modelid) >= 400 || strval(modelid) < 612)
{
VehicleSpawner(playerid,modelid);---this line
Code:
error 035: argument type mismatch (argument 2)
__________________


UGF
Unlimited GTA Freeroam

Freeroam - Deathmach - Race -Stunts



kalanerik99 is offline   Reply With Quote
Old 22/01/2015, 03:05 PM   #4
Schneider
Gangsta
 
Schneider's Avatar
 
Join Date: Jun 2007
Location: Netherlands
Posts: 515
Reputation: 136
Default Re: /v ([vehicleid])

Sorry, there are some mistakes in the code, currently fixing and testing it.
Schneider is offline   Reply With Quote
Old 22/01/2015, 03:09 PM   #5
kalanerik99
Huge Clucker
 
kalanerik99's Avatar
 
Join Date: Mar 2012
Location: Slovenia
Posts: 473
Reputation: 9
Default Re: /v ([vehicleid])

Ok
btw just /v 411 works (not names and dialog)
__________________


UGF
Unlimited GTA Freeroam

Freeroam - Deathmach - Race -Stunts



kalanerik99 is offline   Reply With Quote
Old 22/01/2015, 03:13 PM   #6
Schneider
Gangsta
 
Schneider's Avatar
 
Join Date: Jun 2007
Location: Netherlands
Posts: 515
Reputation: 136
Default Re: /v ([vehicleid])

Got it! Tested and works!

pawn Code:
CMD:v(playerid,params[])
{
    if(InDM[playerid]) return GameTextForPlayer(playerid, "~w~You cannot spawn vehicles in ~r~DM",2000,5);
    new modelid[32];
    if(sscanf(params, "s[32]", modelid)) return ShowPlayerDialog(playerid, Dialog_Vehicles, DIALOG_STYLE_LIST, "{ffffff}Vehicle categories:", "Airplanes\nHelicopters\nBikes\nConvertibles\nIndustrial\nLowriders\nOff Road\nPublic Service\nSaloons\nSport Vehicles\nStation Wagons\nBoats\nTrailers\nUnique\nRC Vehicles", "Select", "Back" );
    if(400 <= strval(modelid) <= 611)
    {
        VehicleSpawner(playerid, strval(modelid));
    }
    else
    {
        new model = GetVehicleModelIDFromName(modelid);
        if(400 <= model <= 611)
        {
            VehicleSpawner(playerid, model);
        }
        else
        {
            GameTextForPlayer(playerid, "~w~Invalid ~r~Name/ID!",2000,5);
        }
    }
    return 1;
}
Schneider is offline   Reply With Quote
Old 22/01/2015, 03:16 PM   #7
kalanerik99
Huge Clucker
 
kalanerik99's Avatar
 
Join Date: Mar 2012
Location: Slovenia
Posts: 473
Reputation: 9
Default Re: /v ([vehicleid])

Yea it works thanks
Sorry my reps hehe some people just give me -rep for joke
__________________


UGF
Unlimited GTA Freeroam

Freeroam - Deathmach - Race -Stunts



kalanerik99 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible vehicleid bug? FufLa Bug Reports 56 16/07/2015 04:47 AM
Workaround vehicleid not matching MySQL vehicleid DrDoom151 Scripting Help 2 18/05/2013 11:49 PM
Vehicleid cruising Scripting Help 9 14/01/2012 08:43 AM
Vehicleid? Darekfred Help Archive 2 04/01/2010 01:00 AM


All times are GMT. The time now is 05:53 PM.


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