PDA

View Full Version : Vehicle command


AiRaLoKa
21/05/2014, 08:19 AM
hi...

i got a problem here, when i tried to type /vehicle [vehicleid], it give me an error. it happened too with /lveh command. Before, it was worked fine, but when i give a lot of vehicle into my server, it's now bugged.

CMD:vehicle(playerid, params[])
{
if(IsPlayerInDM(playerid))
{
SendClientMessageLang(playerid, COLOR_RED, ""Err" You cannot spawn vehicle when you are on minigame!", ""Err" Anda tidak bisa menspawn kedaraan saat berada di minigame!");
}
else
{
new Float:x, Float:y, Float:z;
new vehicle = GetVehicleModelIDFromName(params);

if(!strlen(params)) return ShowVehicleDialog(playerid);
if(vehicle < 400 || vehicle > 611) return ShowVehicleDialog(playerid);

new Float:a;
GetPlayerFacingAngle(playerid, a);
GetPlayerPos(playerid, x, y, z);

VehicleSpawner(playerid, vehicle);
/*DestroyVehicle(PlayersVehicle[playerid]);
PlayersVehicle[playerid] = CreateVehicle(vehicle, x, y, z+1, a, -1, -1, -1);
LinkVehicleToInterior(PlayersVehicle[playerid], GetPlayerInterior(playerid));
PutPlayerInVehicle(playerid, PlayersVehicle[playerid], 0);*/
}
return 1;
}

public VehicleSpawner(playerid,model)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vid = GetPlayerVehicleID(playerid);
DestroyVehicle(vid);
if(VehicleSpawn[playerid]==0)
{
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
DestroyVehicle(PlayersVehicle[playerid]);
PlayersVehicle[playerid] = AddStaticVehicle(model, x, y, z+1, a, -1, -1);
PutPlayerInVehicle(playerid, PlayersVehicle[playerid], 0);
SetVehicleHealth(PlayersVehicle[playerid], 1000.0);
LinkVehicleToInterior(PlayersVehicle[playerid], GetPlayerInterior(playerid));
}
}
else
{
if(VehicleSpawn[playerid]==0)
{
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
DestroyVehicle(PlayersVehicle[playerid]);
PlayersVehicle[playerid] = AddStaticVehicle(model, x, y, z+1, a, -1, -1);
PutPlayerInVehicle(playerid, PlayersVehicle[playerid], 0);
SetVehicleHealth(PlayersVehicle[playerid], 1000.0);
LinkVehicleToInterior(PlayersVehicle[playerid], GetPlayerInterior(playerid));
}
}
return 1;
}

CMD:lveh(playerid,params[])
{
//new file[256];
//format(file,sizeof(file),"SavedVeh/%s.sav", pName(playerid));
new Query[256];
new rows,fields;

new Float:nx,Float:ny,Float:nz,Float:nrot;
new ID, Model, col1, col2, comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, pj;
mysql_format(dbHandle,Query,sizeof Query,"SELECT * FROM `SavedVeh` WHERE `Name` = '%s'",pName(playerid));
mysql_query(dbHandle,Query);
cache_get_data(rows,fields);
if(rows)
{
GetPlayerPos(playerid, nx, ny, nz);
GetPlayerFacingAngle(playerid, nrot);
ID = cache_get_field_content_int(0,"ID");
DestroyVehicle(PlayerVehicle[ID]);
Model = cache_get_field_content_int(0,"Model");
nrot = cache_get_field_content_float(0,"A");

col1 = cache_get_field_content_int(0,"Col1");
col2 = cache_get_field_content_int(0,"Col2");
comp1 = cache_get_field_content_int(0,"1");
comp2 = cache_get_field_content_int(0,"2");
comp3 = cache_get_field_content_int(0,"3");
comp4 = cache_get_field_content_int(0,"4");
comp5 = cache_get_field_content_int(0,"5");
comp6 = cache_get_field_content_int(0,"6");
comp7 = cache_get_field_content_int(0,"7");
comp8 = cache_get_field_content_int(0,"8");
comp9 = cache_get_field_content_int(0,"9");
pj = cache_get_field_content_int(0,"PJ");
PlayerVehicle[ID]=AddStaticVehicle(Model, nx, ny, nz, nrot, col1, col2);
AddVehicleComponent(PlayerVehicle[ID], comp1);
AddVehicleComponent(PlayerVehicle[ID], comp2);
AddVehicleComponent(PlayerVehicle[ID], comp3);
AddVehicleComponent(PlayerVehicle[ID], comp4);
AddVehicleComponent(PlayerVehicle[ID], comp5);
AddVehicleComponent(PlayerVehicle[ID], comp6);
AddVehicleComponent(PlayerVehicle[ID], comp7);
AddVehicleComponent(PlayerVehicle[ID], comp8);
AddVehicleComponent(PlayerVehicle[ID], comp9);
ChangeVehiclePaintjob(PlayerVehicle[ID], pj);
PutPlayerInVehicle(playerid, PlayerVehicle[ID], 0);
arendaveh[PlayerVehicle[ID]] = playerid;
isarenda[PlayerVehicle[ID]] = 1;
}
else
{
SendClientMessageLang(playerid, 0xFF0000FF, ""Err" You don't have a saved vehicle!", ""Err" Anda tidak memiliki kendaraan pribadi.");
}
return 1;
}

P.S.: i have for about 2000 vehicle in my gamemode

BroZeus
21/05/2014, 08:30 AM
whats the bug?

AiRaLoKa
21/05/2014, 08:44 AM
whats the bug?

i can't spawn any vehicle

rockhopper
21/05/2014, 08:58 AM
Try this
new VehicleNames[212][] =
{
"Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster","Stretch","Manana","Infernus",
"Voodoo","Pony","Mule","Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto","Taxi","Washington","Bobcat","Mr 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","ZR3 50","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","Cropdust","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 A",
"Monster B","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight","Trailer",
"Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford","BF-400","Newsvan","Tug","Trailer A","Emperor",
"Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C","Andromada","Dodo","RC Cam","Launch","Police Car (LSPD)","Police Car (SFPD)",
"Police Car (LVPD)","Police Ranger","Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B",
"Stair Trailer","Boxville","Farm Plow","Utility Trailer"
};
At top of script and try

AiRaLoKa
21/05/2014, 09:12 AM
no the only one problem is there is too many vehicle in my server...

when i tried to remove the vehicle, it's worked again...

CASE CLOSED!!!