How can i make /transfer dialog..
#1

How can i make /transfer dialog from that command:
Код:
if(strcmp(cmd, "/transfer", true) == 0 || strcmp(cmd, "/wiretransfer", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(PlayerInfo[playerid][pLevel] < 3)
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   You must be level 3 !");
				return 1;
			}
	        if(PlayerToPoint(1.0, playerid, 321.5792,129.2914,1007.9657))
	        {
	            SCM(playerid, COLOR_GREY, "   You are not in the right place !");
	            return 1;
			}
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /transfer [playerid/PartOfName] [amount] [reason]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /transfer [playerid/PartOfName] [amount] [reason]");
				return 1;
			}
			moneys = strval(tmp);
			if (IsPlayerConnected(giveplayerid))
			{
			    if(giveplayerid != INVALID_PLAYER_ID)
			    {
			        new length = strlen(cmdtext);
			        while ((idx < length) && (cmdtext[idx] <= ' '))
			        {
			            idx++;
			        }
			        new offset = idx;
			        new result[128];
			        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			        {
			            result[idx - offset] = cmdtext[idx];
			            idx++;
			        }
			        result[idx - offset] = EOS;
			        if(!strlen(result))
			        {
			            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /transfer [playerid/PartOfName] [amount] [reason]");
			            return 1;
			        }
					GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
					GetPlayerName(playerid, sendername, sizeof(sendername));
					playermoney = PlayerInfo[playerid][pAccount] ;
					if (moneys > 0 && playermoney >= moneys)
					{
						format(string, sizeof(string),"%s wants to transfer you %d$ reason: %s, if you want to accept the money, type /accept money.",sendername,moneys,(result));
		                SendClientMessage(giveplayerid, COLOR_LIGHTRED, string);
	    	            format(string, sizeof(string),"You have offered %s to accept %d$ reason: %s.Wait his answer.",giveplayer,moneys,(result));
		                SendClientMessage(playerid, COLOR_LIGHTRED, string);
                        TransferOffer[giveplayerid] = playerid;
                        TransferMoney[giveplayerid] = moneys;
                        format(string, sizeof(string), "%s transferd $%d to %s reason: %s", sendername, moneys, giveplayer, (result));
		                if(moneys >= 500000)
						{
							ABroadCast(COLOR_YELLOW,string,1);
						}
						PayLog(string);
					}
					else
					{
						SendClientMessage(playerid, COLOR_GRAD1, "   Invalid transaction amount.");
					}
				}
			}
			else
			{
				format(string, sizeof(string), "   %d is not an active player.", giveplayerid);
				SendClientMessage(playerid, COLOR_GRAD1, string);
			}
		}
		return 1;
	}
thanks ...
Reply
#2

Quote:
How can i make /transfer dialog from that command:

https://sampwiki.blast.hk/wiki/ShowPlayerDialog
And convert them.
Reply
#3

yes i tried, but i get "pawno don't send" ...
Reply
#4

Post the errors that you get, and your OnDialogResponse public please
Reply
#5

Quote:
Originally Posted by dowster
Посмотреть сообщение
Post the errors that you get, and your OnDialogResponse public please
He didn't get errors, he said pawno crashed.

OT: Make sure you didn't miss any bracket, in OnDialogResponse
Reply
#6

Код:
if(strcmp(cmd, "/transfer", true) == 0 || strcmp(cmd, "/wiretransfer", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pIsaBank] != 1)
	        {
	            SendClientMessage(playerid, COLOR_GREY, "   You are not at the Bank !");
	            return 1;
	        }
	        if(PlayerToPoint(1.0, playerid, 321.5792,129.2914,1007.9657))
	        {
	            SCM(playerid, COLOR_GREY, "   You are not in the right place !");
	            return 1;
			}
			format(string,sizeof(string),""color_white"Account: "color_green"%d$\n"color_white"How much money do you want to send:",PlayerInfo[playerid][pAccount]);
		    ShowPlayerDialog(playerid,450,DIALOG_STYLE_INPUT,""color_yellow"Bank:",string,"Ok","Exit");
		    PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
			return 1;
		}
		return 1;
 	}
Код:
if(dialogid==450)
    {
    	if(response)
		{
        	if(IsPlayerConnected(playerid))
			{
            	ShowPlayerDialog(playerid,451,DIALOG_STYLE_MSGBOX,""color_yellow"Bank:",""color_white"This player isn't online.","Ok","Exit");
            	PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
				return 1;
			}
			format(string,sizeof(string),""wh"You want to send the money to:"color_red"%s\n"color_white"Balance: "color_green"%d$", playerid, PlayerInfo[playerid][pAccount]);
	    	ShowPlayerDialog(playerid,452,DIALOG_STYLE_MSGBOX,""color_yellow"Bank:",string,"Ok","Exit");
	    	PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
			return 1;
    	}
    }
    if(dialogid==452)
    {
    	if(response)
		{
			new cashdeposit = strval(inputtext);
        	if (cashdeposit > PlayerInfo[playerid][pAccount] || cashdeposit < 1)
			{
            	ShowPlayerDialog(playerid,451,DIALOG_STYLE_MSGBOX,""color_yellow"Bank:",""color_white"You don't have so much money!","Ok","Exit");
            	PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
				return 1;
			}
			PlayerInfo[playerid][pAccount] = -cashdeposit;
			PlayerInfo[giveplayerid][pAccount] = +cashdeposit;
			format(string,sizeof(string),""color_white"You send: "color_green"%d$\n"color_white"New Balance: "color_green"%d$", cashdeposit, PlayerInfo[playerid][pAccount]);
	    	ShowPlayerDialog(playerid,452,DIALOG_STYLE_MSGBOX,""color_yellow"Bank:",string,"Ok","Exit");
	    	PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
			return 1;
    	}
    }
