[HELP] dialog
#1

hello.

im a beginner in scripting for sa-mp.
the PM thingy work fine.
now , i want to give clicked player the money amount i type in the box.

little explaination : GivePlayerMoney(clickeduser, x_amountofmoney);


here my curent code
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_CLICK)
 	  {
		if(!response)  return SendClientMessage(playerid,RED,"You didn't selected any option.");
		if(response)
		{
            ShowPlayerDialog(playerid, 2001, DIALOG_STYLE_INPUT, "PM", "Enter the message to send ", "Ok", "Quit");
            ShowPlayerDialog(playerid, 2002, DIALOG_STYLE_INPUT, "SENDMONEY", "Ammount", "Ok", "Quit");
        	}
    	return 1;
	    }
     if(dialogid == 2001)
               {
                 if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Player OFFLINE!");
                 if(strlen(inputtext) > 0)
                 {
                 GetPlayerName(playerid, Nome, sizeof(Nome));
                 GetPlayerName(playerid, ClickedPlayer, sizeof(ClickedPlayer));
                 format(StringaPM, sizeof(StringaPM), " PM received from: %s(%d): %s ", ClickedPlayer, playerid, inputtext);
	             SendClientMessage(playerid,GREEN, StringaPM);
	             format(StringaPM, sizeof(StringaPM), "(( PM sent to: %s(%d): %s ))", Nome, playerid, inputtext);
    			 SendClientMessage(playerid,YELLOW, StringaPM);
                 }
                 }

     if(dialogid == 2002)
               {
                 if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Player OFFLINE!");
                 if(strlen(inputtext) > 0)
                 {
				 // GIVE ENTERED MONEY AMOUNT TO THE "CLICKED" PLAYER
                 }
                 }
	return 0;
i hope you guys will be able to help me on that and understand it.

thanks
Reply
#2

Hello.

At first, you need to make variable with will hold selected id of selected player.
pawn Код:
new myId;
After on, you must do some stuff in OnPlayerClickPlayer callback (which, as I believe, you've already done).

For example:
pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
ShowPlayerDialog(2002, DIALOG_STYLE_INPUT, "Give cash", "Give him a cash cus he's so poor and so..", "Give", "No way");
clickedplayerid = myId;
return 1;
}
Then you can do something like this
pawn Код:
if(strlen(inputtext) > 0)
{
new amount;
amount = strval(inputtext);

if(amount <= 0)
{
// If amount is 0 or lower
}
else
{
// If amount is bigger than 0
GivePlayerMoney(myId, amount);
// You can do also some other stuff, like SendClientMessage which says * USERNAME has just given you $x or something.

// Yay, forget to give this one.. :P Just for debug stuff
myId = -1;
}
}
Sorry, I am in hurry a little, and this cody may be a little messy, but I believe You will understand, what I wanted to write

Greetz,
LetsOWN
Reply
#3

thanks i will try.

but... should'nt be that on OnDialogResponse like the PM system ?
Reply
#4

Hey

pawn Код:
if(strlen(inputtext) > 0)
{
new amount;
amount = strval(inputtext);

if(amount <= 0)
{
// If amount is 0 or lower
}
else
{
// If amount is bigger than 0
GivePlayerMoney(myId, amount);
// You can do also some other stuff, like SendClientMessage which says * USERNAME has just given you $x or something.

// Yay, forget to give this one.. :P Just for debug stuff
myId = -1;
}
}
Forget to add it
Yes, this part goes to OnPlayerDialogResponse.

The first part (myId variable) must be on the very top of the gamemode (to make it be global variable).
Any other questions ?

Greetz,
LetsOWN
Reply
#5

THANKS YOU VERY MUCH !
it work !

i will try meself to make it so the giver money decrease.
if i cant get it to work i will ask you but i have to try first
Reply
#6

Hah, of course, You're welcome

Good luck and happy scripting!

Greetz,
LetsOWN
Reply
#7

ok i tried ( maybe its the wrongest way to try it ever but i tried )

if i have 10000 and try to give 10001 i get the message saying i dont have enought money.
if i have enought money let say i have 10000 and try to send 500 the money doesnt change at all ( no decrease no increase ).
is it because tis too fast or because it really don't work ?
PS im trying this alone on local


Код:
     if(dialogid == 2002)
               {
                 if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Player OFFLINE!");
                 if(strlen(inputtext) > 0)
                 {
                 new amount;
                 amount = strval(inputtext);
                 if(amount <= 0)
                 {
                 // If amount is 0 or lower
                 }
                 else
                 {
                 // If amount is bigger than 0
                 GivePlayerMoney(myId, amount);
                 if(GetPlayerMoney(playerid) < amount) return SendClientMessage(playerid, RED, "You do not have enough money");
                 GivePlayerMoney(playerid, -amount);
                 myId = -1;
                }
               }
              }
	return 0;
Reply
#8

------------- UPDATE

pawn Код:
GivePlayerMoney(myId, amount);
                 if(GetPlayerMoney(playerid) < amount) return SendClientMessage(playerid, RED, "You do not have enough money");
                 GivePlayerMoney(playerid, -amount);
Hmm, these lines are wrong, because it will:
1. Give player money (amount you wrote)
2. Check if you have money you have given the player
3. If yes then it decerases your money
4. If no, then it doesnt decerase your money, sends you 'You dont have enough money' msg, but still gives 'myId' the money..

Do it this way:
pawn Код:
if(GetPlayerMoney(playerid) < amount)
{
SendClientMessage(playerid, 0xFF0000FF, "You do not have enough money");
return 1;
}
else
{
GivePlayerMoney(myId, amount);
GivePlayerMoney(playerid, -amount);
}
Should work..

Greetz,
LetsOWN
Reply
#9

Quote:
Originally Posted by LetsOWN[PL]
Посмотреть сообщение
Hello.

In this case, you need to do something like this:

pawn Код:
// Where is it in your 'OnPlayerDialogResponse'??
GivePlayerMoney(myId, amount);
// So under it..
GivePlayerMoney(playerid, -amount);
That's all

Greetz,
LetsOWN
lol i feel low.....

but the same thing happen. no money increase/decrease.
i think its because i try it on meself on local ( only 1 player on‌line = me )

anyway thank you so much !
Reply
#10

I am not a genius, but..
But are you expect decerase/incerase money count if:

> You give yourself $20?
>? Do I have $20?
>A: Yes
>Give me $20 (GivePlayerMoney(playerid, amount))
>Give away from me $20 (GivePlayerMoney(playerid, -amount))
>Result: Dafuk? 0

Greetz,
Lets ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)