CMD:v(playerid, params[])
{
if(!strcmp(params, "color", true))
{
new c[2];
// if(pInfo[playerid][VipLevel] == 0) return ErrorMessages(playerid, 4);
if(strcmp(GetPlayerName(playerid), vInfo[id][vowner], true)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]"COL_WHITE" This is not your vehicle");
if(sscanf(params,"sii", params, c[0], c[1])) return SendClientMessage(playerid, COLOR_ORANGE,"Usage:"COL_WHITE" /v color [COLOR 1] [COLOR 2]");
else if(c[0] > 255) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]"COL_WHITE" Cannot go above 255!");
else if(c[1] > 255) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]"COL_WHITE" Cannot go above 255!");
if(id != 0)
{
vInfo[id][vcolor1] = c[0];
vInfo[id][vcolor2] = c[1];
ChangeVehicleColor(vehicleid, c[0], c[1]);
format(fquery,sizeof(fquery), "UPDATE `vehicles` SET Color1 = '%d', Color2 = '%d' WHERE ID = '%d'", DB_Escape(vInfo[id][vcolor1]), DB_Escape(vInfo[id][vcolor2]), id);
db_free_result(db_query(Database, fquery));
format(fquery, sizeof(fquery), "[VEHICLE]"COL_WHITE" You've changed the primary color %i and secondary %i", c[0], c[1]);
SendClientMessage(playerid, COLOR_SERVER, fquery);
}
else return ErrorMessages(playerid, 13);
}
return 1;
}
// if player inputs only the name of the option, return them the usage
if(!strcmp(params, "color", true)) return SendClientMessage(playerid, COLOR_ORANGE,"Usage:"COL_WHITE" /v color [COLOR 1] [COLOR 2]");
// if player inputs "/v color " may or may not have parameters following, sscanf will react accordingly
// 6 is the length of the option + a space at the end
if (!strcmp(params, "color ", true, 6))
{
new c[2];
if(sscanf(params[6], "ii", c[0], c[1])) return SendClientMessage(playerid, COLOR_ORANGE,"Usage:"COL_WHITE" /v color [COLOR 1] [COLOR 2]");
// code..
}
What your commands checks is "/v color". Since you have parameters for "color" option, you'll need to use 4th parameter (length) in strcmp function.
pawn Код:
Only strings need to be escaped and there's no need of DB_Escape anymore - there is now a %q specifier for format function that does the job for you. |
format(hInfo[IID][hName], MAX_PLAYER_NAME, "%s", inputtext);
format(fquery, sizeof(fquery), "UPDATE `Houses` SET Title = '%q' WHERE `ID` = '%d'", hInfo[IID][hName], IID);
db_free_result(db_query(Database, fquery));
CMD:v(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_ORANGE,"Usage:"COL_WHITE" /v [BUY/SELL/LOCK/PARK/RESPAWN]");
// if player inputs only the name of the option, return them the usage
if(!strcmp(params, "color", true)) return SendClientMessage(playerid, COLOR_ORANGE,"Usage:"COL_WHITE" /v color [COLOR 1] [COLOR 2]");
// if player inputs "/v color " may or may not have parameters following, sscanf will react accordingly
// 6 is the length of the option + a space at the end
if (!strcmp(params, "color ", true, 6))
{
new c[2];
if(!IsPlayerInAnyVehicle(playerid)) return ErrorMessages(playerid, 11);
// if(pInfo[playerid][VipLevel] == 0) return ErrorMessages(playerid, 4);
if(strcmp(GetPlayerName(playerid), vInfo[id][vowner], true)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]"COL_WHITE" This is not your vehicle");
if(sscanf(params[6], "ii", c[0], c[1])) return SendClientMessage(playerid, COLOR_ORANGE,"Usage:"COL_WHITE" /v color [COLOR 1] [COLOR 2]");
else if(c[0] > 255) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]"COL_WHITE" Cannot go above 255!");
else if(c[1] > 255) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]"COL_WHITE" Cannot go above 255!");
if(id != 0)
{
vInfo[id][vcolor1] = c[0];
vInfo[id][vcolor2] = c[1];
ChangeVehicleColor(vehicleid, c[0], c[1]);
format(fquery,sizeof(fquery), "UPDATE `vehicles` SET Color1 = '%d', Color2 = '%d' WHERE ID = '%d'", vInfo[id][vcolor1], vInfo[id][vcolor2], id);
db_free_result(db_query(Database, fquery));
format(fquery, sizeof(fquery), "[VEHICLE]"COL_WHITE" You've changed the primary color %i and secondary %i", c[0], c[1]);
SendClientMessage(playerid, COLOR_SERVER, fquery);
}
else return ErrorMessages(playerid, 13);
}
if(!strcmp(params, "respawn", true, 7))
{
new str[50], STR[512], idd = 0;
for(new i; i < MAX_BUY_V; i++)
{
if(i == 0) continue;
if(!strcmp(GetPlayerName(playerid), vInfo[i][vowner], false))
{
format(str, sizeof(str),"%s \n", GetVehicleNameByModel(vInfo[i][vmodel]));
strcat(STR, str);
RespawnVOwner[playerid][idd] = vInfo[i][NewID];
idd++;
}
}
if(strlen(STR) < 2) return SendClientMessage(playerid, COLOR_RED, "[ERROR]"COL_WHITE" You don't have any vehicle");
return ShowPlayerDialog(playerid, CAR_LIST, DIALOG_STYLE_LIST,""COL_BLUE"Cars list", STR, "Select", "Close");
}
}
return 1;
stock GetVehicleNameByModel(modelid)
{
if(400<modelid || modelid>611)
{
modelid=612;
}
return VehicleNames[(modelid-400)];
}
It is most likely because you try to return the text stored in VehicleNames array directly. I knew it could return corrupted text but never expected a run time error.
Create a local string and store the name there, then return that local string instead. |