totally mess X_X
Reply
#7

Can you indent your code please, we can't understand non-indented code
Reply
#8

Код:
if(strcmp(cmd, "/transfer", true) == 0 || strcmp(cmd, "/wiretransfer", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pIsaBank] != 1)
	        {
	            SendClientMessage(playerid, COLOR_GREY, "   You are not at the Bank !");
	            return 1;
	        }
	        if(PlayerToPoint(1.0, playerid, 321.5792,129.2914,1007.9657))
	        {
	            SCM(playerid, COLOR_GREY, "   You are not in the right place !");
	            return 1;
			}
			new str[256];
			format(str,256,"%s\t"wh"Type the player "color_red"ID\t\n\n",str);
			ShowPlayerDialog(playerid,TransferDialog,DIALOG_STYLE_INPUT,""color_yellow"Bank:",str,"Ok","exit");
			return 1;
		}
		return 1;
 	}
ondialogresponse:
Код:
if(dialogid == TransferDialog)
	{
		if(response)
		{
		    if (IsPlayerConnected(playerid))
			{
		    	new giveplayerid = strval(inputtext);
				if (giveplayerid == playerid)
				{
				    format(string, 256, "%s"wh"You can't send money to yourself.\n\n",string);
					ShowPlayerDialog( playerid, 1559, DIALOG_STYLE_MSGBOX, ""color_yellow"Bank:", string, "Exit", "" );
					return 1;
				}
				else
				{
				    format(string, 256, "%s"wh"Type how much money do you want to transfer.\t\n",string);
				    format(string, 256, "%s"wh"Balance: "color_green"%d$"wh".\t\n\n",string, PlayerInfo[playerid][pAccount]);
					ShowPlayerDialog(playerid,TransferDialog+1,DIALOG_STYLE_INPUT,""color_yellow"Bank:", string,"Ok","Exit");
					PlayerInfo[playerid][pAccount] = giveplayerid;
				}
			}
		}
		return 1;
	}
	if(dialogid == TransferDialog+1)
	{
		if(response)
		{
		    new giveplayerid = PlayerInfo[playerid][pAccount];
			if (IsPlayerConnected(giveplayerid))
			{
			    if (giveplayerid == playerid)
				{
				    format(string, 256, "%s"wh"Type how much money do you want to transfer.\t\n",string);
				    format(string, 256, "%s"wh"Balance: "color_green"%d$"wh".\t\n\n",string, PlayerInfo[playerid][pAccount]);
					ShowPlayerDialog(playerid,TransferDialog+1,DIALOG_STYLE_INPUT,""color_yellow"Bank:", string,"Ok","Exit");
				}
				else
				{
					GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
					playermoney = PlayerInfo[playerid][pAccount];
					if (moneys > 0 && playermoney >= moneys)
					{
					    PlayerInfo[playerid][pAccount] = -moneys;
					    PlayerInfo[giveplayerid][pAccount] = moneys;
						format(string, sizeof(string), "%s"wh"You've send "color_green"%d$"wh" to "color_red"%s"wh".\t\n",string,moneys,giveplayer);
						ShowPlayerDialog( playerid, 1560, DIALOG_STYLE_MSGBOX, ""color_yellow"Bank:", string, "Exit", "" );
						PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
						format(string, sizeof(string), "** You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
						SendClientMessage(giveplayerid, COLOR_GRAD1, string);
						PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
					}
					else
					{
						format(string, 256, "%s"wh"Invalid tranzaction amount.\n",string);
						ShowPlayerDialog( playerid, 1551, DIALOG_STYLE_MSGBOX, ""color_yellow"Bank:", string, "Exit", "" );
						return 1;
					}
				}
			}
			else
			{
				format(string, 256, "%s"wh"This player isn't online.\n",string);
				ShowPlayerDialog( playerid, 1559, DIALOG_STYLE_MSGBOX, ""color_yellow"Bank:", string, "Exit", "" );
				return 1;
			}
		}
		return 1;
	}
But is bugged... if i type at the input id/name/something i lose money from Bank account... and if i type a id of a offline player when i get the dialog: "how much money blabla", i type 653453, i lose money too ( from bank account ) what is the problem ? :-s
Reply
#9

bump ... :-s
Reply
#10

pawn Код:
if (IsPlayerConnected(strval(inputtext)))//This
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)