SA-MP Forums Archive
Strval(inputtext) -- Need help. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Strval(inputtext) -- Need help. (/showthread.php?tid=408292)



Strval(inputtext) -- Need help. - Bobman - 17.01.2013

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


Re: Strval(inputtext) -- Need help. - mineralo - 17.01.2013

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 $");


Re: Strval(inputtext) -- Need help. - Bobman - 17.01.2013

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


Re: Strval(inputtext) -- Need help. - RedCrossER - 17.01.2013

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



Re: Strval(inputtext) -- Need help. - Bobman - 17.01.2013

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


Re: Strval(inputtext) -- Need help. - azzerking - 17.01.2013

new money = GetPlayerCash(playerid);

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


Re: Strval(inputtext) -- Need help. - Bobman - 17.01.2013

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.");
				}
            }
        }
	}



Re: Strval(inputtext) -- Need help. - Sasino97 - 17.01.2013

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


Re: Strval(inputtext) -- Need help. - Chenko - 17.01.2013

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.");
                }
            }
        }
    } 



Re: Strval(inputtext) -- Need help. - Bobman - 18.01.2013

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++