return as invalid command
#1

im trying to reload the bought vehicles with /reload but the command return as invalid "SERVER: Unknown Command"
pawn Код:
CMD:reload(playerid,params[])
{
    Loop(MAX_OV,v)
    {
        if(strlen(VehicleData[getVehicleID(v)][Vehicleowner]) >= 3)
        {
            DestroyVehicle(getVehicleID(v));
            printf("Vehicle ID: %d |> Removed!", v);
        }
        return 1;
    }
    LoadOwnedVehicles();
    return 1;
}

stock getVehicleID(vehicleid)
{
    Loop(MAX_VEHICLES, vID)
    {
        if(VehicleData[vID][VehicleID] == vehicleid)
        {
            return vID;
        }
    }
    return -1;
}
Reply
#2

Try and show us the last print
pawn Код:
CMD:reload(playerid,params[])
{
    Loop(MAX_OV,v)
    {
        print("1");
        if(strlen(VehicleData[getVehicleID(v)][Vehicleowner]) >= 3)
        {
            DestroyVehicle(getVehicleID(v));
            printf("Vehicle ID: %d |> Removed!", v);
            print("2");
        }
        return 1;
    }
    print("3");
    LoadOwnedVehicles();
    print("4");
    return 1;
}
Reply
#3

Код:
[00:05:49] 1
:/
Reply
#4

Ok xd remove the first return 1; :P
Reply
#5

hm, still same
Reply
#6

new VehicleData[here is MAX_VEHICLES ?][enum];
Reply
#7

new VehicleData[MAX_OV][vInfo];
Reply
#8

hah and MAX_OV is? and here is error getVehicleID(v), replace Loop(MAX_VEHICLES, vID) to Loop(MAX_OV, vID) or not hm You dont need that getVehicleID(v) i think
Reply
#9

It's a problem with the new version of sa-mp server. I had a command /v that worked perfectly (With a loop, using Loop(x, y) {} ) , and with the new versions, it returned as Unknown Command. I fixed it now.

The real problem is: The new version of sa-mp has a LOWER limit of the size of the string. I lowed the number and it worked

and also, can we see the "Loop" macro, I have a Loop macro too, but it's different, my Loop usage is: "Loop(x, max)"

pawn Код:
#define Loop(%0,%1) for(new %0; %0 < %1; %0++)
Look at my "/veh" command:

pawn Код:
if(!strcmp(cmd, "/veh"))
{
    if(GetPlayerScore(playerid) < 3) return MessaggioTradotto(playerid, 0xFF0000FF, "Devi essere almeno al livello 3 per usare questo comando!", "You must be at least level 3 to use this command!");
    new string[2500]; // This was 3500 before
    new string2[51];
    Loop(i, sizeof(GTA_CarNames))
    {
        format(string2, 51, GTA_CarNames[i]);
        format(string, sizeof(string), "%s%s\n", string, string2);
    }
    ShowPlayerDialog(playerid, DIALOGO_SCELTA_AUTO,DIALOG_STYLE_LIST, "Seleziona un veicolo - Select a vehicle", string, "OK", "Cancel");
}
I changed [3500] to [2500].
Reply
#10

Here array is crash
pawn Код:
stock getVehicleID(vehicleid)
{
    Loop(MAX_VEHICLES, vID)
    {
        if(VehicleData[vID][VehicleID] == vehicleid)
        {
            return vID;
        }
    }
    return -1;
}
MAX_OV = 100
MAX_VEHICLES = 2000
if(VehicleData[if vID > MAX_OV = crash / unknown command][VehicleID] == vehicleid)
Reply
#11

i got this now
pawn Код:
#define MAX_OV    50

CMD:reload(playerid, params[])
{
    Loop(MAX_VEHICLES, v)
    {
        print("1");
        if(VehicleData[getVehicleID(v)][Vehiclecost] == 100)
        {
            DestroyVehicle(getVehicleID(v));
            printf("Vehicle ID: %d |> Removed!", getVehicleID(v));
            print("2");
        }
    }
    print("3");
    SetTimer("Loadvehicles", 5000, false);
    print("4");
    return 1;
}

forward Loadvehicles();
public Loadvehicles()
{
    LoadOwnedVehicles();
    return 1;
}

stock GetVehicleID(vehicleid)
{
    Loop(MAX_VEHICLES, vID)
    {
        if(VehicleData[vID][VehicleID] == vehicleid)
        {
            return vID;
        }
    }
    return -1;
}
i want to remove all vehicles that cost $100

i got a commadn /cost to check it too

it says id:

1
&
2
costs $100

but it removes vehicle 0 and 1 instead..

[00:35:38] Vehicle ID: 0 |> Removed!
[00:35:38] Vehicle ID: 1 |> Removed!

it removes vehicles but still return unknown
Reply
#12

How You buy a vehicle?
Reply
#13

pawn Код:
CMD:vehicle(playerid, params[])
{
    new Float:X, Float:Y, Float:Z, Float:A;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);
    CreateVehicleEx(GetFreeVehicleSlot(), PName(playerid), 411, X, Y, Z, A, 100);
    return 1;
}

stock CreateVehicleEx(ID, Owner[], modelid, Float:X, Float:Y, Float:Z, Float:A, Cost)
{
    new vehicleid = CreateVehicle(modelid, X, Y, Z, A, -1, -1, 99999);
    VehicleData[ID][VehicleID] = vehicleid;
    format(VehicleData[ID][VehicleOwner], 24, Owner);
    VehicleData[ID][VehicleX] = X;
    VehicleData[ID][VehicleY] = Y;
    VehicleData[ID][VehicleZ] = Z;
    VehicleData[ID][VehicleA] = A;
    VehicleData[ID][VehicleModel] = modelid;
    VehicleData[ID][VehicleCost] = Cost;
    VehicleData[ID][VehicleSell] = Cost / 2;
    return VehicleFreeSlot[ID] = true;
}
Reply
#14

Omg so use VehicleData[ID][VehicleID] = vehicleid;
pawn Код:
CMD:reload(playerid, params[])
{
    Loop(MAX_OV, v)
    {
        print("1");
        if(VehicleData[v][Vehiclecost] == 100)
        {
            DestroyVehicle(VehicleData[v][VehicleID]);
            printf("Vehicle ID: %d |> Removed!", VehicleData[v][VehicleID]);
            print("2");
        }
    }
    print("3");
    SetTimer("Loadvehicles", 5000, false);
    print("4");
    return 1;
}
and reset arrays
VehicleData[v][VehicleID] = 0; etc
Reply
#15

still remove wrong ids

[00:52:34] Vehicle ID: 0 |> Removed!
[00:52:34] Vehicle ID: 1 |> Removed!

it should have removed 1 & 2 not 0 & 1

(But the unknown command bug is gone)
Reply
#16

So here GetFreeVehicleSlot() or here Loop(MAX_OV, v) is error. Or show the whole script on pm
pawn Код:
VehicleData[ID][VehicleID] = CreateVehicle(modelid, X, Y, Z, A, -1, -1, 99999);
shorter :P
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)