23.08.2011, 03:24
pawn Code:
command(setcargroup, playerid, params[])
{
new id, string[128];
if(Player[playerid][AdminLevel] < 4/* || Playerrank[playerid] < x*/) return SendClientMessage(playerid, WHITE, "Error.");
if(sscanf(params, "d", id)) return SendClientMessage(playerid, WHITE, "SYNTAX: /setcargroup [Group ID] [Group Rank]");//You only extract to 1 variable??
if(IsPlayerInAnyVehicle(playerid))
{
if(0 <= id < MAX_GROUPS)
{
if(GetVehicleFileID(GetPlayerVehicleID(playerid)) == 0)
{
SendClientMessage(playerid, WHITE, "That doesn't seem to be a saved vehicle.");
}
else
{
if(id == 0)
{
SendClientMessage(playerid, WHITE, "You have unlocked this vehicle.");
Vehicles[GetVehicleFileID(GetPlayerVehicleID(playerid))][CarGroup] = 0;
}
else
{
Vehicles[GetVehicleFileID(GetPlayerVehicleID(playerid))][CarGroup] = id;
format(string, sizeof(string), "You have locked this vehicle to Group %s.", Groups[id][GroupName]);
SendClientMessage(playerid, WHITE, string);
SaveExistingVehicle(GetPlayerVehicleID(playerid));
}
}
}
else
{
format(string, sizeof(string), "Invalid Group ID (groups vary from ID 1 to ID %d).", MAX_GROUPS);
SendClientMessage(playerid, WHITE, string);
}
}
else
{
SendClientMessage(playerid, WHITE, "You're not in a valid vehicle.");
}
return 1;
}