SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 29/11/2017, 10:09 PM   #1
Mivco
Big Clucker
 
Mivco's Avatar
 
Join Date: Mar 2015
Location: Slovakia
Posts: 60
Reputation: 0
Post GIVECASH

How do I make a givecash because I want to give it to OnPlayerClickPlayer ??
Thanks
Mivco is offline   Reply With Quote
Old 29/11/2017, 10:13 PM   #2
RageCraftLV
Big Clucker
 
Join Date: Jun 2016
Location: Latvia <3
Posts: 56
Reputation: 4
Default Re: GIVECASH

You have to specify how you want to give it. Just by double-clicking player, and giving him 100k, or maybe showing a dialog asking how much do you want to give?
__________________
RageCraftLV is offline   Reply With Quote
Old 29/11/2017, 10:16 PM   #3
Mivco
Big Clucker
 
Mivco's Avatar
 
Join Date: Mar 2015
Location: Slovakia
Posts: 60
Reputation: 0
Default Re: GIVECASH

Normally how much I want to give
Mivco is offline   Reply With Quote
Old 29/11/2017, 10:27 PM   #4
RageCraftLV
Big Clucker
 
Join Date: Jun 2016
Location: Latvia <3
Posts: 56
Reputation: 4
Default Re: GIVECASH

Code:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	if(!IsPlayerConnected(clickedplayerid)) return SendClientMessage(playerid, -1, "Player not online!");
	if(clickedplayerid == playerid) return SendClientMessage(playerid, -1, "Cannot give money to yourself!");
	Dialog_Show(playerid, GiveMoney, DIALOG_STYLE_INPUT, "Give money", "Please specify how much money you want to give (ID, amount)", "OK", "Cancel");
	SetPVarInt(playerid, "ClickedPlayer", clickedplayerid);
	return 1;
}

Dialog:GiveMoney(playerid, response, listitem, inputtext[])
{
	if(!response) return 1;
	new 
		clickedplayer = GetPVarInt(playerid, "ClickedPlayer"),
		amount;
	if(sscanf(inputtext, "i", amount)) return Dialog_Show(playerid, GiveMoney, DIALOG_STYLE_INPUT, "Give money", "Please specify how much money you want to give", "OK", "Cancel");
	if(amount > GetPlayerMoney(playerid)) return SendClientMessage(playerid, -1, "Not enough money!");
	GivePlayerMoney(playerid, -amount);
	GivePlayerMoney(clickedplayer, amount);
	return 1;
}
This should give you the rough idea. Not tested!
__________________
RageCraftLV is offline   Reply With Quote
Old 30/11/2017, 02:10 AM   #5
Mivco
Big Clucker
 
Mivco's Avatar
 
Join Date: Mar 2015
Location: Slovakia
Posts: 60
Reputation: 0
Post Re: GIVECASH

I did it this way but it shows me error.....

PHP Code:
PlayerInfo[playerid][BankMoney]+=strval(castka);
GivePlayerMoney(playerid,-strval(castka));

