number of arg. does not match definition -
SymonClash - 27.02.2019
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
Re: number of arg. does not match definition -
NaS - 27.02.2019
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.
Re: number of arg. does not match definition -
TheToretto - 27.02.2019
Make it an array and use strcat in order to copy strings.
Re: number of arg. does not match definition -
SymonClash - 27.02.2019
Any example?
Re: number of arg. does not match definition -
Kaliber - 27.02.2019
Here you go:
PHP код:
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 len = strlen(params);
if(len < 4 || len > MAX_GARAGE_NAME) return SCM(playerid, COLOR_ERROR, "» Name should be between 4 and 40 chars.");
format(GarageData[id][garageName], MAX_GARAGE_NAME, params);
new Query[150];
format(Query,sizeof(Query), "UPDATE garages SET garageName = '%e' WHERE ID = '%d'", params, 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", params);
GameTextForPlayer(playerid, "~w~Garage ~g~name changed~w~!", 3000, 3);
return 1;
}
Re: number of arg. does not match definition -
SymonClash - 27.02.2019
Oh thank you. Gonna test later.