Search the Community
Showing results for tags 'shop system'.
-
Hi, I have a problem with a script currently it accepts an elementdata as its currency. local currency_item = "zombieskilled"; if (guiGridListGetSelectedItem(shop_gui.gridlist[2] ) == -1) then guiSetText(shop_gui.label[4],"Please select an item") guiLabelSetColor (shop_gui.label[4],255,0,0) else if (shop_marker_type == "supply") then local target = localPlayer; local item = guiGridListGetItemText(shop_gui.gridlist[2], guiGridListGetSelectedItem(shop_gui.gridlist[2]),1) local amount,price,itemdata = unpack(guiGridListGetItemData(shop_gui.gridlist[2], guiGridListGetSelectedItem(shop_gui.gridlist[2]),2)) guiLabelSetColor(shop_gui.label[4],255,0,0) if (getElementData(localPlayer, currency_item) >= price) then guiSetText(shop_gui.label[4],"You successfully bought "..item..".") guiLabelSetColor (shop_gui.label[4],0,149,14,255) triggerServerEvent("DayZPH:onClientSuccessBuysItem",localPlayer,target,itemdata,currency_item,amount,price) else guiSetText(shop_gui.label[4],"You don't have enough money (PHP) to buy utilities") end elseif (shop_marker_type == "vehicle") then local target = localPlayer; local vehicleName = guiGridListGetItemText(shop_gui.gridlist[2], guiGridListGetSelectedItem(shop_gui.gridlist[2]),1) local id,engine,rotor,tires,tankparts,scrap,slots,fuel,price = unpack(guiGridListGetItemData(shop_gui.gridlist[2],guiGridListGetSelectedItem(shop_gui.gridlist[2]),1)) local x,y,z,rx,ry,rz = unpack(vehicle_spawn_position) guiLabelSetColor(shop_gui.label[4],255,0,0) if (getElementData(localPlayer,currency_item) >= price) then for i,v in ipairs(getElementsWithinColShape(vehicle_spawn_position_col[shop_marker],"vehicle")) do guiSetText(shop_gui.label[4],"Vehicle spawn area is taken, clear it before buying vehicle.") return end guiSetVisible(shop_gui.window[1],false) showCursor(false) outputChatBox("You successfully bought "..vehicleName..".",0,255,0) triggerServerEvent("DayZPH:onClientSuccessBuysVehicle",localPlayer,target,currency_item,price,x,y,z,rx,ry,rz,id,engine,rotor,tires,tankparts,scrap,slots,fuel) else guiSetText(shop_gui.label[4], "You don't have enough money (PHP) to buy a car") end end end server side function onClientSuccessBuysItem(target,item,currency,amount,price) setElementData(target,item,getElementData(target,item)+amount) setElementData(target,currency,getElementData(target,currency)-price) end addEvent("DayZPH:onClientSuccessBuysItem",true) addEventHandler("DayZPH:onClientSuccessBuysItem",getRootElement(),onClientSuccessBuysItem) addEventHandler("onPlayerLogin",root,function() triggerClientEvent(source,"load_shop",source); end); I tried changing the variable to currency_item = getPlayerMoney(source); but I don't see it working. anything I'm missing? Please assist me