Money transfer system
#1

Hey, guys!

I would like to create a system that allows players to send money to each other. Can anyone help me do this?
Reply
#2

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.
Reply
#3

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;

Reply
#4

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",giveplayeridmoneys)) return SendClientMessage(playeridCOLOR_LIGHTBLUE"USAGE: /givemoney [playerid] [amount]");
    if (
IsPlayerConnected(giveplayerid)) {
        
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
        
GetPlayerName(playeridsendernamesizeof(sendername));
        
playermoney[playerid] = GetPlayerMoney(playerid);
        if (
moneys && playermoney[playerid] >= moneys) {
            
GivePlayerMoney(playerid, (-moneys));
            
GivePlayerMoney(giveplayeridmoneys);
            
format(stringsizeof(string), "You have sent %s (id: %d), $%d."giveplayer,giveplayeridmoneys);
            
SendClientMessage(playeridCOLOR_GREENstring);
            
format(stringsizeof(string), "You have recieved $%d from %s (id: %d)."moneyssendernameplayerid);
            
SendClientMessage(giveplayeridCOLOR_GREENstring);
            
printf("%s (%d) has transfered %d to %s (%d)",sendernameplayeridmoneysgiveplayergiveplayerid);
        }
        else {
            
SendClientMessage(playeridCOLOR_BRIGHTRED"Invalid transaction amount.");
        }
    }
    else {
        
format(stringsizeof(string), "ID:%d is not an active player."giveplayerid);
        
SendClientMessage(playeridCOLOR_BRIGHTREDstring);
    }
    return 
1;

This may help you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)