30.01.2014, 17:26
PHP код:
CMD:sellmycar(playerid, params[])
{
new string[128], playerb;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsPlayerNearPlayer(playerid, playerb, 2)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
if(!PlayerInfo[playerid][pVeh] && !PlayerInfo[playerid][pVVeh] && !PlayerInfo[playerid][pVVVeh]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a vehicle.");
if(sscanf(params, "uis[64]", playerb, carslot, carprice)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /sellmycar [playerid] [slot] [price]");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(playerid == playerb) return SendClientMessage(playerid, COLOR_GREY, "You can't sell your car to yourself.");
if(carprice == 0) return SendClientMessage(playerid, COLOR_GREY, "You cant sell your car for 0$.");
if(carslot< 1 || carslot > 4) return SendClientMessage(playerid, COLOR_WHITE, "There are only 4 car slots");
switch(carslot)
{
case 1:
{
if(PlayerInfo[playerid][vModel] == 0) return SendClientMessage(playerid, COLOR_GREY, "You dont have vehicle in this slot.");
new Float:vx, Float:vy, Float:vz;
GetVehiclePos(PlayerInfo[playerid][pVeh], vx, vy, vz);
if(IsPlayerInRangeOfPoint(playerid, 4, vx, vy, vz)) return SendClientMessage(playerid, COLOR_GREY, "You are not near your car.");
format(string, sizeof(string), " You have offered your %s to %s for $%d.",RVN(PlayerInfo[playerid][vModel]), RPN(playerb), carprice);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "%s has offered you his/her %s for $%d. (/accept car) (/cancel car)",RPN(playerid), RVN(PlayerInfo[playerid][vModel]), carprice);
SendClientMessage(playerb, COLOR_YELLOW, string);
CarBy[playerb] = playerid;
Car[playerb] = 0;
offeredcar[playerb] = 1;
}
}
return 1;
}