26.03.2016, 09:41
Hi Mecent, thanks it's fixed already, how about this? can you make work this also?
PHP код:
CMD:accept(playerid, params[])
{
if(Player[playerid][Admin] >= 1)
{
SendClientMessage(playerid,COLOR_WHITE, "Administrators can't use this command.");
return 1;
}
new string[145];
//new sendername[MAX_PLAYER_NAME];
//new giveplayer[MAX_PLAYER_NAME];
new material[2];
if(IsPlayerConnected(playerid))
{
if(isnull(params))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /accept [name]");
SendClientMessage(playerid, COLOR_GREY, "Available Names: Mats");
return 1;
}
else if(strcmp(params,"mats",true) == 0)
{
if(MatsOffer[playerid] < 999)
{
if(GetPlayerMoney(playerid) >= MatsPrice[playerid])
{
if(IsPlayerConnected(MatsOffer[playerid]))
{
if(GetPVarInt(playerid, "SellMatsTimer") > 0)
{
format(string, sizeof(string), "You must wait %d seconds before accepting materials.", GetPVarInt(playerid, "SellMatsTimer"));
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}
if (Player[MatsOffer[playerid]][MatsA] < MatsAmount[playerid])
{
SendClientMessage(playerid,COLOR_GREY, "That player does not have that amount of materials anymore!");
return 1;
}
else if (Player[MatsOffer[playerid]][MatsB] < MatsAmount[playerid])
{
SendClientMessage(playerid,COLOR_GREY, "That player does not have that amount of materials anymore!");
return 1;
}
else if (Player[MatsOffer[playerid]][MatsC] < MatsAmount[playerid])
{
SendClientMessage(playerid,COLOR_GREY, "That player does not have that amount of materials anymore!");
return 1;
}
format(string, sizeof(string), "* You bought %d class %s materials for $%d from %s.", MatsAmount[playerid], material, MatsPrice[playerid], GetName(MatsOffer[playerid]));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s has bought your %d class %s materials, the $%d was added to your money.", GetName(playerid), MatsAmount[playerid], material, MatsPrice[playerid]);
SendClientMessage(MatsOffer[playerid], COLOR_LIGHTBLUE, string);
GivePlayerMoney(MatsOffer[playerid], MatsPrice[playerid]);
GivePlayerMoney(playerid, -MatsPrice[playerid]);
if (strcmp(material, "A", true))
{
Player[playerid][MatsA] += MatsAmount[playerid];
Player[MatsOffer[playerid]][MatsA] -= MatsAmount[playerid];
}
else if (strcmp(material, "B", true))
{
Player[playerid][MatsB] += MatsAmount[playerid];
Player[MatsOffer[playerid]][MatsB] -= MatsAmount[playerid];
}
else if (strcmp(material, "C", true))
{
Player[playerid][MatsC] += MatsAmount[playerid];
Player[MatsOffer[playerid]][MatsC] -= MatsAmount[playerid];
}
MatsOffer[playerid] = 999;
MatsPrice[playerid] = 0;
MatsType[playerid] = 0;
MatsAmount[playerid] = 0;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You can't afford those materials!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "No-one offered you any materials!");
return 1;
}
}
}
return 1;
}