-
Posts
4,121 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Kenix
-
#DaMiAnO,Show your meta.xml If you use my code you need type /repair and you can use bind 2.
-
He have not defined variables: TNSmemo,EditPasswordRegister,LoginWi,LblRegisterEmail
-
dxDrawText must be in onClientRender event because it needs to be rendered every time. Client-side: local screenWidth, screenHeight = guiGetScreenSize() local visible = false function repairVehicle() local theVehicle = getPedOccupiedVehicle(localPlayer) if(theVehicle) then fixVehicle(theVehicle) dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements else dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements end end bindKey('f2','down', function() if visible then removeEventHandler('onClientRender',root,repairVehicle) else addEventHandler('onClientRender',root,repairVehicle) setTimer( function() removeEventHandler('onClientRender',root,repairVehicle) end, 3000,1) end end ) Why add command to bind key to repair the vehicle?
-
He have syntax error i said. In your code have syntax error. In my no. sckatchof,test my code.
-
Client local screenWidth, screenHeight = guiGetScreenSize( ) local timer local function draw( ) local theVehicle = getPedOccupiedVehicle( localPlayer ) if theVehicle then dxDrawText( "Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false ) else dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false ) end end function repairVehicle( ) local theVehicle = getPedOccupiedVehicle( localPlayer ) if theVehicle then fixVehicle( theVehicle ) end end function bindKeyForRepair( ) bindKey( "2", "down", repairVehicle ) addEventHandler( 'onClientRender',root,draw ) timer = setTimer( function( ) removeEventHandler( 'onClientRender',root,draw ) unbindKey( "2", "down", repairVehicle ) end, 3000, 1 ) end addCommandHandler( "repair", bindKeyForRepair ) Analysis of the code local screenWidth, screenHeight = guiGetScreenSize() function repairVehicle() local theVehicle = getPedOccupiedVehicle(source) -- source is source in event ( you need use localPlayer in this situation ) if(theVehicle) then fixVehicle(theVehicle) repair = dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) setTimer(RemoveDrawText, 3000, 1, repair) else repair2 = dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) setTimer(RemoveDrawText, 3000, 1, repair2) end end function RemoveDrawText(repair, repair2) destroyElement(repair) destroyElement(repair2) end function bindKeyForRepair(source) -- source argument only in server side bindKey(source, "2", "down", repairVehicle) -- source argument only in server side end addCommandHandler("repair", bindKeyForRepair) dxDrawText not return element. And you need draw text only in render.
-
screenWidth,screenHeight = guiGetScreenSize() LoginWin = guiCreateWindow(screenWidth/2-mainWidth/2,screenHeight/2-mainHeight/2,mainWidth,mainHeight,"TNS Login Panel",false) guiSetAlpha(LoginWin,1) guiWindowSetSizable(LoginWin,false) guiSetVisible(LoginWin, false) guiLabelSetColor(label,0,255,0) Labelusername = guiCreateLabel(18,42,67,22,"Username :",false,LoginWin) Labelpassword = guiCreateLabel(18,86,65,22,"Password :",false,LoginWin) LoginUsername = guiCreateEdit(96,37,237,30,"",false,LoginWin) guiSetAlpha(LoginUsername,1) guiEditSetMaxLength(LoginUsername, 50) LoginPassword = guiCreateEdit(96,80,237,30,"",false,LoginWin) guiEditSetMasked(LoginPassword, true) guiEditSetMaxLength(LoginPassword, 50) guiEditSetMasked(LoginPassword,true) BtnAction = guiCreateButton(16,159,112,33,"Login",false,LoginWin) buttonRegister = guiCreateButton(143,159,127,33,"Create an Account",false,LoginWin) guiMemoSetReadOnly( TNSmemo,true,LoginWin) line = guiCreateLabel(43,199,438,25,"__________________________________________________________________",false,LoginWin) RegisterWindow = guiCreateWindow(376,162,447,396,"Create an Account",false) guiWindowSetSizable(RegisterWindow,false) LabelUsername = guiCreateLabel(12,39,72,27,"Username :",false,RegisterWindow) LabelPassword = guiCreateLabel(12,82,72,27,"Password :",false,RegisterWindow) EditRegisterUsername = guiCreateEdit(81,38,191,26,"",false,RegisterWindow) EditRegisterPassword = guiCreateEdit(81,78,191,26,"",false,RegisterWindow) guiEditSetMaxLength(EditPasswordRegister,9) guiEditSetMasked(EditPasswordRegister,true) EditPasswordConfirmation = guiCreateEdit(124,117,178,27,"",false,RegisterWindow) guiEditSetMaxLength(EditPasswordConfirmation,9) guiEditSetMasked(EditPasswordConfirmation,true) labelconfi = guiCreateLabel(12,123,109,27,"Confirm Password :",false,RegisterWindow) labelconfirpassword = guiCreateLabel(307,122,132,16,"Confitm yout password",false,RegisterWindow) guiLabelSetColor(labelconfirpassword,0,255,0) labesnas = guiCreateLabel(26,171,393,20,"Make sure your password can not be guessed. If somebody hacks your ",false,RegisterWindow) info = guiCreateLabel(26,191,411,24,"account you should have kept you password secure.",false,RegisterWindow) infoaccount = guiCreateLabel(9,231,130,30,"Account confirmation",false,RegisterWindow) guiSetFont(infoaccount ,"default-bold-small") Labelemail = guiCreateLabel(9,264,57,22,"E-mail :",false,RegisterWindow) EditRegisterEmail = guiCreateEdit(54,259,191,26,"",false,RegisterWindow) LabelEmail = guiCreateLabel(257,263,132,16,"Enter yout email",false,RegisterWindow) ButtonRegister = guiCreateButton(9,347,124,37,"Create my account",false,RegisterWindow) ButtonClose = guiCreateButton(311,347,124,37,"Close",false,RegisterWindow) addEventHandler("onClientResourceStart", resourceRoot, function () guiSetVisible(LoginWi, true) guiSetVisible(RegisterWindow, false) showCursor(true) guiSetInputEnabled(true) end ) function onClickBtn(button, state) if(button == "left" and state == "up") then if (source == BtnAction) then username = guiGetText(LoginUsername) password = guiGetText(LoginPassword) triggerServerEvent("onLogin", getRootElement(), localPlayer, username, password) else triggerServerEvent("onRegister", getRootElement(), localPlayer, guiGetText(EditRegisterUsername), guiGetText(EditRegisterPassword), guiGetText(EditRegisterEmail)) end end end addEventHandler("onClientGUIClick", BtnAction, onClickBtn, false) ----- Open registration window function onClickRegisterToggle(button,state) if(button == "left" and state == "up") then if (source == buttonRegister) then guiSetVisible(registerWindow, true) guiSetVisible(LoginWin, false) guiBringToFront(registerWindow) guiSetInputEnabled(true) showCursor(true) end end end addEventHandler("onClientGUIClick",btnToggleRegister,onClickRegisterToggle) ------ Cancel registration function onClickCancel(button,state) if(button == "left" and state == "up") then if (source == ButtonClose) then guiSetVisible(LoginWin, true) guiSetVisible(registerWindow, false) guiSetInputEnabled(true) showCursor(true) end end end addEventHandler("onClientGUIClick",ButtonClose,onClickCancel) ---- Show Login function showLoginWindow() guiSetVisible(LoginWin, true) guiSetVisible(registerWindow, false) guiSetInputEnabled(true) showCursor(true) end addEvent("showLoginWindow", true) addEventHandler("showLoginWindow",getRootElement(),showLoginWindow) function hideRegisterWindow() guiSetInputEnabled(true) guiSetVisible(LoginWin, true) guiSetVisible(registerWindow, false) showCursor(true) end addEvent("hideRegisterWindow", true) addEventHandler("hideRegisterWindow", getRootElement(), hideRegisterWindow) local localPlayer = getLocalPlayer() function receiveVars( allow, email) local playername = getPlayerName(localPlayer) guiSetText(LoginUsername, "") guiSetText(EditRegisterUsername, "") if (email == "false") then guiSetVisible(LblRegisterEmail, false) guiSetVisible(EditRegisterEmail, false) end if (allow == "false") then end guiSetText(LoginUsername, playername) guiSetText(EditRegisterUsername, playername) guiSetVisible(LoginWin, true) guiBringToFront(LoginWin) guiSetInputEnabled(true) showCursor(true) end addEvent( "onSendVars", true ) addEventHandler( "onSendVars", getRootElement(), receiveVars ) function windowHandler() triggerServerEvent("onNeedVars", getLocalPlayer()) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler) Syntax error Use /debugscript 3 please!
-
Перед тем, как выложить код, лучше всего пройтись по этим пунктам: Стандарт оформления кода Наличие общего стиля программирования облегчает понимание исходного кода. Внутри любых управляющих конструкций операторы следует располагать с отступом. Бинарные операторы следует обрамлять пробелами. Комментарии Старайтесь комментировать нужные строчки кода.( по вашему мнению ) Это намного упростит его чтение. Объявление переменных, событий, обработчиков Порядок: Это также улучшит чтение кода. Логи Если у вас не работает скрипт, то используйте /debugscript 3 в чате или debugscript 3 в консоли. Также все ошибки будут в логах. Серверный лог: Папка сервера\server\mods\deathmatch\logs\server.log Клиентский лог: Папка клиента\MTA\clientscript.log Не забывайте чистить логи. Логически нерабочий код Если ваш код отказывается работать, ни дебаг сообщений, ни логов нет, то следует проверить каждую строку кода. А именно: Полностью нерабочий код Если ваш код отказывается работать, то возможно ваш код имеет синтаксические ошибки. Лучше всего вшить в вашу текстовую программу дебаггер. Если вы не знаете, как вшить в текстовую программу дебаггер, то лучше всего скачать уже готовую программу с дебаггером: Полностью нерабочий ресурс Если ваш ресурс отказывается работать, то следует проверить meta.xml. Возможно, meta.xml имеет синтаксические ошибки и поэтому ваш ресурс не будет работать в любом случае. Подробнее о meta.xml https://wiki.multitheftauto.com/index.ph ... U/Meta.xml Добавление событий ( addEvent ) Переменные Функции Обработчики событий ( addEventHandler,... ) ( Обработчики - функции, которые обрабатывают события. ) Переменные Условия Возвращаемые значения функций и т.д. Notepad++ viewtopic.php?f=91&t=30077 LuaEdit http://sourceforge.net/projects/luaedit ... t/download MTA Script editor viewtopic.php?t=24834
-
Где вы писали это?
-
I tested now it working. Maybe your resource scoreboard not 'scoreboard' name? Check.
-
Your resource http://www.mediafire.com/?1688nd7y392ab4r blips http://www.mediafire.com/?4balgdl4atx7lgp Just copy to server and run. First.blips Second.Your resource ( customblips ).
-
Try again. Your resource named is scoreboard?( not Scoreboard ?Case sensitive ) Not debug errors?
-
http://imageshack.us/photo/my-images/81 ... 021047.png http://imageshack.us/photo/my-images/29 ... 021058.png
-
Use my code i tested it now. If you in los santos then LS. If in country side then none.
-
exports.scoreboard:addScoreboardColumn( "Zone",root,3,0.15 ) local uTimers = { } local t = { ['Los Santos'] = 'LS'; ['Las Venturas'] = 'LV'; ['San Fierro'] = 'SF'; } function setZoneData( player ) local player = player or source if isTimer( uTimers[ player ] ) then killTimer( uTimers[ player ] ) end uTimers[ player ] = setTimer( function( player ) local playerX, playerY, playerZ = getElementPosition ( player ) local playerZoneName = getZoneName ( playerX, playerY, playerZ,true ) if playerZoneName == 'Los Santos' or playerZoneName == 'Las Venturas' or playerZoneName == 'San Fierro' then playerZoneName = t[ playerZoneName ] else playerZoneName = 'none' end setElementData ( player,"Zone" , playerZoneName ) end, 1000, 0, player ) end addEventHandler( 'onResourceStart',resourceRoot, function( ) for _,v in pairs( getElementsByType 'player' ) do setZoneData( v ) end end ) addEventHandler( 'onPlayerQuit',root, function( ) if isTimer( uTimers[ source ] ) then killTimer( uTimers[ source ] ) end uTimers[ source ] = nil end ) addEventHandler( 'onPlayerJoin',root,setZoneData ) Tested and updated again.
-
exports.scoreboard:addScoreboardColumn( "Zone",root,3,0.15 ) local uTimers = { } function setZoneData( player ) local player = player or source if isTimer( uTimers[ player ] ) then killTimer( uTimers[ player ] ) end uTimers[ player ] = setTimer( function( player ) local playerX, playerY, playerZ = getElementPosition ( player ) local playerZoneName = getZoneName ( playerX, playerY, playerZ,true ) setElementData ( player,"Zone" , playerZoneName ) end, 1000, 0, player ) end addEventHandler( 'onResourceStart',resourceRoot, function( ) for _,v in pairs( getElementsByType 'player' ) do setZoneData( v ) end end ) addEventHandler( 'onPlayerQuit',root, function( ) if isTimer( uTimers[ source ] ) then killTimer( uTimers[ source ] ) end uTimers[ source ] = nil end ) addEventHandler( 'onPlayerJoin',root,setZoneData )
-
I think you need upload to wiki ( update post modules ). And add this links.
-
addEventHandler ( "onClientResourceStart", resourceRoot, function() exports.customblips:createCustomBlip ( 2487.6000976563, -1668.4000244141, 20, 20, "taxi.png" ) end ) Problem found. You not convert your code to utf-8 without bom.And it show errors with syntax.
-
Upload your resource http://www.mediafire.com/
-
You resource blips NOT RUNNING! Type cmd /refresh in chat.( if in console then , no slash ) And start resource. Your resource name blips or customblips?
-
You refresh resources? Restart this resource? See in /debugscript 3? Check folder?(files directory )
-
Not understand you ... It's him code ,maybe he need trigger for all elements in tree. https://wiki.multitheftauto.com/wiki/Element_tree
-
Addation to your code.WolfPire Client Find addEvent("HP",true) addEventHandler("HP",root, function(mVehicle, mTrailer) TruckHP = getElementHealth(mVehicle) TrailerHP = getElementHealth(mTrailer) TruckHP2 = tonumber(TruckHP) TrailerHP2 = tonumber(TrailerHP) TruckHPF = math.ceil(TruckHP2) TrailerHPF = math.ceil(TrailerHP2) end ) function renderHP() truHP = dxDrawText("HP(Truck): " .. tostring(TruckHPF) .. "", sWidth/1.2,sHeight-47, sWidth, sHeight ) traHP = dxDrawText("HP(Trailer): " .. tostring(TrailerHPF) .. "", sWidth/1.2,sHeight-57, sWidth, sHeight ) end Replace local TruckHP,TrailerHP addEvent( "HP",true ) addEventHandler( "HP",root, function( mVehicle, mTrailer ) TruckHP = getElementHealth( mVehicle ) TrailerHP = getElementHealth( mTrailer ) end ) function renderHP( ) if TruckHP and TrailerHP then TruckHPF = math.ceil( TruckHP2 ) TrailerHPF = math.ceil( TrailerHP2 ) dxDrawText( "HP(Truck): " .. tostring( TruckHPF ) .. "", sWidth/1.2,sHeight-47, sWidth, sHeight ) dxDrawText( "HP(Trailer): " .. tostring( TrailerHPF ) .. "", sWidth/1.2,sHeight-57, sWidth, sHeight ) end end Server addEventHandler( 'onVehicleDamage',root, function( ) if source == mVehicle or source == mTrailer then triggerClientEvent( "HP",root,mVehicle,mTrailer ) end end ) addEventHandler( 'onVehicleExplode',root, function( ) if source == mVehicle or source == mTrailer then triggerClientEvent( "HP",root,mVehicle,mTrailer ) end end ) Or i think better create custom element. And in client side loop this elements and check ( getElementHealth ,... ) Like this Server addEvent( "start",true ) addEventHandler( "start",root, function( theElement ) if theElement then local uTrailerElement = createElement( 'uCars','uTrailer' ) local uRootElement = createElement( 'uCars','uRoot' ) mVehicle = createVehicle( 403, -22, -291, 6, 0, 0, 180 ) mTrailer = createVehicle ( 435, -14, -285, 7, 0, 0, 180 ) setElementParent( mVehicle,uRootElement ) setElementParent( mTrailer,uTrailerElement ) --warpPedIntoVehicle( theElement, mVehicle ) warpPedIntoVehicle( theElement, uRootElement ) end end ) Client function renderHP( ) for _,v in pairs( getElementsByType 'uCars' ) then if getElementType( v ) == 'uTrailer' then dxDrawText( "HP(Trailer): " .. tostring( math.floor( getElementHealth( v ) ) ) .. "", sWidth/1.2,sHeight-57, sWidth, sHeight ) end if getElementType( v ) == 'uRoot' then dxDrawText( "HP(Truck): " .. tostring( math.floor( getElementHealth( v ) ) ) .. "", sWidth/1.2,sHeight-47, sWidth, sHeight ) end end end