pay command save in Pay.log
#2

Add This Forward
PHP код:
forward PLog(string[]); 
Here's the /pay script,
PHP код:
if(strcmp(cmd"/pay"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_WHITE"USAGE: /pay [playerid/PartOfName] [amount]");
                return 
1;
            }
            
giveplayerid ReturnUser(tmp);
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_WHITE"USAGE: /pay [playerid/PartOfName] [amount]");
                return 
1;
            }
            
moneys strvalEx(tmp);
            if(
moneys 1000 && PlayerInfo[playerid][pLevel] < 2)
            {
                
SendClientMessage(playeridCOLOR_GRAD1"   You must be level 2 to pay more than $1000 at a time !");
                return 
1;
            }
            if(
moneys || moneys 100000)
            {
                
SendClientMessage(playeridCOLOR_GRAD1"   You can't pay more under $1 or than $100,000 at a time !");
                return 
1;
            }
            if(
IsPlayerConnected(giveplayerid))
            {
                if(
giveplayerid == playerid) { SendClientMessage(playeridCOLOR_GREY"   You can't pay money to yourself !"); return 1; }
                if(
giveplayerid != INVALID_PLAYER_ID)
                {
                    if(
ProxDetectorS(5.0playeridgiveplayerid))
                    {
                        
GetPlayerNameEx(playeridsendernamesizeof(sendername));
                        
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
                        new 
playermoney PlayerInfo[playerid][pCash];
                        if(
moneys && playermoney >= moneys)
                        {
                            
PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-moneys;
                            
GivePlayerMoney(playerid, (moneys));
                            
PlayerInfo[giveplayerid][pCash] = PlayerInfo[giveplayerid][pCash]+moneys;
                            
GivePlayerMoney(giveplayeridmoneys);
                            if(
PlayerInfo[playerid][pMask] > 0){ sendername "Stranger"; }
                            if(
PlayerInfo[giveplayerid][pMask] > 0){ giveplayer "Stranger"; }
                            
format(stringsizeof(string), "   You have paid $%d to %s",moneys,giveplayer);
                            
SendClientMessage(playeridCOLOR_GRAD1string);
                            
format(stringsizeof(string), "   You have recieved $%d from %s."moneys,sendername);
                            
SendClientMessage(giveplayeridCOLOR_GRAD1string);
                            
format(stringsizeof(string), "* %s takes out some cash, and hands it to %s.",sendername,giveplayer);
                            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                            
PlayerPlaySound(playerid10520.00.00.0);
                            
PlayerPlaySound(giveplayerid10520.00.00.0);
                            new 
plrIP[16];
                            new 
giveplrIP[16];
                            
GetPlayerIp(playeridplrIPsizeof(plrIP));
                            
GetPlayerIp(giveplayeridgiveplrIPsizeof(giveplrIP));
                            
format(stringsizeof(string), "%s (IP:%s) (Key:%s) (ConTime:%d) has paid $%d to %s (IP:%s) (Key:%s)"sendername,plrIP,PlayerInfo[playerid][pKey], PlayerInfo[playerid][pConnectTime],moneys,giveplayer,giveplrIP,PlayerInfo[giveplayerid][pKey]);
                            
PayLog(string);
                        }
                        else
                        {
                            
SendClientMessage(playeridCOLOR_GRAD1"   Invalid transaction amount !");
                        }
                    }
                    else
                    {
                        
SendClientMessage(playeridCOLOR_GRAD1"   You're too far away !");
                    }
                }
            }
            else
            {
                
format(stringsizeof(string), "   %d is not an active player !"giveplayerid);
                
SendClientMessage(playeridCOLOR_GRAD1string);
            }
        }
        return 
1;
    } 
Add This below OnPlayerCommandText


PHP код:
public PLog(string[])
{
    new 
entry[256];
    
format(entrysizeof(entry), "%s\n",string);
    new 
File:hFile;
    
hFile fopen("Logs/pays.log"io_append);
    
fwrite(hFileentry);
    
fclose(hFile);

Reply


Messages In This Thread
pay command save in Pay.log - by Flo_White - 16.11.2008, 20:07
Re: pay command save in Pay.log - by Aira - 28.11.2011, 11:11

Forum Jump:


Users browsing this thread: 1 Guest(s)