21.03.2015, 11:30
Hello guys, I wondered if you could help me out with this one.
If I have a charge command and there I need to insert "/charge [playerid] [charge money] [reason]"
Is there any way to make a command that will automatically calculate 10% of players money (from bank) instead of charging with the inserted amount of money.
Example: If I insert "/charge [playerid] [percent money] [reason]" and if I insert 10%, can it check players money and if the player has 100.000$ on bank, he gets charged with 10.000$?
This is my /charge command. Please help me create this command.
Thanks in advance.
If I have a charge command and there I need to insert "/charge [playerid] [charge money] [reason]"
Is there any way to make a command that will automatically calculate 10% of players money (from bank) instead of charging with the inserted amount of money.
Example: If I insert "/charge [playerid] [percent money] [reason]" and if I insert 10%, can it check players money and if the player has 100.000$ on bank, he gets charged with 10.000$?
This is my /charge command. Please help me create this command.
pawn Код:
if(strcmp(cmd, "/charge", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /charge [Playerid/PartOfName] [money] [reason]");
return 1;
}
new playa;
new money;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
money = strvalEx(tmp);
if(money < 1)
{
SendClientMessage(playerid, COLOR_GREY, "The price shouldn't be less than 1$");
return 1;
}
if (PlayerInfo[playerid][pAdmin] >= 2)
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /charge [Playerid/PartOfName] [money] [reason]");
return 1;
}
if (!GetPVarInt(giveplayerid, "gPlayerLogged"))
{
SendClientMessage(playerid, COLOR_RED, "The player is not connected.");
return 1;
}
new year, month,day;
getdate(year, month, day);
format(string, sizeof(string), "AdmCmd: %s has punished %s with %d$, reason: %s (%d-%d-%d)", sendername, giveplayer, money, (result) ,month, day, year);
ChargeLog(string);
format(string, sizeof(string), "AdmCmd: %s has punished %s with %d$, reason: %s", sendername, giveplayer, money, (result));
SendClientMessageToAll(COLOR_LIGHTRED, string);
SafeGivePlayerMoney(playa, -money);
return 1;
}
}
}
else
SendClientMessage(playerid, COLOR_RED, "The player is not connected!");
}
return 1;
}