/AcceptMoney command. -
OleKristian95 - 30.07.2012
What I am asking for if anyone could make a /acceptmoney command for me that will work with the /GiveMoney command below.
I have no idea how to do this myself so I beg for help.
I am having a problem with moneyhackers that are sending millions of money to my players.
pawn Код:
CMD:givemoney(playerid,params[]) {
if(PlayerInfo[playerid][LoggedIn] == 1) {
} else return SendClientMessage(playerid,red,"ERROR: You can't use this command!");
new moneys,giveplayerid,giveplayer[MAX_PLAYER_NAME],sendername[MAX_PLAYER_NAME],playermoney[MAX_PLAYERS],string[128];
if (sscanf(params, "ud",giveplayerid, moneys)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /givemoney [Playerid] [Amount]");
// if (!IsNumeric(giveplayerid)) giveplayerid = ReturnPlayerID(giveplayerid);
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(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
format(string, sizeof(string),"%s (%d) has transfered [$%d] to %s (%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
SaveToFile("GiveMoney",string);
MessageToAdmins(green,string);
}
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;
}
Re: /AcceptMoney command. -
SEnergy - 30.07.2012
something like this?
pawn Код:
new CanAcceptMoney[MAX_PLAYERS];
new MoneyAmount[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
CanAcceptMoney[playerid] = 0;
MoneyAmount[playerid] = 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/givemoney") == 0)
{
new targetid = strval(GetToken(cmdtext, 1)); // your thing to get player id
new money = strval(GetToken(cmdtext, 2)); // your thing to get amount of money
if(IsPlayerConnected(targetid))
{
CanAcceptMoney[targetid] = 1;
MoneyAmount[targetid] = money;
SendClientMessage(targetid, -1, "Someone is sending you money! Type /acceptmoney to accept the money");
return 1;
}
}
if(strcmp(cmdtext, "/acceptmoney") == 0)
{
if(CanAcceptMoney[playerid] == 1)
{
GivePlayerMoney(playerid, MoneyAmoun[playerid]);
CanAcceptMoney[playerid] = 0;
return 1;
}
}
return 0;
}
Re: /AcceptMoney command. -
OleKristian95 - 30.07.2012
Yes but could you make the command in zcmd?
Re: /AcceptMoney command. -
SEnergy - 30.07.2012
Quote:
Originally Posted by OleKristian95
Yes but could you make the command in zcmd?
|
sorry I've never before used zcmd, only this what I showed you :X
Re: /AcceptMoney command. -
OleKristian95 - 30.07.2012
Ok thanks anyway, I'll try figure out how to do it myself