#include <a_samp>
#include <LIFE-CMD>
new gVehicleNames[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", "Harley", "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", "Hotring Racer", "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", "Traktor",
"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", "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", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club", "Trailer", "Trailer",
"Andromeda", "Dodo", "RC Cam", "Launch", "Radiowoz", "Radiowoz", "Radiowoz", "Radiowoz", "Picador", "S.W.A.T. Van",
"Alpha", "Phoenix", "Glendale", "Sadler", "Luggage Trailer", "Luggage Trailer", "Stair Trailer", "Boxville", "Farm Plow", "Utility Trailer"
};
playaName(playerid)
{
static Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
return Name;
}
CreatePlayerVehicle(playerid, modelid)
{
new vehicle, Float: X, Float: Y, Float: Z, Float: angle;
if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
vehicle = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicle, X, Y, Z);
GetVehicleZAngle(vehicle, angle);
DestroyVehicle(vehicle);
}
else
{
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, angle);
}
vehicle = AddStaticVehicle(modelid, X, Y, Z + 1, angle, -1, -1);
LinkVehicleToInterior(vehicle, GetPlayerInterior(playerid));
SetVehicleVirtualWorld(vehicle, GetPlayerVirtualWorld(playerid));
SetVehicleNumberPlate(vehicle, playaName(playerid));
PutPlayerInVehicle(playerid, vehicle, 0);
return 1;
}
str_del_free_space (string[], _char = ' ')
{
new len = strlen (string);
if (len)
{
new begin = -1, end = len;
while (string[++begin] == _char) {}
if (string[begin] == EOS)
{
string [0] = 0;
return 1;
}
while (string[--end] == _char) {}
strmid (string, string, begin, end+1, len+1);
}
return 1;
}
GetVehicleModelIdByName(vehiclename[])
{
for(new i = 0; i < 211; i++)
if (strfind(gVehicleNames[i], vehiclename, true) != -1) return i + 400;
return -1;
}
CMD:v(playerid, params[])
{
str_del_free_space(params);
if(isnull(params)) return SendClientMessage(playerid, -1, "Write /v CarName");
CreatePlayerVehicle(playerid, GetVehicleModelIdByName(params));
return 1;
}
|
Commands with params won't work. |
|
Why is this "multi-threaded"? That doesn't make code faster! You specifically state that you are new to C++ but decide to use what is widely regarded as one of the hardest things in programming to get right (threads) with no understanding at all of WHY it should be used. xeeZ already touched on this and I agree entirely. This is what you do:
So, to sumarise:
"Threads" are not a magic "go faster" switch - they are hard. I'll come to the more minor points after you fix these. Edit: Actually, no, let's go:
|
|
This is the reason why i was reading the whole damn thread , post by post. This is all i wanted to hear. This is nowhere faster then y_cmd or zcmd in real.
|
|
Because I've seen numerous attempts to "optimised" zcmd - usually by removing support for various corner cases or protection against crashers. Or getting rid of the extra callbacks. However, none of these have ever been faster once the bugs were pointed out and code to correct them added back in.
|
|
Because I've seen numerous attempts to "optimised" zcmd - usually by removing support for various corner cases or protection against crashers. Or getting rid of the extra callbacks. However, none of these have ever been faster once the bugs were pointed out and code to correct them added back in.
|
|
Hum... When i create my cmd processor I had some bugs but now don't have bugs and don't crash.
When i used slice benchmark and gave me 236.99 times/ms i knew that was very good to me. |
|
Indeed, ****** is right...
There's nothing bad about writing your own version or integrating zcmd into your gamemode so it fully fits your needs (leave out the callbacks, do it all in OnPlayerCommandText, remove unnecessary features, whatever floats your server's boat), but in such case, you cannot directly compare it to the original zcmd. |