Код:
dcmd_givecash(playerid, params[])
{
new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
new targetid = strval(tmp);
new NewMoney = strval(tmp2);
if (!Player[playerid][HasSpawnedYet])
{
SendClientMessage(playerid, RED, "You can't use that command when you're dead.");
return 1;
}
if (NewMoney == 0)
{
SendClientMessage(playerid, RED, "Usage: '/gc [PlayerID] [Amount]'");
return 1;
}
if (NewMoney < 1 || NewMoney > 1000000)
{
SendClientMessage(playerid, RED, "You can give up to a maximum $1000000, and a minimum of $1.");
return 1;
}
if (!IsPlayerConnected(targetid))
{
format(myString, sizeof(myString), "%i is not a valid player.", targetid);
SendClientMessage(playerid, RED, myString);
return 1;
}
GetPlayerName(playerid, playerName, sizeof(playerName));
GetPlayerName(targetid, targetName, sizeof(targetName));
if (GetPlayerMoney(playerid) < NewMoney)
{
format(myString, sizeof(myString), "You can't afford to give $%i to %s (%i).", NewMoney, targetName, targetid);
SendClientMessage(playerid, RED, myString);
return 1;
}
GivePlayerMoney(playerid, -NewMoney);
GivePlayerMoney(targetid, NewMoney);
format(myString, sizeof(myString), "You have given $%i to %s (%i).", NewMoney, targetName, targetid);
SendClientMessage(playerid, GREEN, myString);
format(myString, sizeof(myString), "%s (%i) has given you $%i.", playerName, playerid, NewMoney);
SendClientMessage(targetid, GREEN, myString);
dUserSetINT(PlayerName(playerid)).("money",GetPlayerMoney(playerid));
dUserSetINT(PlayerName(targetid)).("money",GetPlayerMoney(targetid));
Player[playerid][TypedSpawn] = true;
return 1;
}
dcmd_gc(playerid, params[])
{
new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
new targetid = strval(tmp);
new NewMoney = strval(tmp2);
if (!Player[playerid][HasSpawnedYet])
{
SendClientMessage(playerid, RED, "You can't use that command when you're dead.");
return 1;
}
if (playerid == targetid)
{
SendClientMessage(playerid, RED, "You can't give money to yourself.");
return 1;
}
if (NewMoney == 0)
{
SendClientMessage(playerid, RED, "Usage: '/gc [PlayerID] [Amount]'");
return 1;
}
if (NewMoney < 1 || NewMoney > 1000000)
{
SendClientMessage(playerid, RED, "You can give up to a maximum $1000000, and a minimum of $1.");
return 1;
}
if (!IsPlayerConnected(targetid))
{
format(myString, sizeof(myString), "%i is not a valid player.", targetid);
SendClientMessage(playerid, RED, myString);
return 1;
}
GetPlayerName(playerid, playerName, sizeof(playerName));
GetPlayerName(targetid, targetName, sizeof(targetName));
if (GetPlayerMoney(playerid) < NewMoney)
{
format(myString, sizeof(myString), "You can't afford to give $%i to %s (%i).", NewMoney, targetName, targetid);
SendClientMessage(playerid, RED, myString);
return 1;
}
GivePlayerMoney(playerid, -NewMoney);
GivePlayerMoney(targetid, NewMoney);
format(myString, sizeof(myString), "You have given $%i to %s (%i).", NewMoney, targetName, targetid);
SendClientMessage(playerid, GREEN, myString);
format(myString, sizeof(myString), "%s (%i) has given you $%i.", playerName, playerid, NewMoney);
SendClientMessage(targetid, GREEN, myString);
dUserSetINT(PlayerName(playerid)).("money",GetPlayerMoney(playerid));
dUserSetINT(PlayerName(targetid)).("money",GetPlayerMoney(targetid));
Player[playerid][TypedSpawn] = true;
return 1;
}
I am not sure about the report command tho so sorry for that but I hope this helps!