-
Posts
4,121 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Kenix
-
t = { 'next'; 'some'; 'etc'; } for i,v in pairs( t ) do if v == 'some' then print ( i,'v == some' ) break end end print 'done' -- some code Output: 2,v == some done I think you understand. You can test this example in lua demo. http://www.lua.org/cgi-bin/demo
-
В чём проблема? Всё можно.
-
Server addEvent( 'giveWeapon',true ) addEventHandler( 'giveWeapon',root, function( ) local Money = getPlayerMoney( source ) local Name = getPlayerName( source) if Money >= 120 then giveWeapon ( source, 29 ) triggerClientEvent ( source, "playSound" , source,'sounds/Buy.mp3' ) outputChatBox ( Name .. "#FF0000Has Bought --- > #00FF00Desert Eagle", root, 255, 255, 255, true ) else triggerClientEvent ( source, "playSound" , source,'sounds/error.mp3' ) outputChatBox( "#ff0000You Dont Have #00ff00$120 To Buy This Weapons", source, root, 255, 255, 255, true ) end end ) Client addEvent ( "playSound" , true ) addEventHandler ( "playSound" , root , function( filepath ) playSound ( tostring( filepath ), false ) end ) Not forget add your sound to meta.xml
-
triggerClientEvent ( "showPanel", rootElement, showPanel ) You trigger for all elements. See in arguments. And you trigger function nil value. Server function OpenPanel ( player ) local player = player or source local accountname = getAccountName( getPlayerAccount( player ) ) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Console" )) then triggerClientEvent ( player,"showPanel", player ) else outputChatBox ("You Don't Have Permission For This Command", player, 255, 0, 0, true) end end addEvent( "OpenPanel", true ) addEventHandler ( "OpenPanel",root, OpenPanel ) addCommandHandler ( "gpp", OpenPanel ) Updated. Tabulate your code please!
-
Сам юзаю её. И самое главное , что очень функциональная.
-
GUIEditor_Window = {} GUIEditor_TabPanel = {} GUIEditor_Tab = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Image = {} GUIEditor_Window[1] = guiCreateWindow(255,151,638,373,"War_Panel By Evil-Cod3r v1.0",false) guiWindowSetMovable(GUIEditor_Window[1],false) guiWindowSetSizable(GUIEditor_Window[1],false) GUIEditor_TabPanel[1] = guiCreateTabPanel(9,23,620,341,false,GUIEditor_Window[1]) GUIEditor_Tab[1] = guiCreateTab("Weapons",GUIEditor_TabPanel[1]) GUIEditor_Image[1] = guiCreateStaticImage(0,0,143,81,"images/1.png",false,GUIEditor_Tab[1]) GUIEditor_Button[1] = guiCreateButton(6,87,139,29,"Desert Eagle",false,GUIEditor_Tab[1]) guiSetFont(GUIEditor_Button[1],"clear-normal") GUIEditor_Label[1] = guiCreateLabel(8,126,179,18,"Buy Desert Eagle For $120 ?",false,GUIEditor_Tab[1]) guiLabelSetColor(GUIEditor_Label[1],0,255,0) guiSetFont(GUIEditor_Label[1],"clear-normal") GUIEditor_Image[2] = guiCreateStaticImage(243,3,177,92,"images/2.png",false,GUIEditor_Tab[1]) GUIEditor_Button[2] = guiCreateButton(245,97,150,28,"M-4",false,GUIEditor_Tab[1]) guiSetFont(GUIEditor_Button[2],"clear-normal") GUIEditor_Label[2] = guiCreateLabel(243,130,175,22,"Buy M-4 For $ 250 ?",false,GUIEditor_Tab[1]) guiLabelSetColor(GUIEditor_Label[2],255,0,0) guiSetFont(GUIEditor_Label[2],"clear-normal") GUIEditor_Image[3] = guiCreateStaticImage(392,138,215,65,"images/3.png",false,GUIEditor_Tab[1]) GUIEditor_Button[3] = guiCreateButton(410,205,148,25,"Sniper",false,GUIEditor_Tab[1]) guiSetFont(GUIEditor_Button[3],"clear-normal") GUIEditor_Label[3] = guiCreateLabel(406,241,178,20,"Buy Sniper For $320 ?",false,GUIEditor_Tab[1]) guiLabelSetColor(GUIEditor_Label[3],255,0,255) guiSetFont(GUIEditor_Label[3],"clear-normal") GUIEditor_Image[4] = guiCreateStaticImage(11,172,369,128,"images/mtalogo.png",false,GUIEditor_Tab[1]) GUIEditor_Tab[2] = guiCreateTab("Shop",GUIEditor_TabPanel[1]) GUIEditor_Image[5] = guiCreateStaticImage(24,26,207,66,"images/4.png",false,GUIEditor_Tab[2]) GUIEditor_Button[4] = guiCreateButton(36,101,165,34,"Armor",false,GUIEditor_Tab[2]) guiSetFont(GUIEditor_Button[4],"clear-normal") GUIEditor_Label[4] = guiCreateLabel(33,148,154,22,"Buy Armor $ 2500 ?",false,GUIEditor_Tab[2]) guiLabelSetColor(GUIEditor_Label[4],0,0,255) guiSetFont(GUIEditor_Label[4],"clear-normal") GUIEditor_Image[6] = guiCreateStaticImage(316,21,227,78,"images/5.png",false,GUIEditor_Tab[2]) GUIEditor_Button[5] = guiCreateButton(332,106,173,33,"Health",false,GUIEditor_Tab[2]) guiSetFont(GUIEditor_Button[5],"clear-normal") GUIEditor_Label[5] = guiCreateLabel(330,154,158,22,"Buy Health For $ 1500 ?",false,GUIEditor_Tab[2]) guiLabelSetColor(GUIEditor_Label[5],0,255,255) guiSetFont(GUIEditor_Label[5],"clear-normal") GUIEditor_Image[7] = guiCreateStaticImage(19,187,530,116,"images/mtalogo.png",false,GUIEditor_Tab[2]) GUIEditor_Image[8] = guiCreateStaticImage(646,15,0,5,"images/3.png",false,GUIEditor_Window[1]) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == GUIEditor_Button[1] ) then triggerServerEvent("giveWeapon",getLocalPlayer()) end end ) addEvent ( "playSound" , true ) addEventHandler ( "playSound" , root , function() playSound ( "sounds/Buy.mp3" , false ) end) Your mistake : You trigger with this event name "giveWeapon,",but should be "giveWeapon".
-
Server addEvent( 'giveWeapon',true ) addEventHandler( 'giveWeapon',root, function( ) local Money = getPlayerMoney( source ) local Name = getPlayerName( source) if Money >= 120 then giveWeapon ( source, 29 ) outputChatBox ( Name .. "#FF0000Has Bought #00FF00Desert Eagle", root, 255, 255, 255, true ) end end ) You forgot ',' in addEventHandler. local Name = getPlayerName(getLocalPlayer()) Your code getLocalPlayer() in server side oO Please tabulate your code!
-
Тебе нужно просто ремувить событие onClientRender и тогда картинка не будет показываться.
-
http://bugs.mtasa.com/view.php?id=6883
-
dxDrawImage не возвращает элемент, а возвращает булевое значение (true/false). Поэтому уничтожить картинку через destroyElement нельзя.
-
Про дебаг не забывайте.( /debugscript 3 )
-
Client local timer function weaponfireds( weapon ) if weapon == 31 then triggerServerEvent ( "bulletboom" ,source, hitX, hitY, hitZ ) end end addCommandHandler( 'buysuperbullet', function( ) local PlayerMoney = getPlayerMoney( localPlayer ) if PlayerMoney >= 10000 then addEventHandler ( "onClientPlayerWeaponFire",localPlayer, weaponfireds ) outputChatBox( "You buy super bullets.",255,255,0 ) if isTimer( timer ) then killTimer( timer ) end timer = setTimer( function( ) outputChatBox( "Super Bullets Has End",255,255,0 ) removeEventHandler ( "onClientPlayerWeaponFire",localPlayer, weaponfireds ) end, 60000, 1 ) end end ) cmd /buysuperbullet Change how you should. And if you need remove event handler you need use like this: function someEvent( ) -- some code. end addEventHandler( 'someEvent',root,someEvent ) removeEventHandler( 'someEvent',root,someEvent )
-
Юзай элемент даты для таких целей. Это намного лучше.
-
Т.е как я понял ты не аттачил обработчик события к функции OnNametagUpdate? Зачем тогда ты юзаешь cancelEvent( ) ? Отмена события работать не будет.
-
addEventHandler ("onPlayerLogin", getRootElement(), functionname) Непонял.
-
Server addEvent( "spawnVehicle",true ) local vehicles = { } addEventHandler( "spawnVehicle",root, function ( vehicleName ) local model = getVehicleModelFromName( vehicleName ) if model then local x, y, z = getElementPosition( source ) if isElement( vehicles[ source ] ) then destroyElement( vehicles[ source ] ) end vehicles[ source ] = createVehicle( model, x+2, y, z ) end end ) addEventHandler( "onPlayerQuit",root, function ( ) if vehicles[ source ] and #vehicles[ source ] > 0 then for _,v in pairs( vehicles[ source ] ) do if isElement( v ) then destroyElement( v ) end end vehicles[ source ] = nil end end ) Client local VehMarker1 = createMarker( 1026.4000244141, -1451.4000244141, 13, 'cylinder', 1.0, 0, 0, 255, 255 ) local teams = {["SWAT"] = true, ["Staff"] = true} local vehicles = {"Police LS", "Police LV", "Police SF", "Police Rancher", "Police Enforcer", "SWAT Truck"} function createVehGui () MainGui = guiCreateWindow(308,125,400,485,"LWC SWAT Vehicle Panel",false) VehGrid = guiCreateGridList(70,55,261,287,false,MainGui) guiGridListSetSelectionMode(VehGrid,2) VehCol = guiGridListAddColumn(VehGrid,"SWAT Vehicles",0.2) Spawn = guiCreateButton(39,393,145,67,"Spawn",false,MainGui) guiSetFont(Spawn,"clear-normal") Cancel = guiCreateButton(219,393,145,67,"Cancel",false,MainGui) guiSetFont(Cancel,"clear-normal") for index, vehicle in ipairs(vehicles) do local row = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, row, VehCol, tostring(vehicle), false, false ) end end addEventHandler("onClientMarkerHit", vehMarker, function ( hitElement ) if (hitElement == localPlayer and getPlayerTeam ( hitElement ) and teams[getTeamName(getPlayerTeam ( hitElement ))]) then createVehGui ( hitElement ) if (MainGui ~= nil) then guiSetVisible(MainGui, true) showCursor(true) guiSetInputEnabled(true) else outputChatBox ("Error: Please Re-enter the marker to get your vehicle keys.", 255, 0, 0) end end end ) addEventHandler("onClientGUIClick", root, function () if (source == Spawn) then local row,col = guiGridListGetSelectedItem(VehGrid) if (row and col and row ~= -1 and col ~= -1) then local vehicleName = guiGridListGetItemText(VehGrid, row, 1) if vehicleName then triggerServerEvent("spawnVehicle",localPlayer,vehicleName) end else outputChatBox("Error: Please select a vehicle from the list.",255,0,0) end elseif (source == Cancel) then guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) end end )
-
local spam = { } local uTimers = { } local setting = get( "kick" ) function onChat ( message, messageType ) spam[ source ] = tonumber( spam[ source ] or 0 ) + 1 if spam[ source ] == 3 then outputChatBox( "Warning - Do Not Spam! ",source,255,0,0 ) elseif spam[ source ] > 5 then if setting == "true" then outputChatBox( "Kicking " .. getPlayerName( source ) .. " For Flooding The Chat! 5 Times !",root,255,0,0 ) kickPlayer( source,"You Have Been Kicked For Flooding! 5/5" ) elseif setting == "false" then setPlayerMuted( source,true ) outputChatBox( getPlayerName( source ) .. " Has Been Auto Muted [20 sec]",root,255,0,0 ) if isTimer( uTimers[ source ] ) then killTimer( uTimers[ source ] ) end uTimers[ source ] = setTimer( function( player ) setPlayerMuted( player,false ) outputChatBox( "You Have Been unMuted Dont Try Spam!",player,255,255,0 ) end, 20000, 1,source ) end end end addEventHandler ( "onPlayerChat", root, onChat ) function quitPlayer( ) spam[ source ] = nil uTimers[ source ] = nil end addEventHandler ( "onPlayerQuit", root, quitPlayer ) function active( ) outputChatBox( ".:[ Anti Flood | #FFFF1ABy E ]:.",root,0,255,0,true ) end addEventHandler( "onResourceStart", resourceRoot, active )
-
Yes i said in function outputChatBox convert value to string. But if you use guiCreateLabel and etc you need convert.
-
Ты забыл вызвать функциюю cancelEvent( ). И ещё: setPlayerNametagText( player, getPlayerName( player ) .. "[" .. ( tonumber( getPlayerWantedLevel( player ) ) or 0 ) .. "]" ) Это не правильно т.к ты должен юзать строку , а не число . Т.е тебе надо конвертнуть из числа в строку. Т.е так: setPlayerNametagText( player, getPlayerName( player ) .. "[" .. tostring( getPlayerWantedLevel( player ) or 0 ) .. "]" ) Полный код. function OnNametagUpdate( player ) local playerTeam = getPlayerTeam ( player ) if not playerTeam == teampolice then setPlayerNametagText( player, getPlayerName( player ) .. "[" .. tostring( getPlayerWantedLevel( player ) or 0 ) .. "]" ) else cancelEvent( ) end end function NametagUpdate() for _, p in ipairs( getElementsByType( "player" ) ) do OnNametagUpdate( p ) end end setTimer( NametagUpdate, 1000, 0 ) Обновил. Вопрос:Переменная teampolice определена? Вопрос2:Ты аттачил к фунции OnNametagUpdate обработчик события?( addEventHandler )
-
In the rest of the functions you need convert value to string( tostring function ). http://bugs.mtasa.com/view.php?id=6021