error 035argument type mismatch (argument 1)
error 035argument type mismatch (argument 1
DIALOG....
PHP Code:
case DIALOG_PLAYER3:
        {
            if(
response == 1)
            {
                   switch(
listitem)
                {
                    case 
0:
                    {
                           if(
IsPlayerConnected(playerid))
                        {
                            if(
strlen(inputtext) > 24) return SendClientMessage(playeridCOLOR_SYSTEM"Chybne parametry!");
                            new 
hrac strval(inputtext),pos chrfind(' ',inputtext);
                             if(
playerid == hracSendClientMessage(playeridCOLOR_SYSTEM"Sam sobe si nemuzes posilat penize.");
                            else
                            {
                                new 
castka strval(inputtext[pos]),string[200];
                                if(
castka GetPlayerMoney(playerid) || castka 1SendClientMessage(playeridCOLOR_SYSTEM"Chybna castka.");
                                else
                                {
                                    
PlayerInfo[playerid][BankMoney]+=strval(castka);
                                    
GivePlayerMoney(playerid,-strval(castka));
                                    
format(stringsizeof(string), "Poslal jste hráči %s castku %d$."PlayerName(hrac), castka);
                                    
SendClientMessage(playerid,COLOR_ORANGE,string);
                                    new 
strinG0[128];
                                    
format(strinG0sizeof(strinG0), "Hráč %s ti poslal %d$.",PlayerName(playerid), castka);
                                    
SendClientMessage(hrac,COLOR_ORANGE,strinG0);
                                }
                            }
                        }
                     }
                }
            }
        } 
Mivco is offline   Reply With Quote
Old 30/11/2017, 05:22 AM   #6
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,920
Reputation: 258
Default Re: GIVECASH

"castka" is already an integer.
You can't use strval on it (since strval need a string as a parameter).
PHP Code:
PlayerInfo[playerid][BankMoney]+=strval(castka); 
GivePlayerMoney(playerid,-strval(castka)); 
You should read error message carefully.
__________________
actor_plus - v5.0.2
« I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath »
Dayrion is offline   Reply With Quote
Old 30/11/2017, 07:47 AM   #7
Mivco
Big Clucker
 
Mivco's Avatar
 
Join Date: Mar 2015
Location: Slovakia
Posts: 60
Reputation: 0
Default Re: GIVECASH

Quote:
Originally Posted by Dayrion View Post
"castka" is already an integer.
You can't use strval on it (since strval need a string as a parameter).
PHP Code:
PlayerInfo[playerid][BankMoney]+=strval(castka); 
GivePlayerMoney(playerid,-strval(castka)); 
You should read error message carefully.
So how do it make it work if I want to to make a player through ClickPlayer send the player money from the Bank
Mivco is offline   Reply With Quote
Old 30/11/2017, 09:17 AM   #8
RageCraftLV
Big Clucker
 
Join Date: Jun 2016
Location: Latvia <3
Posts: 56
Reputation: 4
Default Re: GIVECASH

Why aren't you using sscanf?
__________________
RageCraftLV is offline   Reply With Quote
Old 30/11/2017, 02:25 PM   #9
Markaraza
Little Clucker
 
Join Date: Nov 2017
Posts: 23
Reputation: 2
Default Re: GIVECASH

Dude, are u using Roleplay Gamong this is our for roleplay gamemode

Code:
CMD:pay(playerid, params[])
{
	if(AdminDuty[playerid] == 1)
 	{
  		SendClientMessage(playerid,COLOR_WHITE, "You can't use this command while on-duty as admin.");
		return 1;
	}

	new
		iTargetID, iCashAmount;

	if(sscanf(params, "ui", iTargetID, iCashAmount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pay [playerid/partofname] [amount]");

	if(iTargetID == playerid)
	{
		SendClientMessage(playerid, COLOR_GRAD1, "You can't use this command on yourself!");
		return 1;
	}
	if(iCashAmount > 100 && PlayerInfo[playerid][pLevel] < 2)
	{
		SendClientMessage(playerid, COLOR_GRAD1, "You must be level 2 to pay over $100");
		return 1;
	}
	if(iCashAmount < 1 || iCashAmount > 10000)
	{
		SendClientMessage(playerid, COLOR_GRAD1, "Don't go below $1, or above $10,000 at once.");
		return 1;
	}
	if(IsPlayerConnected(iTargetID))
	{
		if(ProxDetectorS(5.0, playerid, iTargetID))
		{
			new
				szMessage[128], giveplayer[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME], playermoney = GetPlayerCash(playerid);

			giveplayer = GetPlayerNameEx(iTargetID);
			sendername = GetPlayerNameEx(playerid);
			if(iCashAmount > 0 && playermoney >= iCashAmount)
			{
				GivePlayerCash(playerid, (0 - iCashAmount));
				GivePlayerCash(iTargetID, iCashAmount);
				format(szMessage, sizeof(szMessage), "   You have sent %s(player: %d), $%d.", GetPlayerNameEx(iTargetID),iTargetID, iCashAmount);
				PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
				SendClientMessage(playerid, COLOR_GRAD1, szMessage);
				format(szMessage, sizeof(szMessage), "   You have recieved $%d from %s(player: %d).", iCashAmount, GetPlayerNameEx(playerid), playerid);
				SendClientMessage(iTargetID, COLOR_GRAD1, szMessage);

				new ip[32], ipex[32];
				GetPlayerIp(playerid, ip, sizeof(ip));
				GetPlayerIp(iTargetID, ipex, sizeof(ipex));
				format(szMessage, sizeof(szMessage), "%s (IP:%s) has paid $%d to %s (IP:%s)", GetPlayerNameEx(playerid), ip, iCashAmount, GetPlayerNameEx(iTargetID), ipex);
				Log("logs/pay.log", szMessage);

				PayWarn[playerid][iTargetID] += iCashAmount;
				if(PayWarn[playerid][iTargetID] >= 10000 && PlayerInfo[playerid][pLevel] <= 3)
				{
					format(szMessage, sizeof(szMessage), "%s (IP:%s) has paid %s (IP:%s) $%d in this session.", GetPlayerNameEx(playerid), ip, GetPlayerNameEx(iTargetID), ipex, PayWarn[playerid][iTargetID]);
					ABroadCast(COLOR_YELLOW, szMessage, 1);
				}

				if(iCashAmount >= 100000)
				{
					ABroadCast(COLOR_YELLOW,szMessage,1);
				}

				PlayerPlaySound(iTargetID, 1052, 0.0, 0.0, 0.0);
				format(szMessage, sizeof(szMessage), "* %s takes out some cash, and hands it to %s.", GetPlayerNameEx(playerid) ,GetPlayerNameEx(iTargetID));
				ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   Invalid transaction amount.");
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "That player isn't near you.");
		}
	}
	else SendClientMessage(playerid, COLOR_GRAD1, "Invalid player specified.");
	return 1;
}
Markaraza is offline   Reply With Quote
Old 30/11/2017, 05:33 PM   #10
Mivco
Big Clucker
 
Mivco's Avatar
 
Join Date: Mar 2015
Location: Slovakia
Posts: 60
Reputation: 0
Default Re: GIVECASH

I want to send the money to the player through the TAB.......
Mivco is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/givecash Help Areax Scripting Help 7 14/04/2013 07:42 PM
Help /givecash [MKD]Max Help Archive 1 30/07/2011 11:47 AM
Givecash bug [LSB]TheGame Help Archive 1 22/04/2011 06:09 PM
/givecash amrour Help Archive 5 15/02/2009 04:55 PM


All times are GMT. The time now is 11:08 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.