Sistema de carro - gbzin - 10/11/2022
Bom o sistema que eu estava pensando era o seguinte
o player digita /car nome do veiculo e ele spawna
RE: Sistema de carro - Carlos Victor - 10/11/2022
Código: #include <a_samp>
#include <zcmd>
#include <sscanf2>
new stock g_arrVehicleNames[][] = {
"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", "Stratum", "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"
};
CMD:veh(playerid, params[])
{
static
model[32],
color1,
color2;
if(sscanf(cmdtext, "s[32]D(-1)D(-1)", model, color1, color2))
return SendClientMessage(playerid, -1, "* /veh [modelo id/nome] [cor 1(opcional)] [cor 2(opcional)]");
if((model[0] = GetVehicleModelByName(model)) == 0)
return SendClientMessage(playerid, -1, "* ID de modelo inválido.");
static
Float:x, Float:y, Float:z, Float:a, vehicle;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
vehicle = CreateVehicle(model[0], x, y, z, a, color1, color2, 0);
PutPlayerInVehicle(playerid, vehicle, 0);
return 1;
}
stock GetVehicleModelByName(const name[])
{
if(IsNumeric(name) && (strval(name) >= 400 && strval(name) <= 611))
return strval(name);
for(new i = 0; i < sizeof(g_arrVehicleNames); i ++)
{
if (strfind(g_arrVehicleNames[i], name, true) != -1)
{
return i + 400;
}
}
return 0;
}
stock IsNumeric(const str[])
{
for (new i = 0, l = strlen(str); i != l; i ++)
{
if (i == 0 && str[0] == '-')
continue;
else if (str[i] < '0' || str[i] > '9')
return 0;
}
return 1;
}
O código é grande, porém é o que você quer.
Eu compilei, zero erros, e também uso em meu servidor, caso tiver algum problema, avise.
RE: Sistema de carro - gbzin - 10/11/2022
(10/11/2022 16:54)Carlos Victor Escreveu: Código: #include <a_samp>
#include <zcmd>
#include <sscanf2>
new stock g_arrVehicleNames[][] = {
"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", "Stratum", "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"
};
CMD:veh(playerid, params[])
{
static
model[32],
color1,
color2;
if(sscanf(cmdtext, "s[32]D(-1)D(-1)", model, color1, color2))
return SendClientMessage(playerid, -1, "* /veh [modelo id/nome] [cor 1(opcional)] [cor 2(opcional)]");
if((model[0] = GetVehicleModelByName(model)) == 0)
return SendClientMessage(playerid, -1, "* ID de modelo inválido.");
static
Float:x, Float:y, Float:z, Float:a, vehicle;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
vehicle = CreateVehicle(model[0], x, y, z, a, color1, color2, 0);
PutPlayerInVehicle(playerid, vehicle, 0);
return 1;
}
stock GetVehicleModelByName(const name[])
{
if(IsNumeric(name) && (strval(name) >= 400 && strval(name) <= 611))
return strval(name);
for(new i = 0; i < sizeof(g_arrVehicleNames); i ++)
{
if (strfind(g_arrVehicleNames[i], name, true) != -1)
{
return i + 400;
}
}
return 0;
}
stock IsNumeric(const str[])
{
for (new i = 0, l = strlen(str); i != l; i ++)
{
if (i == 0 && str[0] == '-')
continue;
else if (str[i] < '0' || str[i] > '9')
return 0;
}
return 1;
}
O código é grande, porém é o que você quer.
Eu compilei, zero erros, e também uso em meu servidor, caso tiver algum problema, avise. Código PHP: error 017: undefined symbol "cmdtext"
error 025: function heading differs from prototype
error 021: symbol already defined: "IsNumeric"
warning 213: tag mismatch
warning 213: tag mismatch
deu isso.
RE: Sistema de carro - Vel - 10/11/2022
Código: CMD:veh(playerid, params[]) {
new modelid;
if (sscanf(params, "k<vehicle>", modelid)) {
return SendClientMessage(playerid, -1, "/veh [ID ou nome do modelo]");
}
if (modelid == -1) {
return SendClientMessage(playerid, -1, "Modelo inválido.");
}
new Float: x,
Float: y,
Float: z,
Float: ang;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, ang);
PutPlayerInVehicle(playerid, CreateVehicle(modelid, x, y, z, ang, -1, -1, cellmin), 0);
return 1;
}
RE: Sistema de carro - gbzin - 10/11/2022
(10/11/2022 17:06)Vel Escreveu: Código: CMD:veh(playerid, params[]) {
new modelid;
if (sscanf(params, "k<vehicle>", modelid)) {
return SendClientMessage(playerid, -1, "/veh [ID ou nome do modelo]");
}
if (modelid == -1) {
return SendClientMessage(playerid, -1, "Modelo inválido.");
}
new Float: x,
Float: y,
Float: z,
Float: ang;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, ang);
PutPlayerInVehicle(playerid, CreateVehicle(modelid, x, y, z, ang, -1, -1, cellmin), 0);
return 1;
}
botei e deu interferencia nos mapper
RE: Sistema de carro - Carlos Victor - 10/11/2022
(10/11/2022 17:06)Vel Escreveu: Código: CMD:veh(playerid, params[]) {
new modelid;
if (sscanf(params, "k<vehicle>", modelid)) {
return SendClientMessage(playerid, -1, "/veh [ID ou nome do modelo]");
}
if (modelid == -1) {
return SendClientMessage(playerid, -1, "Modelo inválido.");
}
new Float: x,
Float: y,
Float: z,
Float: ang;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, ang);
PutPlayerInVehicle(playerid, CreateVehicle(modelid, x, y, z, ang, -1, -1, cellmin), 0);
return 1;
}
Que show! Eu não sabia desse specifiers, que legal. Vou até reajustar meu comando.
|