Errores
#1

El siguiente codigo me da errores.

pawn Код:
CMD:v(playerid,params[])
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"Ya tienes un vehiculo. Baja e intenta de nuevo.");
new id;
new vehiculo;
if(sscanf(params,"i",id)) return SendClientMessage(playerid,COLOR_RED,"USO: /v [Nombre del vehiculo o ID");
if(!IsNumeric(id))
{
vehiculo = GetVehicleModelIDFromName(id);
}


return 1;
}
pawn Код:
error 035: argument type mismatch (argument 1)
error 035: argument type mismatch (argument 1)
Definicion de las funciones:
pawn Код:
stock GetVehicleModelIDFromName(vname[])
{
    for(new i = 0; i < 211; i++)
    {
        if ( strfind(VehicleNames[i], vname, true) != -1 )
            return i + 400;
    }
    return -1;
}
IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
Reply
#2

Pero pasa las lineas exactamente en donde te da el error.
Reply
#3

ignorar mensaje. Post equivocado
Reply
#4

pawn Код:
if(!IsNumeric(id))
{
vehiculo = GetVehicleModelIDFromName(id);
}
Reply
#5

Es porque en la funciуn estбs indicando que vname sea un string, y luego en el comando estбs pasando un entero sobre la funciуn. Crea una variable que sea tipo string en el comando y luego usala en el sscanf tambiйn.

pawn Код:
new var[20];

if(sscanf(params,"s[20]",var)) return SendClientMessage(playerid,COLOR_RED,"USO: /v [Nombre del vehiculo o ID");
Y luego llamas a la funciуn con esa variable.

pawn Код:
vehiculo = GetVehicleModelIDFromName(var);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)