Money transfer system - 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: Money transfer system (
/showthread.php?tid=570300)
Money transfer system -
dimashr12345 - 08.04.2015
Hey, guys!
I would like to create a system that allows players to send money to each other. Can anyone help me do this?
Re: Money transfer system -
CalvinC - 08.04.2015
Read these:
https://sampforum.blast.hk/showthread.php?tid=300397
https://sampwiki.blast.hk/wiki/GetPlayerMoney
https://sampwiki.blast.hk/wiki/GivePlayerMoney
And try making an attempt yourself.
Re: Money transfer system -
NoDi522 - 09.04.2015
PHP код:
#include <a_samp>
#include <sscanf>
#include <zcmd>
// For this to work you will need this includes.
CMD:pay(playerid,params[])
{
new ID,ime[MAX_PLAYER_NAME],ime2[MAX_PLAYER_NAME],poruka[128],poruka2[128],kolicina;
if(sscanf(params,"ud",ID,kolicina)) return SendClientMessage(playerid,-1,"Syntax: /pay (ID/name) (amount)");
else if(ID == playerid) return SendClientMessage(playerid,-1," You can't pay yourself");
else if(ID == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Error: That player is not logged in");
else if(GetPlayerMoney(playerid) < kolicina) return SendClientMessage(playerid,-1,"Error: You don't have enough money");
else if(kolicina <= 0) return SendClientMessage(playerid,-1,"Error: You can't pay less than $1");
else if(kolicina > 10000) return SendClientMessage(playerid,-1,"Error: You can't pay more than 10.000$");
{
GetPlayerName(playerid,ime,sizeof(ime));
format(poruka,sizeof(poruka),"%s[%d] has send you $%d",ime,playerid,kolicina);
SendClientMessage(ID,-1,poruka);
GetPlayerName(ID,ime2,sizeof(ime2));
format(poruka2,sizeof(poruka2),"You have send $%d to player %s[%d]",kolicina,ime2,ID);
SendClientMessage(playerid,-1,poruka2);
{
GivePlayerMoney(ID,kolicina);
GivePlayerMoney(playerid,-kolicina);
}
}
return 1;
}
Re: Money transfer system -
Muhammad78 - 09.04.2015
PHP код:
#include <a_samp>
#include <zcmd>
#include <sscanf>
#define COLOR_BRIGHTRED 0xDC143CAA
#define COLOR_GREEN 0x33AA33AA
PHP код:
CMD:givemoney(playerid,params[]) {
new moneys,giveplayerid,giveplayer[MAX_PLAYER_NAME],sendername[MAX_PLAYER_NAME],playermoney[MAX_PLAYERS],string[64];
if (sscanf(params, "ud",giveplayerid, moneys)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /givemoney [playerid] [amount]");
if (IsPlayerConnected(giveplayerid)) {
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
playermoney[playerid] = GetPlayerMoney(playerid);
if (moneys > 0 && playermoney[playerid] >= moneys) {
GivePlayerMoney(playerid, (-moneys));
GivePlayerMoney(giveplayerid, moneys);
format(string, sizeof(string), "You have sent %s (id: %d), $%d.", giveplayer,giveplayerid, moneys);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "You have recieved $%d from %s (id: %d).", moneys, sendername, playerid);
SendClientMessage(giveplayerid, COLOR_GREEN, string);
printf("%s (%d) has transfered %d to %s (%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
}
else {
SendClientMessage(playerid, COLOR_BRIGHTRED, "Invalid transaction amount.");
}
}
else {
format(string, sizeof(string), "ID:%d is not an active player.", giveplayerid);
SendClientMessage(playerid, COLOR_BRIGHTRED, string);
}
return 1;
}
This may help you