PDA

View Full Version : [Urgent]Command Help: Both Get Me Wrong Car


Danyal
18/11/2011, 04:46 PM
dcmd_vgoto(playerid,params[]) {
if(PlayerInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid)) {
if(!strlen(params)) return SendClientMessage(playerid,red,"USAGE: /vgoto [vehicleid]");
new player1, string[128];
player1 = strval(params);
CMDMessageToAdmins(playerid,"VGOTO");
new Float:x, Float:y, Float:z; GetVehiclePos(player1,x,y,z);
SetPlayerVirtualWorld(playerid,GetVehicleVirtualWo rld(player1));
if(GetPlayerState(playerid) == 2) {
SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z );
SetVehicleVirtualWorld(GetPlayerVehicleID(playerid ), GetVehicleVirtualWorld(player1) );
} else SetPlayerPos(playerid,x+2,y,z);
format(string,sizeof(string),"You have teleported to vehicle id %d", player1);
return SendClientMessage(playerid,blue,string);
} else return SendClientMessage(playerid,red,""Yellow"Error: "White"You are not a high enough level to use this command");
}

dcmd_vget(playerid,params[]) {
if(PlayerInfo[playerid][Level] >= 3 || IsPlayerAdmin(playerid)) {
if(!strlen(params)) return SendClientMessage(playerid,red,"USAGE: /vget [vehicleid]");
new player1, string[128];
player1 = strval(params);
CMDMessageToAdmins(playerid,"VGET");
new Float:x, Float:y, Float:z; GetPlayerPos(playerid,x,y,z);
SetVehiclePos(player1,x+3,y,z);
SetVehicleVirtualWorld(player1,GetPlayerVirtualWor ld(playerid));
format(string,sizeof(string),"You have brough vehicle id %d to your location", player1);
return SendClientMessage(playerid,blue,string);
} else return SendClientMessage(playerid,red,""Yellow"Error: "White"You are not a high enough level to use this command");
}

above command get me wrong cars if i type /vget 562 it get me car 469 the banshee one i think so. please fix them. +2rep for help

Daddy Yankee
18/11/2011, 04:55 PM
That's because you're bringing to you the vehicle id currently on your server not the vehicle model...

Danyal
18/11/2011, 04:57 PM
then who can i get vehicle mode with that cmd

Daddy Yankee
18/11/2011, 05:03 PM
Your cmd just brings an existing vehicle to you, I think what you want is to spawn one.. I have this FS, I hope it will help you..


#define FILTERSCRIPT

#include <a_samp>



#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GRAD3 0xCBCCCEFF
#define COLOR_GRAD4 0xD8D8D8FF
#define COLOR_GRAD5 0xE3E3E3FF

new gDestroyVehicle[MAX_VEHICLES];
new CreatedCars[MAX_VEHICLES] = {INVALID_VEHICLE_ID, ...};

public OnFilterScriptInit()
{
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

new vehName[][] = // array for vehicle names to be displayed
{
"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", "SWAT Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan",
"Blade", "Streak", "Freight", "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", "LSPD Car", "SFPD Car", "LVPD Car",
"Police Rancher", "Picador", "S.W.A.T", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs",
"Boxville", "Tiller", "Utility Trailer"
};

stock ReturnVehicleModelID(string[])
{

if(IsNumeric(string))
{
new id = strval(string);

if(id >= 400 && id <= 611)
{
return id;
}
}

for(new i = 0;i < sizeof(vehName);i++)
{
if(strfind(vehName[i],string,true) != -1)
{
return i + 400;
}
}

return 0;
}


stock strvalEx( str[ ] )
{
if( strlen( str ) >= 50 ) return -1;
return strval( str );
}

strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}

new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128];
new tmp[128];
new idx;
new string[256];
cmd = strtok(cmdtext, idx);
if (strcmp(cmdtext, "/setcarvw", true)==0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
return 1;
}
new vehid = strvalEx(tmp);
new world = GetVehicleVirtualWorld(vehid);
SetPlayerVirtualWorld(playerid, world);

}
if(strcmp(cmd, "/veh", true) == 0)
{

tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [vehicle name/ID] [color1(optional)] [color2(optional)]");

new car = ReturnVehicleModelID(tmp);
if(!car)
return SendClientMessage(playerid, COLOR_GREY, " Invalid vehicle model name/ID.");

new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
color1 = -1;
color2 = -1;
}
else
{
color1 = strval(tmp);
if(color1 < -1 || color1 > 200)
return SendClientMessage(playerid, COLOR_GREY, " Enter a valid color [0-200]");

tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) color2 = color1;
else color2 = strval(tmp);
if(color2 < -1 || color2 > 200)
return SendClientMessage(playerid, COLOR_GREY, " Enter a valid color [0-200]");
}

if(IsPlayerInAnyVehicle(playerid))
RemovePlayerFromVehicle(playerid);
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid,A);
new carid = CreateVehicle(car, X,Y,Z,A, color1, color2, -1);
PutPlayerInVehicle(playerid,carid,0);
LinkVehicleToInterior(carid,GetPlayerInterior(play erid));
for(new i = 0; i < sizeof(CreatedCars); i++)
{
if(CreatedCars[i] == INVALID_VEHICLE_ID)
{
CreatedCars[i] = carid;
break;
}
}
return 1;
}

if(strcmp(cmd, "/destroycar", true)== 0)
{

new currentVehicle = GetPlayerVehicleID(playerid);
if(currentVehicle == 0) return SendClientMessage(playerid,COLOR_GREY, "You must be in a vehicle to destroy it.");
new check;
for(new i = 0; i < sizeof(CreatedCars); i++)
{
if(CreatedCars[i] == currentVehicle)
{
check = 1;
CreatedCars[i] = INVALID_VEHICLE_ID;
break;
}
}
if(!check) return SendClientMessage(playerid, COLOR_GRAD1, "You may only destroy a vehicle that was created with /veh.");

gDestroyVehicle[currentVehicle] = 1;
DestroyVehicle(currentVehicle);
return 1;
}
}
if(strcmp(cmd, "/destroycars", true) == 0)
{

new vehcount = 0;
for(new i = 0; i < sizeof(CreatedCars); i++)
{
if(CreatedCars[i] != INVALID_VEHICLE_ID)
{
vehcount++;
gDestroyVehicle[CreatedCars[i]] = 1;
DestroyVehicle(CreatedCars[i]);
CreatedCars[i] = INVALID_VEHICLE_ID;
}
}
return 1;
}

return 0;
}

Danyal
18/11/2011, 05:07 PM
no i dont mean to create any other vehicle i only want to bring server car's to me where ever any empty car is of my choice like /vget 562 it get me server elegy that is empty and /vgoto 562 it should teleport me to vehicle id that i specified they should get me server cars not out side cars