Once more /atm help -
MichaelWharton101 - 04.05.2013
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;
}
Re: Once more /atm help -
MP2 - 04.05.2013
Debug.
Re: Once more /atm help -
MichaelWharton101 - 04.05.2013
What do you mean?
Re: Once more /atm help -
JaKe Elite - 04.05.2013
Debug the code. Like putting some print"[DEBUG]"); in the code...
Or putting some SendClientMessage. inside the code
Re: Once more /atm help -
MichaelWharton101 - 04.05.2013
Hmm... Could you explain this to me? I have never done a debug thing like you are talking about.
Re: Once more /atm help -
MichaelWharton101 - 04.05.2013
Anyone got a idea how to fix this?
Re: Once more /atm help -
caki - 04.05.2013
pawn Код:
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;
}
First seperate this into three commands not all in one. Then check out if it works for each one. After that add one by one into main ''atm'' command and test after it. I guess you missed something on the way
Re: Once more /atm help -
caki - 04.05.2013
Ok so now use this below and test each command and try to see what is working and what is broken. Dont make it into one ''atm'' command until you are sure that all is working properly
pawn Код:
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;
}
}
CMD:withdraw(playerid, params[])
{
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;
}
CMD:deposit(playerid, params[])
{
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;
}
CMD:balance(playerid, params[])
{
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;
}