SA-MP Forums Archive
Taking money - 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: Taking money (/showthread.php?tid=358088)



Taking money - RedFusion - 09.07.2012

I don't get it, why does this not work?
pawn Код:
if(GetPlayerMoney(playerid) >= 20000)
{
GivePlayerMoney(playerid,- 20000);
//other stuff here
}



Re: Taking money - DBan - 09.07.2012

How does it not work? It works fine for me.


Re: Taking money - Vince - 09.07.2012

I'm pretty sure that a space is not allowed between -20000.


Re: Taking money - DBan - 09.07.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
I'm pretty sure that a space is not allowed between -20000.
I tested it and it works fine with the space


Re: Taking money - RedFusion - 09.07.2012

pawn Код:
switch(listitem)
            {
                case 0:
                {
                    if(GetPlayerMoney(playerid) >= 20000)
                    {
                        ShowPlayerDialog(playerid,windsorshop,0,"Windsor","Do you want to buy this vehicle for \n$20 000 ?","Yes","No");
                        GivePlayerMoney(playerid,- 20000);
                        return 1;
                    }
                    else if(GetPlayerMoney(playerid) < 20000)
                    {
                        ShowPlayerDialog(playerid,windsorshop,0,"Windsor","Do you want to buy this vehicle for \n$20 000 ?","Yes","No");
                        SendClientMessage(playerid,0xFF0000FF,"You don't have enough money");
                        return 1;
                    }
                }
            }



Re: Taking money - DBan - 09.07.2012

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
pawn Код:
switch(listitem)
            {
                case 0:
                {
                    if(GetPlayerMoney(playerid) >= 20000)
                    {
                        ShowPlayerDialog(playerid,windsorshop,0,"Windsor","Do you want to buy this vehicle for \n$20 000 ?","Yes","No");
                        GivePlayerMoney(playerid,- 20000);
                        return 1;
                    }
                    else if(GetPlayerMoney(playerid) < 20000)
                    {
                        ShowPlayerDialog(playerid,windsorshop,0,"Windsor","Do you want to buy this vehicle for \n$20 000 ?","Yes","No");
                        SendClientMessage(playerid,0xFF0000FF,"You don't have enough money");
                        return 1;
                    }
                }
            }
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext [ ])
{
    switch(dialogid)
    {
        case 25:
            {
            switch(listitem)
                {
                    case 0:
                    {
                        if(!response) return 0;
                        if(response)
                        {
                            if(GetPlayerMoney(playerid) >= 20000)
                            {
                                ShowPlayerDialog(playerid, 28,0,"Windsor","Do you want to buy this vehicle for \n$20 000 ?","Yes","No");
                                return 1;
                            }
                            else if(GetPlayerMoney(playerid) < 20000)
                            {
                                ShowPlayerDialog(playerid, 27, 0,"Windsor","Do you want to buy this vehicle for \n$20 000 ?","Yes","No");
                                SendClientMessage(playerid,0xFF0000FF,"You don't have enough money");
                                return 1;
                            }
                        }
                    }
                }
            }
            case 28:
            {
                if(!response) return 0;
                if(response)
                {
                    GivePlayerMoney(playerid,- 20000);
                }
            }
        }
    return 0;
}
Replace the IDs accordingly.

The solution is pretty self-explanatory.


Re: Taking money - CmZxC - 09.07.2012

Maybe you have a server-sided stat that constantly keeps setting the player money?
Those systems are used to prevent money hackers ..


Re: Taking money - RedFusion - 09.07.2012

I'll try DBan's first and if it doesnt work then i'll check for anticheat scripts, thanks for the help!
EDIT: Dban's suggestion worked out. Thanks both of you


Re: Taking money - clarencecuzz - 09.07.2012

He's not trying to get rid of someone's money once it surpasses 20,000. He's trying to make the server take away 20,000 after he has accepted to purchase a vehicle. Which he hasn't done very efficiently, seeing as it is taking the money before the player has even accepted, however Derek's solution should work.

EDIT:
pawn Код:
else if(GetPlayerMoney(playerid) < 20000)
                            {
                                ShowPlayerDialog(playerid, 27, 0,"Windsor","Do you want to buy this vehicle for \n$20 000 ?","Yes","No");
                                SendClientMessage(playerid,0xFF0000FF,"You don't have enough money");
                                return 1;
                            }
Shouldn't the dialog NOT be displayed if they don't have enough money?


Re: Taking money - DBan - 09.07.2012

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
He's not trying to get rid of someone's money once it surpasses 20,000. He's trying to make the server take away 20,000 after he has accepted to purchase a vehicle. Which he hasn't done very efficiently, seeing as it is taking the money before the player has even accepted, however Derek's solution should work.

EDIT:
pawn Код:
else if(GetPlayerMoney(playerid) < 20000)
                            {
                                ShowPlayerDialog(playerid, 27, 0,"Windsor","Do you want to buy this vehicle for \n$20 000 ?","Yes","No");
                                SendClientMessage(playerid,0xFF0000FF,"You don't have enough money");
                                return 1;
                            }
Shouldn't the dialog NOT be displayed if they don't have enough money?
HAHAHA, now I know why I recognized your name, you were on NVCNR? lol

And yes, I noticed that but left it for him to remove.