Advertisement
N1E7R4V

Untitled

Apr 23rd, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.45 KB | None | 0 0
  1. function CMD_Accept(playerid)
  2.     if Player[playerid].propozycja == true then
  3.         local vendor = Player[playerid].gVendor
  4.         local cost = Player[vendor].gCost
  5.         local enteredAmount = Player[vendor].gAmount
  6.         local distance = GetDistancePlayers(playerid, vendor)
  7.         local money = Player[playerid].bank
  8.         if distance <= 1200 then
  9.             if money >= cost then
  10.                 Player[playerid].propozycja = false
  11.                 GiveItem(playerid, Player[vendor].item, enteredAmount);
  12.                 --RemoveItemBySlot(vendor, Player[vendor].gSlot, enteredAmount)
  13.                 --RemoveItemBySlot(playerid,slot,Player[playerid].amount_drop);
  14.     RemoveItemBySlot(vendor, Player[vendor].gSlot, enteredAmount);
  15.     local newValue = enteredAmount - Player[vendor].gAmount;--HEH
  16.     if newValue < 0 then
  17.         newValue = 0;
  18.     end
  19.    
  20.     local file = io.open("Items/"..GetPlayerName(vendor)..".txt","r+");
  21.     local tempString = file:read("*a");
  22.     file:close();
  23.     local tempString = string.gsub(tempString,string.upper(Player[vendor].item).." "..enteredAmount,string.upper(Player[vendor].item).." "..newValue);
  24.     local file = io.open("Items/"..GetPlayerName(vendor)..".txt","w+");
  25.     file:write(tempString);
  26.     file:close();--HEH
  27.                 --
  28.                 if Player[playerid].ReplyTimer ~= -1 then
  29.                     KillTimer(Player[playerid].ReplyTimer)
  30.                 end
  31.                 if cost > 0 then
  32.                     Player[vendor].bank = Player[vendor].bank + cost
  33.                     Player[playerid].bank = Player[playerid].bank - cost
  34.                 end
  35.                 SendPlayerMessage(vendor,0,191,255,"(ТОРГОВЛЯ): Вы продали "..Player[vendor].item.." игроку "..GetPlayerName(playerid).." за "..cost.." кусков руды")
  36.                 SendPlayerMessage(playerid,0,191,255,"(ТОРГОВЛЯ): Вы купили "..Player[vendor].item.." у игрока "..GetPlayerName(vendor).." за "..cost.." кусков руды")
  37.                 local name = GetPlayerName(playerid)
  38.                 --====
  39.             else
  40.                 Player[playerid].propozycja = false
  41.                 SendPlayerMessage(vendor,0,191,255,"(ТОРГОВЛЯ): Игроку "..GetPlayerName(playerid).." не хватает кусков руды для покупки.")
  42.                 SendPlayerMessage(playerid,0,191,255,"(ТОРГОВЛЯ): Не хватает кусков руды для покупки "..Player[vendor].item..".")
  43.             end
  44.         else
  45.             SendPlayerMessage(playerid,0,191,255,"(ТОРГОВЛЯ): Слишком далеко от "..GetPlayerName(vendor).."!")
  46.         end
  47.     else
  48.         SendPlayerMessage(playerid,0,191,255,"(ТОРГОВЛЯ): Никто ничего не предлагал!")
  49.     end
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement