Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CMD_Accept(playerid)
- if Player[playerid].propozycja == true then
- local vendor = Player[playerid].gVendor
- local cost = Player[vendor].gCost
- local enteredAmount = Player[vendor].gAmount
- local distance = GetDistancePlayers(playerid, vendor)
- local money = Player[playerid].bank
- if distance <= 1200 then
- if money >= cost then
- Player[playerid].propozycja = false
- GiveItem(playerid, Player[vendor].item, enteredAmount);
- --RemoveItemBySlot(vendor, Player[vendor].gSlot, enteredAmount)
- --RemoveItemBySlot(playerid,slot,Player[playerid].amount_drop);
- RemoveItemBySlot(vendor, Player[vendor].gSlot, enteredAmount);
- local newValue = enteredAmount - Player[vendor].gAmount;--HEH
- if newValue < 0 then
- newValue = 0;
- end
- local file = io.open("Items/"..GetPlayerName(vendor)..".txt","r+");
- local tempString = file:read("*a");
- file:close();
- local tempString = string.gsub(tempString,string.upper(Player[vendor].item).." "..enteredAmount,string.upper(Player[vendor].item).." "..newValue);
- local file = io.open("Items/"..GetPlayerName(vendor)..".txt","w+");
- file:write(tempString);
- file:close();--HEH
- --
- if Player[playerid].ReplyTimer ~= -1 then
- KillTimer(Player[playerid].ReplyTimer)
- end
- if cost > 0 then
- Player[vendor].bank = Player[vendor].bank + cost
- Player[playerid].bank = Player[playerid].bank - cost
- end
- SendPlayerMessage(vendor,0,191,255,"(ТОРГОВЛЯ): Вы продали "..Player[vendor].item.." игроку "..GetPlayerName(playerid).." за "..cost.." кусков руды")
- SendPlayerMessage(playerid,0,191,255,"(ТОРГОВЛЯ): Вы купили "..Player[vendor].item.." у игрока "..GetPlayerName(vendor).." за "..cost.." кусков руды")
- local name = GetPlayerName(playerid)
- --====
- else
- Player[playerid].propozycja = false
- SendPlayerMessage(vendor,0,191,255,"(ТОРГОВЛЯ): Игроку "..GetPlayerName(playerid).." не хватает кусков руды для покупки.")
- SendPlayerMessage(playerid,0,191,255,"(ТОРГОВЛЯ): Не хватает кусков руды для покупки "..Player[vendor].item..".")
- end
- else
- SendPlayerMessage(playerid,0,191,255,"(ТОРГОВЛЯ): Слишком далеко от "..GetPlayerName(vendor).."!")
- end
- else
- SendPlayerMessage(playerid,0,191,255,"(ТОРГОВЛЯ): Никто ничего не предлагал!")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement