So I tried to make a command with the integer being optional, for example this:
First part works if you're in a vehicle but if you enter something after /repair, it sends the message but returns it as vehicle id 0. I'm assuming it's because I've got nothing set to define it?
I tried adding:
But it didn't work. I've never really done shit like this before so helps appreciated.
PHP Code:
CMD:repair(playerid, params[])
{
new carid, mycar, string[128];
mycar = GetPlayerVehicleID(playerid);
if(isnull(params))
{
if(IsPlayerInAnyVehicle(playerid))
{
RepairVehicle(mycar);
format(string, sizeof(string), "AdmWarn[%d]: %s repaired vehicle id %d.", Player[playerid][AdminLevel], GetOOCName(playerid), mycar);
SendToAdmins(YELLOW, string, 0);
}
}
else
{
format(string, sizeof(string), "AdmWarn[%d]: %s repaired vehicle id %d.", Player[playerid][AdminLevel], GetOOCName(playerid), carid);
SendToAdmins(YELLOW, string, 0);
RepairVehicle(carid);
}
return 1;
}
I tried adding:
PHP Code:
if(sscanf(params, "D(integer)", carid)) return SendClientMessage(playerid, ADM, "SERVER: /repair [vehicleid] OR be in your car");