/car command, works with car IDs, but not with car names.
#1

Thanks for putting some time aside and reading this.

So, here's my code:
pawn Код:
GetVehicleFromName(string[], playerid, Float:x, Float:y, Float:z, Float:a, color1, color2)
{
    new var[20];
    new vehid;
    new countForMe, CountFor;
    for(new pp = 0; pp < 210; pp++)
    {
        countForMe = 0;
        format(var, sizeof(var), "%s", Vehicles[pp+400]);
        for(i = 0; i < sizeof(var)+1; i++)
        {
            if(strcmp(var[i], string[i], true) == 0)
            {
                countForMe++;
            }
            if(countForMe > CountFor)
            {
                vehid = pp + 400;
            }
        }
    }
    if(vehid == 0) return SendClientMessage(playerid, COLOR_ERROR, "Error: The vehicle name you chose does not exist.");
    CreateVehicle(vehid, x+3, y, z, a, color1, color2, -1);
    return 1;
}




IsNumeric(const string[])
{
    new j;
    for ( i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    IsNumber = 1;
    return 1;
}
       


CMD:car(playerid, params[])
{
    IsNumber = 0;
    new car[20], color1, color2;
    if(!IsPlayerAdmin(playerid) && PlayerInfo[playerid][AdminLevel] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not authorized to use this command.");
    if(sscanf(params, "s[20]dd", car, color1, color2)) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: {ABABAB}/car [car name/id] [color 1] [color 2]");
    if(color1 < 0 || color1 > 255 || color2 < 0 || color2 > 255) return SendClientMessage(playerid, COLOR_ERROR, "Error: Color number must be between 0 and 255.");
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);
   
    IsNumeric(car);
    if(IsNumber == 1)
    {
        if(strval(car) < 400 || strval(car) > 610) return SendClientMessage(playerid, COLOR_ERROR, "Error: You must select an ID between 400 and 610.");
        CreateVehicle(strval(car), x+2, y, z, a, color1, color2, -1);
    }
    else
    {
        GetVehicleFromName(car, playerid, x, y, z, a, color1, color2);
    }

    return 1;
}
When I use /car and put a vehicle name it says command unknown.

EDIT: I used some different variations of /car command and GetVehicleFromName or whatever it was, none worked.
Reply


Messages In This Thread
/car command, works with car IDs, but not with car names. - by Denying - 16.05.2014, 16:14
Re: /car command, works with car IDs, but not with car names. - by Mey6155 - 16.05.2014, 16:18
Re: /car command, works with car IDs, but not with car names. - by Denying - 16.05.2014, 16:20
Re: /car command, works with car IDs, but not with car names. - by Konstantinos - 16.05.2014, 16:32
Re: /car command, works with car IDs, but not with car names. - by Denying - 16.05.2014, 16:37

Forum Jump:


Users browsing this thread: 1 Guest(s)