14.07.2012, 03:17
hey guys iv been trying to do a /repair command for the mechanic. I cant do it though and need someone to take a look at what im doing wrong please!
I want it so The mechanic will only be able to offer a repair if they are in the same vehicle as the person they are offering and if they arent in a vehicle then it wont do anything and same as player. Im getting confuzed :/
Код:
CMD:repair(playerid, params[]) { new string[128], playerb, price; if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(PlayerInfo[playerid][pJob] != JOB_MECHANIC && PlayerInfo[playerid][pVIPJob] != JOB_MECHANIC) return SendClientMessage(playerid, COLOR_GREY, "You are not a mechanic."); if(sscanf(params, "uii", playerb, price)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /repair [playerid] [price]"); if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id."); if(playerid == playerb) return SendClientMessage(playerid, COLOR_GREY, "You can't offer a repair to yourself."); if(IsPlayerNearPlayer(playerid, playerb, 2 && IsPlayerInAnyVehicle(playerb) && IsPlayerInAnyVehicle(playerid))) { //if(!IsPlayerInAnyVehicle(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Player is not in a vehicle."); //if(!IsPlayerInAnyVehicle(playerid) && (vehicleid == playerb)) return SendClientMessage(playerid, COLOR_GREY, "You are not in the same vehicle."); //if(!IsPlayerNearPlayer(playerid, playerb, 2)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player."); if(SellRepairTo[playerid] == playerb) return SendClientMessage(playerid, COLOR_GREY, "You have already offered that player to repair their vehicle."); if(price <= 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid repair price."); // Clearing old buyer foreach(Player, i) { if(IsPlayerLoggedIn(i)) { if(SellRepairTo[playerid] == i && BuyRepairFrom[i] == playerid) { BuyRepairFrom[i] = -1; BuyRepairPrice[i] = 0; BeenOfferedRepair[i] = 0; } } } // New buyer SellRepairTo[playerid] = playerb; BuyRepairFrom[playerb] = playerid; BuyRepairPrice[playerb] = price; BeenOfferedRepair[playerb] = 1; format(string, sizeof(string), " You have offered %s to repair their vehicle for $%d.", RPN(playerb), price); SendClientMessage(playerid, COLOR_LIGHTBLUE, string); format(string, sizeof(string), " %s has offered to repair your vehicle for $%d. (/accept repair) (/cancel repair)", RPN(playerid), price); SendClientMessage(playerb, COLOR_LIGHTBLUE, string); return 1; } else { SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player."); } }