i have now a /pay command. but how can i do it that all /pay things are saved in the pay.log file??
Код:
// /pay
if(!strcmp(strget(cmdtext, 0), "/pay")) {
new typ = strval(strget(cmdtext, 1));
if(IsPlayerConnected(typ)) {
new summe = strval(strget(cmdtext, 2));
if(GetPlayerMoney(playerid) >= summe) {
if(summe <= 0 || summe >= 100001) { SendClientMessage(playerid,COLOR_RED,"Don't go under 1$ and above 100000$"); } else {
new string[256], str[256], geber[MAX_PLAYER_NAME], erhalter[MAX_PLAYER_NAME];
GetPlayerName(playerid,geber,sizeof(geber)); GetPlayerName(typ,erhalter,sizeof(erhalter));
format(str,sizeof(str),"You have solt %d$ to %s",summe,erhalter);
format(string,sizeof(string),"You received %d$ from %s",summe,geber);
SendClientMessage(playerid,COLOR_NEUTRALGREEN,str); SendClientMessage(typ,COLOR_NEUTRALGREEN,string);
GivePlayerMoney(playerid,-summe); GivePlayerMoney(typ,summe); }}
else { SendClientMessage(playerid,COLOR_RED,"You don't have enough money"); }}
else { SendClientMessage(playerid,COLOR_RED,"INVALID ID"); }
return 1;
}
and how can i save all admincommands who were used by the admins in a log file?? /i use seif adminfs)
PHP код:
if(strcmp(cmd, "/pay", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pay [playerid/PartOfName] [amount]");
return 1;
}
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pay [playerid/PartOfName] [amount]");
return 1;
}
moneys = strvalEx(tmp);
if(moneys > 1000 && PlayerInfo[playerid][pLevel] < 2)
{
SendClientMessage(playerid, COLOR_GRAD1, " You must be level 2 to pay more than $1000 at a time !");
return 1;
}
if(moneys < 1 || moneys > 100000)
{
SendClientMessage(playerid, COLOR_GRAD1, " You can't pay more under $1 or than $100,000 at a time !");
return 1;
}
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, " You can't pay money to yourself !"); return 1; }
if(giveplayerid != INVALID_PLAYER_ID)
{
if(ProxDetectorS(5.0, playerid, giveplayerid))
{
GetPlayerNameEx(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
new playermoney = PlayerInfo[playerid][pCash];
if(moneys > 0 && playermoney >= moneys)
{
PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-moneys;
GivePlayerMoney(playerid, (0 - moneys));
PlayerInfo[giveplayerid][pCash] = PlayerInfo[giveplayerid][pCash]+moneys;
GivePlayerMoney(giveplayerid, moneys);
if(PlayerInfo[playerid][pMask] > 0){ sendername = "Stranger"; }
if(PlayerInfo[giveplayerid][pMask] > 0){ giveplayer = "Stranger"; }
format(string, sizeof(string), " You have paid $%d to %s",moneys,giveplayer);
SendClientMessage(playerid, COLOR_GRAD1, string);
format(string, sizeof(string), " You have recieved $%d from %s.", moneys,sendername);
SendClientMessage(giveplayerid, COLOR_GRAD1, string);
format(string, sizeof(string), "* %s takes out some cash, and hands it to %s.",sendername,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
new plrIP[16];
new giveplrIP[16];
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
GetPlayerIp(giveplayerid, giveplrIP, sizeof(giveplrIP));
format(string, sizeof(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(playerid, COLOR_GRAD1, " Invalid transaction amount !");
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " You're too far away !");
}
}
}
else
{
format(string, sizeof(string), " %d is not an active player !", giveplayerid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
return 1;
}