Flaker Posted January 17, 2012 Share Posted January 17, 2012 (edited) Довольно сложная проблемма (imho). (Zombie server) Суть: 1.Убил зомби > 2.получил 15$ > 3.Накопил 200$ > 4.Пошел в магаз, купил пушку потратил 200$ > 5.Убил зомби > 6.Получил 15$ Проблемма: В 6 пункте, вместо 15 баксов я получаю "кол-во накопленных денег до покупки оружия в магазине" + 15$. Тоесть было у меня 200$, я пошел купил оружие за 200$, затем убил 1 зомби, у меня стало 215$ Скрипты: Скрипт получения денег за убйство 1 зомби: addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",getRootElement(), function (killer) givePlayerMoney(killer,15) end) ______________________ UPDATED*: Серверный скрипт магазина: function shop() weapons_shop1 = createMarker(242,1862,13.1,"cylinder",1.2, 125, 200, 211, 150 ) createBlipAttachedTo ( weapons_shop1, 6 ) weapons_shop2 = createMarker(1059,1269,9.8,"cylinder",1.2, 125, 200, 211, 150 ) createBlipAttachedTo ( weapons_shop2, 6 ) end addEventHandler ("onResourceStart",root,shop) function open_weps_menu(hitElement) if (source == weapons_shop1) or (source == weapons_shop2) then triggerClientEvent (hitElement,"open_weps_shop",getRootElement()) end end addEventHandler ("onMarkerHit",getRootElement(),open_weps_menu) function giveAK () giveWeapon ( source, 30, 80 ) end addEvent ("giveAK",true) addEventHandler ("giveAK",getRootElement(),giveAK) function giveM4 () giveWeapon ( source, 31, 80 ) end addEvent ("giveM4",true) addEventHandler ("giveM4",getRootElement(),giveM4) function giveDgl () giveWeapon ( source, 24, 100 ) end addEvent ("giveDgl",true) addEventHandler ("giveDgl",getRootElement(),giveDgl) function givePistol () giveWeapon ( source, 22, 120 ) end addEvent ("givePistol",true) addEventHandler ("givePistol",getRootElement(),givePistol) function giveSclienced () giveWeapon ( source, 23, 90 ) end addEvent ("giveSclienced",true) addEventHandler ("giveSclienced",getRootElement(),giveSclienced) function giveUzi () giveWeapon ( source, 28, 90 ) end addEvent ("giveUzi",true) addEventHandler ("giveUzi",getRootElement(),giveUzi) Клиентский скрипт магазина: function open_weps_shop() wdwWeaponsShop = guiCreateWindow(0.3106,0.2787,0.376,0.4506,"Weapon Shop",true) btnM4 = guiCreateButton(0.0286,0.3121,0.2494,0.104,"M4 $500",true,wdwWeaponsShop) btnAK = guiCreateButton(0.3636,0.3121,0.2494,0.104,"AK47 $500",true,wdwWeaponsShop) btnDgl = guiCreateButton(0.7117,0.3121,0.2494,0.104,"Deagle $300",true,wdwWeaponsShop) guiCreateStaticImage(0.0649,0.4711,0.161,0.1879,"images/pistol.png",true,wdwWeaponsShop) btnPistol = guiCreateButton(0.0286,0.6792,0.2494,0.104,"Pistol $150",true,wdwWeaponsShop) guiCreateStaticImage(0.4052,0.4769,0.1532,0.185,"images/silenced.png",true,wdwWeaponsShop) btnSclienced = guiCreateButton(0.361,0.6792,0.2494,0.104,"Sclienced $200",true,wdwWeaponsShop) guiCreateStaticImage(0.7636,0.4769,0.1532,0.185,"images/uzi.png",true,wdwWeaponsShop) btnUzi = guiCreateButton(0.7091,0.6792,0.2494,0.104,"UZI $350",true,wdwWeaponsShop) btnExit = guiCreateButton(0.3844,0.8382,0.2052,0.1098,"Exit",true,wdwWeaponsShop) guiSetFont(btnExit,"default-bold-small") guiCreateStaticImage(0.0675,0.1069,0.161,0.185,"images/M4.png",true,wdwWeaponsShop) guiCreateStaticImage(0.413,0.1069,0.1481,0.185,"images/AK-47.png",true,wdwWeaponsShop) guiCreateStaticImage(0.761,0.1012,0.1481,0.1792,"images/deagle.png",true,wdwWeaponsShop) showCursor (true) end addEvent ("open_weps_shop",true) addEventHandler ("open_weps_shop",getResourceRootElement(getThisResource()),open_weps_shop) function planeDestroyPlaneGUI() destroyElement(wdwWeaponsShop) wdwWeaponsShop = false showCursor (false) end function buy() money = getPlayerMoney (source) if source == btnAK and (money >= 500) then triggerServerEvent ("giveAK",getLocalPlayer()) takePlayerMoney(500) outputChatBox ("You bought a AKA $500",225,225,0) elseif source == btnAK and (money < 500) then outputChatBox ("You haven't money",225,225,0) end if source == btnM4 and (money >= 500) then triggerServerEvent ("giveM4",getLocalPlayer()) takePlayerMoney(500) outputChatBox ("You bought a M4 $500",225,225,0) elseif source == btnM4 and (money < 500) then outputChatBox ("You haven't money",225,225,0) end if source == btnDgl and (money >= 300) then triggerServerEvent ("giveDgl",getLocalPlayer()) takePlayerMoney(300) outputChatBox ("You bought a Deagle $300",225,225,0) elseif source == btnDgl and (money < 300) then outputChatBox ("You haven't money",225,225,0) end if source == btnPistol and (money >= 150) then triggerServerEvent ("givePistol",getLocalPlayer()) takePlayerMoney(150) outputChatBox ("You bought a Pistol $150",225,225,0) elseif source == btnPistol and (money < 150) then outputChatBox ("You haven't money",225,225,0) end if source == btnSclienced and (money >= 200) then triggerServerEvent ("giveSclienced",getLocalPlayer()) takePlayerMoney(200) outputChatBox ("You bought a Sclienced $200",225,225,0) elseif source == btnSclienced and (money < 200) then outputChatBox ("You haven't money",225,225,0) end if source == btnUzi and (money >= 350) then triggerServerEvent ("giveUzi",getLocalPlayer()) takePlayerMoney(350) outputChatBox ("You bought a Uzi $350",225,225,0) elseif source == btnUzi and (money < 350) then outputChatBox ("You haven't money",225,225,0) end if source == btnExit then destroyElement(wdwWeaponsShop) wdwWeaponsShop = false showCursor (false) end end addEventHandler("onClientGUIClick",getRootElement(),buy) Edited January 17, 2012 by Guest Link to comment
DakiLLa Posted January 17, 2012 Share Posted January 17, 2012 Данный код, случаем, не на клиентской стороне выполняется? Link to comment
MX_Master Posted January 17, 2012 Share Posted January 17, 2012 Название темы понравилось, зато честно (: Код все равно ни о чем не говорит. Link to comment
Flaker Posted January 17, 2012 Author Share Posted January 17, 2012 Данный код, случаем, не на клиентской стороне выполняется? На сервере!Могу код магазина выложить или еще что то. Я просто даже не представляю как это справить(( Link to comment
MX_Master Posted January 17, 2012 Share Posted January 17, 2012 ну мы же не можем сказать, что в коде не так, если код мы не видели (: Link to comment
Flaker Posted January 17, 2012 Author Share Posted January 17, 2012 Я выложил скрипты магазина... Незнаю что еще можно выложить. Link to comment
Scripting Moderators Sarrum Posted January 17, 2012 Scripting Moderators Share Posted January 17, 2012 takePlayerMoney выполняется на клиенте. Думаю стоит попробовать перенести его на серверную часть. Link to comment
Flaker Posted January 17, 2012 Author Share Posted January 17, 2012 Еще одна заминочка( Я попробовал перенести takePlayerMoney примерно вот так: function giveDgl (thePlayer) giveWeapon ( source, 24, 100 ) takePlayerMoney ( thePlayer, 300) end addEvent ("giveDgl",true) addEventHandler ("giveDgl",getRootElement(),giveDgl) Но натолкнулся на такую проблемму: При нажатии кнопки "покупка" деньги не снимаються, а в консоли выдает такую ошибку: Поправимо? Link to comment
DakiLLa Posted January 17, 2012 Share Posted January 17, 2012 function giveDgl () giveWeapon ( source, 24, 100 ) takePlayerMoney ( source, 300) end addEvent ("giveDgl",true) addEventHandler ("giveDgl",getRootElement(),giveDgl) Link to comment
Flaker Posted January 17, 2012 Author Share Posted January 17, 2012 Спасибо большое) Поставил, все заработало как надо) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now