SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 30/03/2014, 03:13 PM   #1
biker122
Gangsta
 
Join Date: Feb 2014
Posts: 766
Reputation: 59
Default Vehicle spawner.

Command :
pawn Code:
CMD:v(playerid,params[])
{
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"[ERROR] You already have a vehicle!");
    new vehicle;
    vehicle = GetVehicleModelIDFromName(params);
    if(isnull(params)) return ShowPlayerDefaultDialog(playerid);
    if(vehicle  < 400 || vehicle  > 611) return SendClientMessage(playerid,COLOR_RED,"[ERROR] Invalid vehicle name!");
    CreatePlayerVehicle(playerid,vehicle);
    return 1;
}
What's wrong with this? When I type /v it will show a dialog. It's perfect. But, When I type /v (carname), It spawns the same car even if I type someother car ID's / names.
I don't know the name of the car, sorry.
and "CreatePlayerVehicle" function :
pawn Code:
function CreatePlayerVehicle(playerid, modelid)
{
    if(PlayerInfo[playerid][PlayerCar] != -1 && !IsVehicleOccupied(PlayerInfo[playerid][PlayerCar]))
    {
        DestroyVehicle(PlayerInfo[playerid][PlayerCar]);
        PlayerInfo[playerid][PlayerCar] = -1;
    }
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerFacingAngle(playerid, a);
    GetPlayerPos(playerid, x, y, z);

    PlayerInfo[playerid][PlayerCar] = CreateVehicle(modelid, x, y, z, a, random(255), random(255), -1);
    LinkVehicleToInterior(PlayerInfo[playerid][PlayerCar], GetPlayerInterior(playerid));
    PutPlayerInVehicle(playerid, PlayerInfo[playerid][PlayerCar], 0);
    return PlayerInfo[playerid][PlayerCar];
}
Hope someone will help me,
Thanks.
biker122 is offline   Reply With Quote
Old 30/03/2014, 03:19 PM   #2
RenovanZ
Gangsta
 
RenovanZ's Avatar
 
Join Date: Jul 2012
Location: Jogjakarta, Indonesia
Posts: 597
Reputation: 32
Default Re: Vehicle spawner.

Show us GetVehicleModelIdFromName.
__________________
__________________________________________________
My Work(s)
__________________________________________________

RenovanZ is offline   Reply With Quote
Old 30/03/2014, 03:21 PM   #3
biker122
Gangsta
 
Join Date: Feb 2014
Posts: 766
Reputation: 59
Default Re: Vehicle spawner.

Here you go,
pawn Code:
function GetVehicleModelIDFromName(vname[])
{
    for(new i = 0; i < 211; i++)
    {
        if(strfind(vname[i], vname, true) != -1)
        return i + 400;
    }
    return -1;
}
biker122 is offline   Reply With Quote
Old 30/03/2014, 03:25 PM   #4
RenovanZ
Gangsta
 
RenovanZ's Avatar
 
Join Date: Jul 2012
Location: Jogjakarta, Indonesia
Posts: 597
Reputation: 32
Default Re: Vehicle spawner.

pawn Code:
function GetVehicleModelIDFromName(vnameX[])
{
    for(new i = 0; i < 211; i++)
    {
        if(strfind(vname[i], vnameX, true) != -1)
        return i + 400;
    }
    return -1;
}
__________________
__________________________________________________
My Work(s)
__________________________________________________

RenovanZ is offline   Reply With Quote
Old 30/03/2014, 03:28 PM   #5
biker122
Gangsta
 
Join Date: Feb 2014
Posts: 766
Reputation: 59
Default Re: Vehicle spawner.

pawn Code:
C:\Users\Matt\Desktop\samp03z_svr_R1_win32\gamemodes\stunting.pwn(1246) : error 017: undefined symbol "vname"
C:\Users\Matt\Desktop\samp03z_svr_R1_win32\gamemodes\stunting.pwn(1246) : warning 215: expression has no effect
C:\Users\Matt\Desktop\samp03z_svr_R1_win32\gamemodes\stunting.pwn(1246) : error 001: expected token: ";", but found "]"
C:\Users\Matt\Desktop\samp03z_svr_R1_win32\gamemodes\stunting.pwn(1246) : error 029: invalid expression, assumed zero
C:\Users\Matt\Desktop\samp03z_svr_R1_win32\gamemodes\stunting.pwn(1246) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
biker122 is offline   Reply With Quote
Old 30/03/2014, 03:32 PM   #6
RenovanZ
Gangsta
 
RenovanZ's Avatar
 
Join Date: Jul 2012
Location: Jogjakarta, Indonesia
Posts: 597
Reputation: 32
Default Re: Vehicle spawner.

Put this somewhere else, before CMD:v or whatever.
pawn Code:
new vname[212][] =
{
    "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"
};
__________________
__________________________________________________
My Work(s)
__________________________________________________

RenovanZ is offline   Reply With Quote
Old 30/03/2014, 03:40 PM   #7
biker122
Gangsta
 
Join Date: Feb 2014
Posts: 766
Reputation: 59
Default Re: Vehicle spawner.

Tried to use GetVehicleName.inc for this and eventually it worked.
Thanks for your help! (:
biker122 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
Vehicle Spawner... Cosmo Bulthuis Scripting Help 1 17/03/2013 04:44 PM
Vehicle spawner... Save Scripting Help 8 09/12/2011 08:07 PM
I need vehicle spawner /and help PLEASE:) sMog. Help Archive 5 04/03/2011 09:45 PM
[FilterScript] [FS][UPDATE][HUN+ENG]Vehicle Spawner by Vehicle Name & ID + DIALOG Kovacs_Richard Filterscripts 4 06/07/2010 01:47 PM


All times are GMT. The time now is 07:39 AM.


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