26.03.2016, 05:56
How can i make the command like this? /sellmats [id] [type] [amount] [price]. Thank you!
material type should be only "A, B and C" small and capital letters are accepted.
material type should be only "A, B and C" small and capital letters are accepted.
Quote:
CMDellmats(playerid, params[]) { if(Player[playerid][Admin] >= 1) { SendClientMessage(playerid,COLOR_WHITE, "Administrators can't use this command."); return 1; } new string[128]; if(GetPVarInt(playerid, "SellMatsTimer") > 0) { format(string, sizeof(string), "You must wait %d seconds before selling more materials.", GetPVarInt(playerid, "SellMatsTimer")); SendClientMessage(playerid, COLOR_GREY, string); return 1; } new giveplayerid, amount, material[1], price; if(sscanf(params, "udud", giveplayerid, material, amount, price)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellmats [playerid/partofname] [material] [amount] [price]"); if(amount < 1) { SendClientMessage(playerid, COLOR_GREY, "Materials amount must be no lower than 1!"); return 1; } if (material != "a" || material != "A" || material != "b" || material != "B" || material != "c" || material != "C") { SendClientMessage(playerid, COLOR_GREY, "Invalid material class."); return 1; } if(price < 5000) { SendClientMessage(playerid, COLOR_GREY, "Price must be no lower than $5000."); return 1; } if(amount > Player[playerid][MatsA] || amount > Player[playerid][MatsB] || amount > Player[playerid][MatsC]) { SendClientMessage(playerid, COLOR_GREY, "You don't have that many materials!"); return 1; } if(IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { if(ProxDetectorS(8.0, playerid, giveplayerid)) { if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, "You can't sell materials to yourself!"); return 1; } format(string, sizeof(string), "* You offered %s to buy %d class %s materials for $%d.", GetPlayerName(giveplayerid), amount, material, price); SendClientMessage(playerid, COLOR_LIGHTBLUE, string); format(string, sizeof(string), "* %s wants to sell you %d class %s materials for $%d, (type /accept mats) to buy.", GetPlayerName(playerid), amount, material, price); SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string); SetPVarInt(playerid, "SellMatsTimer", 30); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_SELLMATSTIMER); MatsOffer[giveplayerid] = playerid; MatsPrice[giveplayerid] = price; MatsType[giveplayerid] = material; MatsAmount[giveplayerid] = amount; } else { SendClientMessage(playerid, COLOR_GREY, "That player isn't near you."); } } } else { SendClientMessage(playerid, COLOR_GREY, "Invalid player specified."); } return 1; } |