SA-MP Forums Archive
/v command with car, and ID name - 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: /v command with car, and ID name (/showthread.php?tid=509268)



/v command with car, and ID name - Riky35800 - 26.04.2014

Hello! I have a /vehicle command. the server have 2 virtual world. 1 = Stunt, 2 = Zombi world.
The /v command is works perfectly. If I enter the vehicle name, then put a vehicle in virtualworld 1, or 2.
There is nothing wrong. The problem is begin to: only works with vehicle id. How to solve it, is to write the name.
Example: /v Sultan And when you enter into it put me in the car (PutPlayerInVehicle)
Код:
CMD:v(playerid, params[])
{
	new vehicleid;
    if(sscanf(params, "d", vehicleid))return SendClientMessage(playerid, -1, "{73abff}<{ffffff}BSR{73abff}> {ffffff}Usage: /v [id]");
    {
        new Float:X, Float:Y, Float:Z, Float:Angle, carObject;
        GetPlayerPos(playerid, X, Y, Z);
        GetPlayerFacingAngle(playerid, Angle);
        carObject = CreateVehicle(vehicleid, X, Y, Z, Angle, random(10), random(10), -1);
        SetVehicleVirtualWorld(carObject, GetPlayerVirtualWorld(playerid));
 }
    return 1;
}



Re: /v command with car, and ID name - Riky35800 - 26.04.2014

The car name is not working


Re: /v command with car, and ID name - Konstantinos - 26.04.2014

Check if params is numeric and spawn the vehicle with that modelid. Else retrieve its modelid by the name a player specified (in params).


Re: /v command with car, and ID name - Riky35800 - 26.04.2014

Not working. How do I do it?


Re: /v command with car, and ID name - Eth - 26.04.2014

Quote:
Originally Posted by Riky35800
Посмотреть сообщение
Hello! I have a /vehicle command. the server have 2 virtual world. 1 = Stunt, 2 = Zombi world.
The /v command is works perfectly. If I enter the vehicle name, then put a vehicle in virtualworld 1, or 2.
There is nothing wrong. The problem is begin to: only works with vehicle id. How to solve it, is to write the name.
Example: /v Sultan And when you enter into it put me in the car (PutPlayerInVehicle)
Код:
CMD:v(playerid, params[])
{ 
	new vehicleid;
    if(sscanf(params, "d", vehicleid))return SendClientMessage(playerid, -1, "{73abff}<{ffffff}BSR{73abff}> {ffffff}Usage: /v [id]");
    {
        new Float:X, Float:Y, Float:Z, Float:Angle, carObject;
        GetPlayerPos(playerid, X, Y, Z);
        GetPlayerFacingAngle(playerid, Angle);
        carObject = CreateVehicle(vehicleid, X, Y, Z, Angle, random(10), random(10), -1);
        SetVehicleVirtualWorld(carObject, GetPlayerVirtualWorld(playerid));
 }
    return 1;
}
edit it with :
Код:
CMD:v(playerid, params[])
{
	new vehicleid,vehiclename[39],carObject;
if(sscanf(params,"s[39]",vehiclename)) return SendClientMessage(playerid,COLOR_RED,"Usage:/v [carname]");
    {
        new Float:X, Float:Y, Float:Z, Float:Angle, carObject;
        vehicleid =GetVehicleModelIDFromName(vehiclename);
        GetPlayerPos(playerid, X, Y, Z);
        GetPlayerFacingAngle(playerid, Angle);
        carObject = CreateVehicle(vehicleid, X, Y, Z, Angle, random(10), random(10), -1);
        SetVehicleVirtualWorld(carObject, GetPlayerVirtualWorld(playerid));
        PutPlayerInVehicle(playerid, vehicleid, 0);
 }
 return 1;
 }
add:
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"
};

stock GetVehicleName(vehicleid)
{
    format(String,sizeof(String),"%s",VehicleNames[GetVehicleModel(vehicleid) - 400]);
    return String;
}
GetVehicleModelIDFromName(vname[])
{
    for(new i = 0; i < 211; i++)
    {
        if(strfind(VehicleNames[i], vname, true) != -1)
        return i + 400;
    }
    return 0;
}



Re: /v command with car, and ID name - Riky35800 - 27.04.2014

Код:
C:\Users\Riky35800\Desktop\Fontos kellйkek\[Szerver] BSR Szerver\gamemodes\BSR.pwn(1195) : warning 219: local variable "carObject" shadows a variable at a preceding level
C:\Users\Riky35800\Desktop\Fontos kellйkek\[Szerver] BSR Szerver\gamemodes\BSR.pwn(1192) : warning 203: symbol is never used: "carObject"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: /v command with car, and ID name - Riky35800 - 27.04.2014

Fixed ! Thank you !