06.03.2013, 23:50
pawn Код:
FindVehicleByNameID(const vname[])
{
if('4' <= vname[0] <= '6') return INVALID_VEHICLE_ID;
for(new i,LEN = strlen(vname); i != sizeof(VehicleNames); i++)
if(!strcmp(VehicleNames[i],vname,true,LEN))
return i + 400;
return INVALID_VEHICLE_ID;
}
CMD:v(playerid, params[])
{
new
toid,
carid[20],
color1,
color2;
if(pInfo[playerid][Admin] < 2) SendClientMessage(playerid, COLOR_LIGHTBLUE, "You don't have access to this command.");
else if(sscanf(params, "is[20]ii", toid, carid, color1, color2)) SendClientMessage(playerid, -1, "USAGE: /v [playerid] [carid / part of carname] [color1] [color2]");
else if(!IsPlayerConnected(toid)) SendClientMessage(playerid, COLOR_LIGHTPINK, "ERROR: That ID is not a valid player!");
else{
new vID = FindVehicleByNameID(carid);
if(vID == INVALID_VEHICLE_ID)
{
vID = strval(carid);
if(!(399 < vID < 612)) return SendClientMessage(playerid, COLOR_LIGHTPINK, "ERROR: That ID is not a valid car id!");
}
new
Float: curX,
Float: curY,
Float: curZ,
Float: curR;
GetPlayerPos(toid, curX, curY, curZ);
GetPlayerFacingAngle(toid, curR);
CreateVehicle(vID, curX+1, curY+1, curZ, curR, color1, color2, -1);
new
Message[128],
SenderName[MAX_PLAYER_NAME + 1],
RecieverName[MAX_PLAYER_NAME + 1];
GetPlayerName(playerid, SenderName, MAX_PLAYER_NAME);
GetPlayerName(toid, RecieverName, MAX_PLAYER_NAME);
format(Message, sizeof(Message), "Car '%s' sent to %s.", GetVehicleName(vID), RecieverName);
SendClientMessage(playerid, COLOR_LIGHTPINK, Message);
format(Message, sizeof(Message), "%s has just spawned you a car (%s).", SenderName, GetVehicleName(vID));
SendClientMessage(toid, COLOR_LIGHTPINK, Message);
format(Message, sizeof(Message), "%s has sent a(n) %s to %s!", SenderName, GetVehicleName(vID), RecieverName);
SendClientMessageToAllButTwo(playerid, toid, COLOR_LIGHTPINK, Message);
}
return 1;
}