/vtrunk [withdraw/deposit] [item] [amount] |
/vtrunk balance |
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;
}
if(sscanf(params, "s[12]S[12]D", type, item, amount))