24.01.2017, 02:05
Код HTML:
CMD:give(playerid, params[])
{
new targetid, type, amount, msg[256];
if(sscanf(params, "us[10]i", targetid, type, amount))
{
if(amount < 1 || amount > 9999999)
{
SendClientMessage(playerid, COLOR_RED, "You have typed an invalid amount.");
return 1;
}
if(targetid == playerid)
{
SendClientMessage(playerid, COLOR_RED, "You cannot give an item to yourself.");
return 1;
}
if(PlayerInfo[playerid][LoggedIn] == false)
{
SendClientMessage(playerid, COLOR_RED, "This player was not found.");
return 1;
}
printf("%s", targetid);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(targetid, X, Y, Z);
if(!IsPlayerInRangeOfPoint(playerid, 5.5, X, Y, Z))
{
SendClientMessage(playerid, COLOR_RED, "You are too far away from this player.");
return 1;
}
if(!strcmp(params, "Pot", true))
{
if(amount > PlayerInfo[playerid][Marijuana])
{
SendClientMessage(playerid, COLOR_RED, "You don't have enough of this item on you.");
return 1;
}
PlayerInfo[playerid][Marijuana] -= amount;
PlayerInfo[targetid][Marijuana] += amount;
format(msg, sizeof(msg), "You gave %s grams of marijuana to %s.", amount, GetPlayerNameEx(targetid));
SendClientMessage(playerid, COLOR_GREEN, msg);
format(msg, sizeof(msg), "You received %s grams of marijuana from %s.", amount, GetPlayerNameEx(playerid));
SendClientMessage(targetid, COLOR_GREEN, msg);
format(msg, sizeof(msg), "* %s hands some marijuana to %s.",GetPlayerNameEx(playerid), GetPlayerNameEx(targetid));
ProxDetector(GetPlayerVirtualWorld(playerid) == 0 ? 20.0 : 7.0, playerid, msg, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "HINT: /give [playerid] [item] [amount]");
SendClientMessage(playerid, COLOR_GREY, "HINT: Items: pot");
}
return 1;
}