30.11.2012, 18:17
Hello, I have 2 ways of making the commands but I would want to know which one is the best. They both work.
Command 1 Example:
Command 2 Example:
Command 1 Example:
pawn Код:
CMD:fix(playerid, params[])
{
new target, string[80];
if(sscanf(params, "u", target)) target = playerid;
if (!IsPlayerConnected(target)) return SendClientMessageFormatted(playerid, COLOR_DARKRED, "%s is not connected to the server.", params);
if(!IsPlayerInAnyVehicle(target))
{
if(target != playerid)
{
SendClientMessageFormatted(playerid, COLOR_DARKRED, "%s(%d) is not in a vehicle.",Name(target),target);
}
else
{
SendClientMessage(playerid, COLOR_DARKRED, "You must be in a vehicle to use this command.");
}
return 1;
}
if(IsPlayerInAnyVehicle(target))
{
new vid;
vid = GetPlayerVehicleID(target);
RepairVehicle(vid);
if(target != playerid)
{
format(string, 128, "You repaired %s(%d)'s vehicle.", Name(target), target);
SendClientMessage(playerid, COLOR_ADMIN, string);
}
else
{
SendClientMessage(playerid, COLOR_ADMIN, "Your vehicle has been fixed.");
}
}
return 1;
}
Command 2 Example:
pawn Код:
CMD:fix(playerid, params[])
{
new target, string[80], vid;
if(sscanf(params, "u", target))
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_DARKRED, "You must be in a vehicle to use this command.");
SendClientMessage(playerid, COLOR_ADMIN, "Your vehicle has been fixed.");
RepairVehicle(vid);
}
else
{
if (!IsPlayerConnected(target)) return SendClientMessageFormatted(playerid, COLOR_DARKRED, "%s is not connected to the server.", params);
if(!IsPlayerInAnyVehicle(target)) return SendClientMessageFormatted(playerid, COLOR_DARKRED, "%s(%d) is not in a vehicle.",Name(target),target);
vid = GetPlayerVehicleID(playerid);
format(string, 128, "You repaired %s(%d)'s vehicle.", Name(target), target);
SendClientMessage(playerid, COLOR_ADMIN, string);
RepairVehicle(vid);
}
return 1;
}