SA-MP Forums Archive
return as invalid command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: return as invalid command (/showthread.php?tid=273217)



return as invalid command - Unknown123 - 31.07.2011

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;
}



Re: return as invalid command - Jefff - 31.07.2011

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;
}



Re: return as invalid command - Unknown123 - 31.07.2011

Код:
[00:05:49] 1
:/


Re: return as invalid command - Jefff - 31.07.2011

Ok xd remove the first return 1; :P


Re: return as invalid command - Unknown123 - 31.07.2011

hm, still same


Re: return as invalid command - Jefff - 31.07.2011

new VehicleData[here is MAX_VEHICLES ?][enum];


Re: return as invalid command - Unknown123 - 31.07.2011

new VehicleData[MAX_OV][vInfo];


Re: return as invalid command - Jefff - 31.07.2011

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


Re: return as invalid command - Sasino97 - 31.07.2011

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].


Re: return as invalid command - Jefff - 31.07.2011

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)


Re: return as invalid command - Unknown123 - 31.07.2011

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


Re: return as invalid command - Jefff - 31.07.2011

How You buy a vehicle?


Re: return as invalid command - Unknown123 - 31.07.2011

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;
}



Re: return as invalid command - Jefff - 31.07.2011

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


Re: return as invalid command - Unknown123 - 31.07.2011

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)


Re: return as invalid command - Jefff - 31.07.2011

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