04.05.2013, 02:54
Well I have the command working now but when I do '/atm withdraw/deposit' it will not show the text for the command nor give me the cash...
Код:
CMD:atm(playerid, params[]) { new amount, string[128]; new me[128]; if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(!IsPlayerNearATM(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You're not in range of any ATM at the moment."); if(sscanf(params, "s[32]", params)) { SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /atm [withdraw/balance/deposit] [amount]"); return 1; } if(!strcmp(params, "withdraw", true)) { if(sscanf(params, "s[32]i", params, amount)) return SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /atm [withdraw/balance/deposit] [amount]"); if(amount > PlayerInfo[playerid][pBank]) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much money in your bank account."); if(amount <= 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid money amount."); if(amount > 50000) return SendClientMessage(playerid, COLOR_GREY, "You can't deposit more than $50,000 in an ATM."); if(ATMTime[playerid] > 0) { format(string, sizeof(string), "You need to wait %d more seconds before using the ATM again.", ATMTime[playerid]); SendClientMessage(playerid, COLOR_GREY, string); return 1; } PlayerInfo[playerid][pBank] -= amount; GiveDodMoney(playerid, amount); ATMTime[playerid] = 40; format(me, sizeof(me), "** %s presses a button on the ATM machine and waits for a response.", RPN(playerid)); SendNearbyMessage(playerid, 5, me, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE); SendClientMessage(playerid, COLOR_WHITE, "_________________________________"); format(string, sizeof(string), "You have successfully withdrawn $%d from your Bank account.", amount); SendClientMessage(playerid, COLOR_LIGHTBLUE, string); format(string, sizeof(string), "You have a total of $%d remaining in your Bank account.", PlayerInfo[playerid][pBank]); SendClientMessage(playerid, COLOR_LIGHTBLUE, string); SetTimerEx("ATMTimer", 1000, false, "i", playerid); return 1; } else if(!strcmp(params, "deposit", true)) { if(sscanf(params, "s[32]i", params, amount)) return SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /atm [withdraw/balance/deposit] [amount]"); if(amount > PlayerInfo[playerid][pMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much money on you."); if(amount <= 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid money amount."); if(amount > 50000) return SendClientMessage(playerid, COLOR_GREY, "You can't withdraw more than $50,000 from the ATM."); if(ATMTime[playerid] > 0) { format(string, sizeof(string), "You need to wait %d more seconds before using the ATM again.", ATMTime[playerid]); SendClientMessage(playerid, COLOR_GREY, string); return 1; } PlayerInfo[playerid][pBank] += amount; GiveDodMoney(playerid, -amount); ATMTime[playerid] = 40; format(me, sizeof(me), "** %s presses a button on the ATM machine and waits for a response.", RPN(playerid)); SendNearbyMessage(playerid, 5, me, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE); SendClientMessage(playerid, COLOR_WHITE, "_________________________________"); format(string, sizeof(string), "You have successfully deposit $%d into your Bank account.", amount); SendClientMessage(playerid, COLOR_LIGHTBLUE, string); format(string, sizeof(string), "You have a total of $%d in your Bank account now.", PlayerInfo[playerid][pBank]); SendClientMessage(playerid, COLOR_LIGHTBLUE, string); SetTimerEx("ATMTimer", 1000, false, "i", playerid); return 1; } else if(!strcmp(params, "balance", true)) { format(me, sizeof(me), "** %s presses a button on the ATM machine and waits for a response.", RPN(playerid)); SendNearbyMessage(playerid, 5, me, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE); SendClientMessage(playerid, COLOR_WHITE, "_________________________________"); format(string, sizeof(string), "Your current Bank-account balance is: $%d.", PlayerInfo[playerid][pBank]); SendClientMessage(playerid, COLOR_LIGHTBLUE, string); return 1; } return 1; }