Command returns 0?
#1

pawn Код:
COMMAND:closestcar(playerid, params[])
{
    if(GetPVarInt(playerid, "Admin") > 0)
    {
        new Float:X, Float:Y, Float:Z, Float:CX, Float:CY, Float:CZ, Float:prevdist=100000.000,closestid=MAX_VEHICLES+1;
        GetPlayerPos(playerid, CX, CY, CZ);
        for(new i=0; i < MAX_VEHICLES; i++)
        {
            GetVehiclePos(i, X, Y, Z);
            new Float:dist = GetDistanceFromPoint(X,Y,Z,CX,CY,CZ);
            if((dist < prevdist))
            {
                prevdist = dist;
                closestid = i;
            }
        }
        new string[128];
        format(string, 128, "Closest Vehicle: ID[%d] - Vehicle Name:[%s]", closestid, VehicleName[closestid-400]);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        return 1;
    }
    else SendErrorMessage(playerid);
    return 1;
}
When I type the command I get "SERVER: Unknown command"

I don't know why, can someone help me?

Thanks.
Reply
#2

E: Nvm.
Reply
#3

No, I do that for everything else (all admin commands).
Reply
#4

you are simply trying to format the VehicleName[] string with an VehicleID out of range (0-2000):
Код:
format(string, 128, "Closest Vehicle: ID[%d] - Vehicle Name:[%s]", closestid, VehicleName[closestid-400]);
the GetVehicleModel will fix it...
Код:
format(string, 128, "Closest Vehicle: ID[%d] - Vehicle Name:[%s]", closestid, VehicleName[GetVehicleModel(closestid)-400]);
Reply
#5

Oh, how did I forget that! Thanks1
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)