27.10.2012, 15:58
Hello. I'm in the process of creating a trunk system for my server (it's already made, I'm actually just making changes).
I'm putting it all into one command so that the player will be prompted to input
At the moment, I have it working so that players can withdraw and deposit money, and weapon parts, however, how would I make it so that they could do:
and not be required to input an item or amount?
Here is the script.
Thank-you in advance for any help given!
I'm putting it all into one command so that the player will be prompted to input
Quote:
/vtrunk [withdraw/deposit] [item] [amount] |
Quote:
/vtrunk balance |
Here is the script.
pawn Код:
CMD:vtrunk(playerid, params[]) {
new
type[12],
amount,
item[12],
vid = GetClosestVehicle(playerid);
if(sscanf(params, "s[12]s[12]d", type, item, amount)) {
SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/vtrunk [deposit/withdraw] [item] [amount]");
return SendClientMessage(playerid, COLOR_GREY, "Items: Money, Parts, Weapon");
}
else {
if(IsPlayerInRangeOfVehicle(playerid, vid, 5.0)) {
if(vehicleVariables[vid][vVehicleGroup] == playerVariables[playerid][pGroup] || IsPlayerVehicleOwner(playerid, vid) || DoesPlayerHaveKey(playerid, vid)) {
if(strcmp(type, "deposit", true) == 0) {
if(strcmp(item, "money", true) == 0) {
if(playerVariables[playerid][pMoney] >= amount) {
if(amount < 1)
return SendClientMessage(playerid, COLOR_GREY, "Invalid amount.");
playerVariables[playerid][pMoney] -= amount;
vehicleVariables[vid][vVehicleMoney] += amount;
format(szMessage, sizeof(szMessage), "* %s opens the trunk of the %s, and stores some money in it.", playerVariables[playerid][pNormalName], VehicleNames[GetVehicleModel(vid) - 400]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
saveVehicle(vid);
}
else SendClientMessage(playerid, COLOR_GREY, "You do not have that much money!");
}
else if(strcmp(item, "parts", true) == 0) {
if(playerVariables[playerid][pMaterials] >= amount) {
if(amount < 1)
return SendClientMessage(playerid, COLOR_GREY, "Invalid amount.");
playerVariables[playerid][pMaterials] -= amount;
vehicleVariables[vid][vVehicleParts] += amount;
format(szMessage, sizeof(szMessage), "* %s opens the trunk of the %s, and stores some parts in it.", playerVariables[playerid][pNormalName], VehicleNames[GetVehicleModel(vid) - 400]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
saveVehicle(vid);
}
else SendClientMessage(playerid, COLOR_GREY, "You do not have that many parts!");
}
}
else if(strcmp(type, "withdraw", true) == 0) {
if(strcmp(item, "money", true) == 0) {
if(vehicleVariables[vid][vVehicleMoney] >= amount) {
if(amount < 1)
return SendClientMessage(playerid, COLOR_GREY, "Invalid amount.");
playerVariables[playerid][pMoney] += amount;
vehicleVariables[vid][vVehicleMoney] -= amount;
format(szMessage, sizeof(szMessage), "* %s opens the trunk of the %s, and takes some money from it.", playerVariables[playerid][pNormalName], VehicleNames[GetVehicleModel(vid) - 400]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
saveVehicle(vid);
}
else SendClientMessage(playerid, COLOR_GREY, "There is not that much money in the trunk!");
}
else if(strcmp(item, "parts", true) == 0) {
if(vehicleVariables[vid][vVehicleParts] >= amount) {
if(amount < 1)
return SendClientMessage(playerid, COLOR_GREY, "Invalid amount.");
playerVariables[playerid][pMaterials] += amount;
vehicleVariables[vid][vVehicleParts] -= amount;
format(szMessage, sizeof(szMessage), "* %s opens the trunk of the %s, and takes some parts from it.", playerVariables[playerid][pNormalName], VehicleNames[GetVehicleModel(vid) - 400]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
saveVehicle(vid);
}
else SendClientMessage(playerid, COLOR_GREY, "There are not that many parts in the trunk!");
}
}
}
else SendClientMessage(playerid, COLOR_GREY, "You do not have a key to this vehicle!");
}
else SendClientMessage(playerid, COLOR_GREY, "You are not near any vehicles!");
}
return 1;
}