Hallo, wieso wird kein Geld abgezogen? (vio-lite)
Lua
addCommandHandler("buyhouse", function(thePlayer)
if(getElementData(thePlayer, "house:lastvisit")) and (getElementData(thePlayer, "house:lastvisit") ~= false) then
local house = getElementData(thePlayer, "house:lastvisit")
if(house) then
local id = house
local owner = houseData[id]["OWNER"]
if(owner ~= "no-one") then
outputChatBox("Du kannst dieses Haus nicht kaufen!", thePlayer, 255, 0, 0)
else
local houses = 0
for index, col in pairs(getElementsByType("colshape")) do
if(getElementData(col, "house") == true) and (houseData[getElementData(col, "ID")]["OWNER"] == getPlayerName(thePlayer)) then
houses = houses+1
if(houses == max_player_houses) then
outputChatBox("Du hast bereits "..max_player_houses.." Haeuser! Verkaufe davor ein Haus!", thePlayer, 255, 0, 0)
return
end
end
end
local money = vioGetElementData ( player, "money" )
local price = houseData[id]["PRICE"]
if(money < price) then outputChatBox("Du hast nicht genug Geld! Du brauchst noch "..(price-money).."$!", thePlayer, 255, 0, 0) return end
setHouseData(id, "OWNER", getPlayerName(thePlayer))
takePlayerMoney ( player, -price )
outputChatBox("Glueckwunsch! Du hast das Haus gekauft!", thePlayer, 0, 255, 0)
triggerClientEvent ( player, "achievsound", getRootElement() )
setElementModel(houseData[id]["PICKUP"], 1272)
setElementModel(houseData[id]["BLIP"], 32)
end
end
end
end)
Alles anzeigen