How to add a SendMoney command MAX Money Limit
#1

Hey guys.

I dont know how to add a money limit, example

send money

Example:
/sendmoney

*Please enter the ID of the Player You want to Send*
Putting ID: 1 (Example)

*Please choose the amount of the money you want to send*

Puttings Amount: 50000

*Success. Your Money successfully transfered to the Specified Player ID*


This is an EXAMPLE.

You know, when you choose the amount, i want it so

MAX Sending Amount: 100000$
MINIMUM Sending Amount: 1$

Can You guys help me please?

Please send the codes etc ordinary with Easy STEP by STEP PLEASE if you got time to do that, if not, then just put the codes.

I will REP if i can! (Will try to REP, never REP'ed anyone so i will TRY!)
Reply
#2

Code:
CMD:givecash(playerid,params[])
{
	new target,ammount;
	if(sscanf(params,"ud",target,ammount)) return SendClientMessage(playerid,-1,"/givecash[playerid][ammount]");
	if(!IsPlayerConnected(target)) return SendClientMessage(playerid,-1,"invalid playerid.");
	if(ammount > 1020301 || ammount < 0) return SendClientMessage(playerid,-1,"Invalid ammount.");
	GivePlayerMoney(playerid,-ammount);
	GivePlayerMoney(target,ammount);
	return 1;
}
Reply
#3

Quote:
Originally Posted by Y_Less
View Post
Check the "givecash" tutorial on the wiki. There it shows you how to set a minimum amount (i.e. 0 so you can't steal money), a maximum is very similar but with ">" instead of "<" (or vice-versa).
Thank you i will check that

QUOTE: ---

Thanks but, my command is based in dialog as i said above in the example... and my command is in strcmp not CMD, but can do it for CMD too as well
Reply
#4

Quote:
Originally Posted by Godfather[TR]
View Post
Thank you i will check that

QUOTE: ---

Thanks but, my command is based in dialog as i said above in the example... and my command is in strcmp not CMD, but can do it for CMD too as well
You can see how I did it though. If you need any help, post some code here.
Reply
#5

Example for dialogs:

PHP Code:
if(inputtext 1020301 || inputtext 0) return ShowPlayerDialog(playerid123DIALOG_STYLE_MSGBOX,"Error""You have entered an invalid amount of cash!""Back""Close"); 
Reply
#6

if(!strcmp(cmdtext,"/sendmoney",true))
{
ShowPlayerDialog(playerid,1234,DIALOG_STYLE_INPUT, "Send Money","Enter the ID of the Player you want to Send Money","Okay","Cancel");
return 1;
}


Public OnDialogResponse

if(dialogid==1234&&response)
{
if(!strlen(inputtext))return ShowPlayerDialog(playerid,1234,DIALOG_STYLE_INPUT, "Send Money","Put the ID Of the Player You want to Send Money","Okay","Cancel");
if((GetTickCount()-WaitTimeForCMD[playerid])>60000)return SendClientMessage(playerid,COLOR_RED,"ERROR: You can send only 1 time's per 1 Minute.");
new level;
if((level < 1) || (level > 100000)) return SendClientMessage(playerid,0xFF0000AA,"The MAXIMUM Cash Amount is 1$ - 500.000$);
para[playerid]=strval(inputtext);
ShowPlayerDialog(playerid,1235,DIALOG_STYLE_INPUT, "Send Money","Enter the Cash Amount","Okay","Cancel");
}
if(dialogid==1235&&response)
{
if(!strlen(inputtext))return ShowPlayerDialog(playerid,1235,DIALOG_STYLE_INPUT, "Send Money","Enter the Amount","Okay","Cancel");
GivePlayerMoney(playerid,-strval(inputtext));
GivePlayerMoney(para[playerid],strval(inputtext));
WaitTimeForCMD[playerid]=GetTickCount();
para[playerid]=INVALID_PLAYER_ID;
}
Reply
#7

PHP Code:
if((level 1) || (level 100000)) return SendClientMessage(playerid,0xFF0000AA,"The MAXIMUM Cash Amount is 1$ - 500.000$); 
Should be:

PHP Code:
if((inputtext 1) || (inputtext 100000)) return SendClientMessage(playerid,0xFF0000AA,"The MAXIMUM Cash Amount is 1$ - 500.000$); 
Note inputtext is defined under:

PHP Code:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[]) 
Inputtext means what the player typed in the dialog. So the text that the player typed in is called inputtext.
Reply
#8

As Y_Less said.. inputtext is a text (string) not an integer (number). Check for strval on Wiki.
Reply
#9

Ohh god, please help me oh my god, you guys think i DONT know that, i ALREADY did this

error 033: array must be indexed (variable "inputtext")

By typing on "inputtext" it DIDNT WORK!!!

Help please!
Reply
#10

Quote:
Originally Posted by Y_Less
View Post
Also, "inputtext" is a string, not an integer.
Quote:
Originally Posted by Riddick94
View Post
As Y_Less said.. inputtext is a text (string) not an integer (number). Check for strval on Wiki.
FOR GOD SAKE!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)