I'm having troubles with the command /setlicenseplate. I'm used to ZCMD and strcmp is new to me when it comes to making commands. Anyways, it always returns a message that car slot 1-3 only should be entered. Can anyone help me out please?
pawn Код:
if(strcmp(cmd, "/setlicenseplate", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 4 && IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "[ERROR:] Either you're not an administrator, or you don't have the privileges to use this command.");
new id;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_USAGE, "[USAGE:] /setlicenseplate [playerid] [vehicleslot] [licenseplate]");
return 1;
}
id = strval(tmp);if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_ORANGE, "[ERROR:] That player is not connected.");
new carslot;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_USAGE, "[USAGE:] /setlicenseplate [playerid] [vehicleslot] [licenseplate]");
return 1;
}
if(carslot < 1 || carslot > 3) return SendClientMessage(playerid, COLOR_ORANGE, "[ERROR:] Vehicle slot 1-3 only.");
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_USAGE, "[USAGE:] /setlicenseplate [playerid] [vehicleslot] [licenseplate]");
return 1;
}
if(carslot == 1)
{
format(PlayerInfo[id][pVeh1License], 12, "%s", result);
}
if(carslot == 2)
{
format(PlayerInfo[id][pVeh2License], 12, "%s", result);
}
if(carslot == 3)
{
format(PlayerInfo[id][pVeh3License], 12, "%s", result);
}
new str[128];
format(str, 128, "[ADMCMD:] You have changed the license plate of %s (%i) in car slot %i to %s", GetPlayerNameEx(id), id, carslot, result);
SendClientMessage(playerid, COLOR_ADMIN, str);
format(str, 128, "[ADMCMD:] Administrator %s (%i) changed your car slot %i's license plate to %s", GetPlayerNameEx(playerid), playerid, carslot, result);
SendClientMessage(id, COLOR_ADMIN, str);
return 1;
}
Just use ZCMD, easier to understand, faster to procces and most importantly shorter to write.