number of arg. does not match definition
#1

Getting this error on this CMD:

pawn Код:
CMD:garagename(playerid, params[])
{
    new id = GetClosestGarage(playerid);

    if(id == -1) return SCM(playerid, COLOR_ERROR, "» There are no garages near you.");

    //if(GarageData[id][garageOwnerID] != playerid) return SCM(playerid, COLOR_ERROR, "» This garage not yours."); //To fix

    if(!GarageData[id][garageOwned]) return SCM(playerid, COLOR_ERROR, "» This garage is unowned.");

    new name;

    if(name < 4 || name > MAX_GARAGE_NAME) return SCM(playerid, COLOR_ERROR, "» Name should be between 4 and 40 chars.");

    format(GarageData[id][garageName], MAX_GARAGE_NAME, name);
   
    new Query[150];
    format(Query,sizeof(Query), "UPDATE garages SET garageName = '%e' WHERE ID = '%d'", name, id);
    db_query(GarageDB, Query);

    UpdateGarageLabel(id);

    SCM(playerid, COLOR_YELLOW, "» [GARAGE] You have changed your garage name successfully!");
    SCMEX(playerid, COLOR_YELLOW, "» [GARAGE] New name: %s", name);

    GameTextForPlayer(playerid, "~w~Garage ~g~name changed~w~!", 3000, 3);
    return 1;
}
Error line:

pawn Код:
format(GarageData[id][garageName], MAX_GARAGE_NAME, name);
#define MAX_GARAGE_NAME 40
Reply
#2

name is not an array.

Furthermore you need to use strlen(name) in order to check its length.

And it's empty since you don't assign it any value.

You could simply use params for input since there's no point in copying it into name first, and then copy it again into your array.
Use isnull(params) to check whether its empty or not.
Reply
#3

Make it an array and use strcat in order to copy strings.
Reply
#4

Any example?
Reply
#5

Here you go:

PHP код:
CMD:garagename(playeridparams[])
{
    new 
id GetClosestGarage(playerid);
    if(
id == -1) return SCM(playeridCOLOR_ERROR"» There are no garages near you.");
    
//if(GarageData[id][garageOwnerID] != playerid) return SCM(playerid, COLOR_ERROR, "» This garage not yours."); //To fix
    
if(!GarageData[id][garageOwned]) return SCM(playeridCOLOR_ERROR"» This garage is unowned.");
    new 
len strlen(params);
    if(
len || len MAX_GARAGE_NAME) return SCM(playeridCOLOR_ERROR"» Name should be between 4 and 40 chars.");
    
format(GarageData[id][garageName], MAX_GARAGE_NAMEparams);
    
    new 
Query[150];
    
format(Query,sizeof(Query), "UPDATE garages SET garageName = '%e' WHERE ID = '%d'"paramsid);
    
db_query(GarageDBQuery);
    
UpdateGarageLabel(id);
    
SCM(playeridCOLOR_YELLOW"» [GARAGE] You have changed your garage name successfully!");
    
SCMEX(playeridCOLOR_YELLOW"» [GARAGE] New name: %s"params);
    
GameTextForPlayer(playerid"~w~Garage ~g~name changed~w~!"30003);
    return 
1;

Reply
#6

Oh thank you. Gonna test later.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)