[AJU]Criar comando /criarveiculo
#1

Tipo estou a fazer um fs de criar veнculos, aqui como estб:


pawn Код:
#include <a_samp>
#include <core>
#include <float>

#define COR_AMARELO 0xFFFF00FF
#define COR_VERDE 0x33AA33AA

new VehicleName[212][0] = {
"Landstalker",//--------> Numero 0
"Bravura",// --------> Numero 1
"Buffalo",// -------> Numero 2
"Linerunner",// -------> E assim vai...
"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 Truck",
"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",
"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",
"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 Truck",
"Monster Truck",
"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",
"Andromada",
"Dodo",
"RC Cam",
"Launch",
"Polнcia (LSPD)",
"Polнcia (SFPD)",
"Polнcia (LVPD)",
"Police Ranger",
"Picador",
"S.W.A.T. Van",
"Alpha",
"Phoenix",
"Glendale",
"Sadler",
"Trailer de Bagagens",
"Trailer de Bagagens",
"Stair Trailer",
"Boxville",
"Farm Plow",
"Trailer de Utilidades"
};

public OnPlayerCommandText(playerid, cmdtext[])
{
    /*
    new Float:x;
    new Float:y;
    new Float:z;
    new Float:a;
    GetPlayerPos(playerid, Float:x, Float:y, Float:z);
    GetPlayerFacingAngle(playerid, Float:a);
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    */

     //PutPlayerInVehicle(playerid, CreateVehicle(401, x, y, z + 2.0, a, 1, 0, 10000) , 0);
    if (strcmp(cmdtext, "/nomeveiculo", true)==0)
    {
    new string [256];
    new tmp[256];
    new idveiculo;
    idveiculo = strval(tmp);
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
        {
        SendClientMessage(playerid, COR_VERDE, "[ERRO DE SINTAXE] /nomeveiculo [id]");
        return 1;
        }
    format(string, sizeof(string), "Nome do veнculo: %s.", VehicleName[idveiculo - 400]);
    SendClientMessageToAll(COR_VERDE, string);
    return 1;
    }
    return 1;
}
Ai eu peguei pronto em um site, ele consulta as informaзхes la em cima no nome dos carros e manda a mensagem, ai vou mudar pra ao inves da msg criar o veiculo(dexa que com essa parte eu me viro), so quero entender porque dб os segunites erros:

Код:
C:\Documents and Settings\Marxista\Meus documentos\SAMP SERVER\filterscripts\criarveiculo.pwn(312) : error 017: undefined symbol "strtok"
C:\Documents and Settings\Marxista\Meus documentos\SAMP SERVER\filterscripts\criarveiculo.pwn(312) : error 033: array must be indexed (variable "tmp")
Linha 312:

pawn Код:
tmp = strtok(cmdtext, idx);
Reply
#2

Tenta coloca isso no final do seu gamemode

pawn Код:
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;
}
Reply
#3

BGlz DR_PAWNO funfou o que vocк me disse, mas agora fui fazer o que quero que й criar o veiculo nй e botei assim dai:

pawn Код:
SendClientMessage(playerid, COR_VERDE, "Use: /nomeveiculo [id]");
        return 1;
        }
    format(string, sizeof(string), "Nome do veнculo: %s.", VehicleName[idveiculo - 400]);
    SendClientMessageToAll(COR_VERDE, string);
    PutPlayerInVehicle(playerid, CreateVehicle(VehicleName[idveiculo - 400] , x, y, z + 2.0, a, 1, 0, 10000) , 0);
    return 1;
Mas da erro agora:
Код:
C:\Documents and Settings\Marxista\Meus documentos\SAMP SERVER\filterscripts\criarveiculo.pwn(319) : error 035: argument type mismatch (argument 1)
A linha eh a que ta:

