Ruga Posted April 6, 2013 Share Posted April 6, 2013 (edited) вообщем как назначить клик на объект, при этом на определенный, тоесть код выполняется на клик по любому элементу машинам игрокам и тп. ругается на getElementType ( clickedElement ) 1 арг а что назначить?.. вообщем прошу объясните, тольео сегодня нашел функцию, решил сделать, но вот : function elementClicked( Button, State, source,clickedElement ) local ob = createPed ( 120, 2823.5195,972.787, 10.75 ) if Button == "left" and State == "down" then if getElementType ( clickedElement ) == "ob" then if tonumber( getElementData ( source, "work" )) == 5 then triggerClientEvent ( source, "showTrailerStartWork", source ) end end else outputChatBox("----------",source,50,100,50) end end addEventHandler( "onElementClicked", getRootElement(), elementClicked ) Edited April 7, 2013 by Guest Link to comment
TheNormalnij Posted April 6, 2013 Share Posted April 6, 2013 ну, нафигачил. function elementClicked( Button, State, ==> ThePlayer <== ) sourse - это источник события, в данном случае это элеиент на который клиннул игрок. local ob = createPed ( 120, 2823.5195,972.787, 10.75 ) если ты хотел, чтобы просматривался клик по педу, то надо было педа до этого кода создать PS не в локальную переменную, если он создается в функции. if getElementType ( clickedElement ) == "ob" then ну, даже если ты хотел проверить тот ли это элемент, то надо было if source == ob then или ты хотел проверить, что это объект if getElementType ( source) == "object" then ну и разные if можно в один всунуть Link to comment
Ruga Posted April 7, 2013 Author Share Posted April 7, 2013 стыдно(((( просто я хотел что бы объяснили как работает эта функция немного подумал почитал)) все получилось)) спасибо, вот так записал = po1 = createObject ( 1337, 2840.7246,901.01,10.75,0 ) function elementClicked( theButton, theState, thePlayer) poi = getElementData(thePlayer, "work") if theButton == "left" and theState == "down" then if source == po1 then if poi == 5 then outputChatBox ( "Едем?", 255, 0, 0 ) triggerClientEvent(thePlayer,"showTrailerStartWork",thePlayer) end end end end addEventHandler( "onElementClicked", getRootElement(), elementClicked ) Link to comment
TheNormalnij Posted April 7, 2013 Share Posted April 7, 2013 Sorry, если слишком грубо вышло. Хмм... outputChatBox ( "Едем?", 255, 0, 0 ) Получилось, что в серверном скрипте клиентский синтаксис. Даже если это работает, то отправляет всем, что, наверное, не нужно тебе. outputChatBox ( "Едем?", ==> thePlayer <==, 255, 0, 0 ) Link to comment
Ruga Posted April 7, 2013 Author Share Posted April 7, 2013 я знаю, просто черновик писать не стал как следует)) но спасибо за советы)) Link to comment
Ruga Posted April 7, 2013 Author Share Posted April 7, 2013 вот такой вопрос возник каким образом можно сделать триггер? я реально не знаю, пробывал но не вышло, на setPedAnimation, подскажите какие елементы в тригере ставить? function onClientPlayerWeaponFireС(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if weapon == 22 and getElementType(hitElement) == "player" then setPedAnimation( hitElement, "CRACK", "crckdeth2",15000, true, false, true, false) outputChatBox ( "", 255, 0, 0 ) end end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireС ) 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