14.01.2015, 15:28
'params' has no given length or size, as it is determined at the moment the player uses the command. What you can do instead is:
Full code:
pawn Код:
format(PlayerInfo[playerid][pVehPlate], 32, "%s", params);
pawn Код:
CMD:plateregister(playerid, params[])
{
if(PlayerInfo[playerid][pLevel] < 7) return SendClientMessage(playerid, COLOR_GREY, "You are not a level 7 player ");
if(!IsPlayerInRangeOfPoint(playerid, 3, 366.4916, 158.6417, 1008.3828)) return SendClientMessage(playerid, COLOR_GREY, "You aren't near Vehicle Registration Place.");
new vslot[6];
if(sscanf(params, "s[6]", vslot))
{
SendClientMessage(playerid, COLOR_ALIREZA, "USAGE: /vehicleregister [VehSlot]");
return SendClientMessage(playerid, COLOR_ALIREZA, "Vehicle Slots: one(for all players) two(vip) three(bvip) ");
}
if(!strcmp(vslot, "one", true))
{
new platetext[32];
if(sscanf(params, "{s[6]}s[32]", platetext)) return SendClientMessage(playerid, COLOR_ALIREZA, "USAGE: /vehicleregister one [PlateText]");
new Float:carpos_x, Float:carpos_y, Float:carpos_z;
SetVehicleNumberPlate(PlayerInfo[playerid][pVeh], platetext);
GetVehiclePos(PlayerInfo[playerid][pVeh], carpos_x, carpos_y, carpos_z);
SetVehicleToRespawn(PlayerInfo[playerid][pVeh]);
SetVehiclePos(PlayerInfo[playerid][pVeh], carpos_x, carpos_y, carpos_z);
format(PlayerInfo[playerid][pVehPlate], 32, "%s", platetext);
new string[65];
format(string, sizeof(string), "* changed plate to %s(slot 1).", platetext);
SendClientMessage(playerid, COLOR_GREY, string);
}
else if(!strcmp(vslot, "two", true))
{
new platetext[32];
if(sscanf(params, "{s[6]}s[32]", platetext)) return SendClientMessage(playerid, COLOR_ALIREZA, "USAGE: /vehicleregister two [PlateText]");
new Float:carpos_x, Float:carpos_y, Float:carpos_z;
SetVehicleNumberPlate(PlayerInfo[playerid][pVVeh], platetext);
GetVehiclePos(PlayerInfo[playerid][pVVeh], carpos_x, carpos_y, carpos_z);
SetVehicleToRespawn(PlayerInfo[playerid][pVVeh]);
SetVehiclePos(PlayerInfo[playerid][pVVeh], carpos_x, carpos_y, carpos_z);
format(PlayerInfo[playerid][pVVehPlate], 32, "%s", platetext);
new string[65];
format(string, sizeof(string), "* changed plate to %s(slot 2).", platetext);
SendClientMessage(playerid, COLOR_GREY, string);
}
else if(!strcmp(vslot, "three", true))
{
new platetext[32];
if(sscanf(params, "{s[6]}s[32]", platetext)) return SendClientMessage(playerid, COLOR_ALIREZA, "USAGE: /vehicleregister three [PlateText]");
new Float:carpos_x, Float:carpos_y, Float:carpos_z;
SetVehicleNumberPlate(PlayerInfo[playerid][pBVeh], platetext);
GetVehiclePos(PlayerInfo[playerid][pBVeh], carpos_x, carpos_y, carpos_z);
SetVehicleToRespawn(PlayerInfo[playerid][pBVeh]);
SetVehiclePos(PlayerInfo[playerid][pBVeh], carpos_x, carpos_y, carpos_z);
format(PlayerInfo[playerid][pBVehPlate], 32, "%s", platetext);
new string[65];
format(string, sizeof(string), "* changed plate to %s (Slot 3).", platetext);
SendClientMessage(playerid, COLOR_GREY, string);
}
else
{
SendClientMessage(playerid, COLOR_ALIREZA, "USAGE: /vehicleregister [VehSlot]");
SendClientMessage(playerid, COLOR_ALIREZA, "Vehicle Slots: one(for all players) two(vip) three(bvip) ");
}
return 1;
}