pawn Код:
PutPlayerInVehicle(playerid, CreateVehicle(VehicleName[idveiculo - 400] , x, y, z + 2.0, a, 1, 0, 10000) ,
Reply
#4

Tenta coloca assim:

pawn Код:
PutPlayerInVehicle(playerid, CreateVehicle(VehicleName[idveiculo - 400], 1);
Reply
#5

continua o mesmo erro
Reply
#6

hum... tenta assim. (n sei c vai dar serto)
pawn Код:
//          PutPlayerInVehicle(playerid, CreateVehicle(VehicleName[idveiculo - 400], 1);
            new Float: X;
            new Float: Y;
            new Float: Z;
            GetPlayerPos(playerid, X, Y, Z);
            CreateVehicle(VehicleName[idveiculo - 400], X, Y, Z +5, -1, -1, -1);
Reply
#7

olha, ja consegui tirar os erros, agora so falta funcionar neh.
O pior eh que com esse fs no server os cmds normais do gm nao funfam
Reply
#8

Talvez se visse em outros fуruns iria ver minha funзгo. enfim olha esse que arrumei
pawn Код:
#include <a_samp>
#include <core>
#include <float>

#define COR_AMARELO 0xFFFF00FF
#define COR_VERDE 0x33AA33AA

new VehicleName[212][0] = {
"Landstalker",//--------> Numero 0
"Bravura",// --------> Numero 1
"Buffalo",// -------> Numero 2
"Linerunner",// -------> E assim vai...
"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 Truck",
"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",
"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",
"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 Truck",
"Monster Truck",
"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",
"Andromada",
"Dodo",
"RC Cam",
"Launch",
"Polнcia (LSPD)",
"Polнcia (SFPD)",
"Polнcia (LVPD)",
"Police Ranger",
"Picador",
"S.W.A.T. Van",
"Alpha",
"Phoenix",
"Glendale",
"Sadler",
"Trailer de Bagagens",
"Trailer de Bagagens",
"Stair Trailer",
"Boxville",
"Farm Plow",
"Trailer de Utilidades"
};

public OnPlayerCommandText(playerid, cmdtext[])
{
    /*
    new Float:x;
    new Float:y;
    new Float:z;
    new Float:a;
    GetPlayerPos(playerid, Float:x, Float:y, Float:z);
    GetPlayerFacingAngle(playerid, Float:a);
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    */

     //PutPlayerInVehicle(playerid, CreateVehicle(401, x, y, z + 2.0, a, 1, 0, 10000) , 0);
    if (strcmp(cmdtext, "/nomeveiculo", true)==0)
    {
    new string [256];
    new tmp[256];
    new idveiculo;
    idveiculo = strval(tmp);
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
        {
        SendClientMessage(playerid, COR_VERDE, "[ERRO DE SINTAXE] /nomeveiculo [id]");
        return 1;
        }
    CreateVehicleInPlayer(playerid,idveiculo );
    format(string, sizeof(string), "Nome do veнculo: %s.", VehicleName[idveiculo - 400]);
    SendClientMessageToAll(COR_VERDE, string);
    return 1;
    }
    return 0;//em seu estava '1' nгo pode ser '1' tem que ser >> '0' <<, por isso desarruma comandos do server..
}

CreateVehicleInPlayer(playerid,modelid)
{
        new Float: xxx,
            Float: yyy,
                Float: zzz,
                Float: rrr,
                vehicle;
 
        GetPlayerPos(playerid,xxx,yyy,zzz);
        GetPlayerFacingAngle(playerid,rrr);
 
        vehicle = CreateVehicle(modelid,xxx,yyy,zzz,rrr,3,0,1);
        PutPlayerInVehicle(playerid,vehicle,0);
}
Reply
#9

ok, drakon.

funcionou, agora quando executo o cmd /nomeveiculo ele diz que nao existe.

P.S.:eu boto: /nomeveiculo 400 durante o jogo ta

por isso nao gosot muito de programaзгo, um numero ja faz tudo da erro.
Reply
#10

Coloca isso ao GM...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)