Strval(inputtext) -- Need help.
#1

Hi,

I've got a deposit system that deposits my money by a dialog. However, I am able to deposit more money than I really have. Let's say that I have got 100$ but I am able to deposit more than 100$, if I deposit 1000$ my money sets to -900$ and my bank gains more money. Any help ?

http://pastebin.com/NeJesPp0
Reply
#2

before to conver check if its numer with function IsNumber(string[]) and after use strval, if you have same problem then just put an condition like
new money=strval(inputtext);
if(money <0 || money >100) return SendClientMessage(playerid,-1,"You can deposite not above 100 $");
Reply
#3

The thing is that when I deposit money it won't stop at 0$, it keeps depositing money to negative side. So, if I've got more than 0 money I can deposit any amount I want to and it'll set my money to negative. That's the problem
Reply
#4

pawn Code:
new dmoney = strval(inputtext);
 
if(dmoney < 0) return SendClientMessage(playerid,-1,"You cannot deposit Less Than 0$");
Reply
#5

did not work, i still can deposit my cash to negative
Reply
#6

new money = GetPlayerCash(playerid);

if(money < 0) return SendClientMessage(playerid,-1,"You cannot deposit Less Than 0$");
Reply
#7

Here

Code:
if(dialogid == DIALOG_DEPOSIT)
    {
        if(!response) return 1;
        if(response)
        {
            if(!strval(inputtext))
            {
                SendClientMessage(playerid, GREY, "You have entered an Invalid amount of money.");
			}
            else
		    {
            	if(PlayerStat[playerid][Money] <= strval(inputtext))
				{
					   new str[128];
					   format(str, sizeof(str), "You have successfully deposit %d in your locker.", strval(inputtext));
                       SendClientMessage(playerid, GREY, str);
                       PlayerStat[playerid][LockerMoney] += strval(inputtext);
                       GiveMoney(playerid, -strval(inputtext));
                       format(str, sizeof(str), "* %s opens their locker and puts %d in it.", GetICName(playerid), strval(inputtext));
                       SendNearByMessage(playerid, ACTION_COLOR, str, 5);
                }
                else
				{
				    SendClientMessage(playerid, GREY, "You don't have that much.");
				}
            }
        }
	}
Reply
#8

Quote:
Originally Posted by Bobman
View Post
if(PlayerStat[playerid][Money] <= strval(inputtext))
Maybe
pawn Code:
if(strval(inputtext) <= PlayerStat[playerid][Money])
You have to check if the player has entered a value that is smaller than his money, not the opposite lol
Reply
#9

Try this.


PHP Code:
if(dialogid == DIALOG_DEPOSIT)
    {
        if(!
response) return 1;
        if(
response)
        {
            if(!
strval(inputtext))
            {
                
SendClientMessage(playeridGREY"You have entered an Invalid amount of money.");
            }
            else
            {
                if(
strval(inputtext) < 0)
                    return 
SendClientMessage(playerid, -1"You can't deposit a negative amount."); 
                
                if(
PlayerStat[playerid][Money] >= strval(inputtext))
                {
                       new 
str[128];
                       
format(strsizeof(str), "You have successfully deposit %d in your locker."strval(inputtext));
                       
SendClientMessage(playeridGREYstr);
                       
PlayerStat[playerid][LockerMoney] += strval(inputtext);
                       
GiveMoney(playerid, -strval(inputtext));
                       
format(strsizeof(str), "* %s opens their locker and puts %d in it."GetICName(playerid), strval(inputtext));
                       
SendNearByMessage(playeridACTION_COLORstr5);
                }
                else
                {
                    
SendClientMessage(playeridGREY"You don't have that much.");
                }
            }
        }
    } 
Reply
#10

Quote:
Originally Posted by Chenko
View Post
Try this.


PHP Code:
if(dialogid == DIALOG_DEPOSIT)
    {
        if(!
response) return 1;
        if(
response)
        {
            if(!
strval(inputtext))
            {
                
SendClientMessage(playeridGREY"You have entered an Invalid amount of money.");
            }
            else
            {
                if(
strval(inputtext) < 0)
                    return 
SendClientMessage(playerid, -1"You can't deposit a negative amount."); 
                
                if(
PlayerStat[playerid][Money] >= strval(inputtext))
                {
                       new 
str[128];
                       
format(strsizeof(str), "You have successfully deposit %d in your locker."strval(inputtext));
                       
SendClientMessage(playeridGREYstr);
                       
PlayerStat[playerid][LockerMoney] += strval(inputtext);
                       
GiveMoney(playerid, -strval(inputtext));
                       
format(strsizeof(str), "* %s opens their locker and puts %d in it."GetICName(playerid), strval(inputtext));
                       
SendNearByMessage(playeridACTION_COLORstr5);
                }
                else
                {
                    
SendClientMessage(playeridGREY"You don't have that much.");
                }
            }
        }
    } 
Hey! It works fine! Thank you! Rep++
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)