Jump to content

Kenix

Retired Staff
  • Posts

    4,121
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Kenix

  1. So you test it? It working?
  2. local uTimers = { } local uTimersLogout = { } addEventHandler('onResourceStart',resourceRoot, function( ) call( getResourceFromName( 'scoreboard' ),'addScoreboardColumn','Level' ) for _,v in pairs( getElementsByType 'player' ) do setElementData( v,'Level','Guest' ) end end ) addEventHandler( 'onPlayerLogin',root, function( ) local account = getPlayerAccount( source ) if account then local level = getAccountData( account ,'My Level' ) or 0 uTimers[ source ] = setTimer( function( thePlayer,account ) local result = executeSQLQuery( "SELECT money FROM Money WHERE player = '"..getPlayerName( thePlayer ).."'" ) if not result or #result == 0 then local create = executeSQLQuery( "INSERT INTO Money VALUES ( '"..getPlayerName( thePlayer ).."','0')" ) setAccountData( account,'My Level','Newbie' ) setElementData( thePlayer,'Level','Newbie' ) else local money = result[1]['money'] if money <= 50000 then setAccountData( account,'My Level','Newbie' ) setElementData( thePlayer,'Level','Newbie' ) elseif money <= 250000 and tonumber( money ) > 50000 then setAccountData( account,'My Level','Regular' ) setElementData( thePlayer,'Level','Regular' ) elseif money <= 450000 and tonumber( money ) > 250000 then setAccountData( account,'My Level','Experienced' ) setElementData( thePlayer,'Level','Experienced' ) elseif money <= 1000000 and tonumber( money ) > 450000 then setAccountData( account,'My Level','Veteran' ) setElementData( thePlayer,'Level','Veteran' ) elseif money <= 5000000 and tonumber( money ) > 1000000 then setAccountData( account,'My Level','Guru' ) setElementData( thePlayer,'Level','Guru' ) elseif money > 10000000 then setAccountData( account,'My Level','Legend' ) setElementData( thePlayer, 'Level', 'Legend' ) end end end, 500,0,source, account ) --output data if level == 'Newbie' then triggerEvent( 'onNewbieLogin',source ) elseif level == 'Regular' then triggerEvent( 'onRegularLogin',source ) elseif level == 'Experienced' then triggerEvent( 'onExperiencedLogin',source ) elseif level == 'Veteran' then triggerEvent( 'onVeteranLogin',source ) elseif level == 'Guru' then triggerEvent( 'onGuruLogin',source ) elseif level == 'Legend' then triggerEvent('onLegendLogin',source ) end end end ) addEventHandler( 'onPlayerLogout',root, function( ) if isTimer( uTimers [ source ] ) then killTimer( uTimers [ source ] ) end uTimersLogout [ source ] = setTimer ( function( thePlayer ) setElementData( thePlayer,'Level','Guest' ) end, 500,1,source ) end ) addEventHandler( 'onPlayerJoin',root, function( ) setElementData ( source, 'Level', 'Guest' ) end ) addEventHandler( 'onPlayerQuit',root, function( ) uTimers[ source ] = nil uTimersLogout[ source ] = nil end ) Corrected full code. addEventHandler('onResourceStart',resourceRoot, function() call(getResourceFromName('scoreboard'),'addScoreboardColumn','Level') setElementData(source,'Level','Guest') end) You setElementData to resource ? Why you need? addEventHandler('onResourceStart',resourceRoot, function( ) call( getResourceFromName( 'scoreboard' ),'addScoreboardColumn','Level' ) for _,v in pairs( getElementsByType 'player' ) do setElementData( v,'Level','Guest' ) end end ) Maybe you mean this? And addEventHandler( 'onPlayerLogout',root, function( ) if isTimer( uTimers [ source ] ) then killTimer( uTimers [ source ] ) end uTimersLogout [ source ] = setTimer ( function( thePlayer ) setElementData( thePlayer,'My Level','Guest' ) end, 500,1,source ) end ) Your code. You setElementData( ..,'My level',... ) So it's not data Level ( not see in scoreboard ). So if you use this data ( My level ) it not show in scoreboard. addEventHandler( 'onPlayerLogout',root, function( ) if isTimer( uTimers [ source ] ) then killTimer( uTimers [ source ] ) end uTimersLogout [ source ] = setTimer ( function( thePlayer ) setElementData( thePlayer,'Level','Guest' ) end, 500,1,source ) end ) Correct. Finally:Why you not use sql db for all? You use account data/and sql functions. My opinion is not correct
  3. You mean it or no? Say line please. We not telepaths
  4. local uTimers = { } local uTimersLogout = { } addEventHandler( 'onPlayerLogin',root, function( ) local account = getPlayerAccount( source ) if account then local level = getAccountData( account ,'My Level' ) or 0 uTimers[ source ] = setTimer( function( thePlayer,account ) local result = executeSQLQuery( "SELECT money FROM Money WHERE player = '"..getPlayerName( thePlayer ).."'" ) if not result or #result == 0 then outputChatBox 'table is empty' else local money = result[1]['money'] if money <= 50000 then setAccountData( account,'My Level','Newbie' ) setElementData( thePlayer,'Level','Newbie' ) elseif money <= 250000 and tonumber( money ) > 50000 then setAccountData( account,'My Level','Regular' ) setElementData( thePlayer,'Level','Regular' ) elseif money <= 450000 and tonumber( money ) > 250000 then setAccountData( account,'My Level','Experienced' ) setElementData( thePlayer,'Level','Experienced' ) elseif money <= 1000000 and tonumber( money ) > 450000 then setAccountData( account,'My Level','Veteran' ) setElementData( thePlayer,'Level','Veteran' ) elseif money <= 5000000 and tonumber( money ) > 1000000 then setAccountData( account,'My Level','Guru' ) setElementData( thePlayer,'Level','Guru' ) elseif money > 10000000 then setAccountData( account,'My Level','Legend' ) setElementData( thePlayer, 'Level', 'Legend' ) end end end, 500,0,source,account ) --output data if level == 'Newbie' then triggerEvent( 'onNewbieLogin',source ) elseif level == 'Regular' then triggerEvent( 'onRegularLogin',source ) elseif level == 'Experienced' then triggerEvent( 'onExperiencedLogin',source ) elseif level == 'Veteran' then triggerEvent( 'onVeteranLogin',source ) elseif level == 'Guru' then triggerEvent( 'onGuruLogin',source ) elseif level == 'Legend' then triggerEvent('onLegendLogin',source ) end end end ) addEventHandler( 'onPlayerLogout',root, function( ) if isTimer( uTimers [ source ] ) then killTimer( uTimers [ source ] ) end uTimersLogout [ source ] = setTimer ( function( thePlayer ) setElementData( thePlayer,'My Level','Guest' ) end, 500,1,source ) end ) addEventHandler( 'onPlayerQuit',root, function( ) uTimers [ source ] = nil uTimersLogout [ source ] = nil end ) You need destroy old timer ( timer in event onPlayerLogin ) if player logout ? And then create new timer. Right?
  5. local uTimers = { } addEventHandler( 'onPlayerLogin',root, function( ) local account = getPlayerAccount( source ) if account then local level = getAccountData( account ,'My Level' ) or 0 uTimers[ source ] = setTimer( function( thePlayer,account ) local result = executeSQLQuery( "SELECT money FROM Money WHERE player = '"..getPlayerName( thePlayer ).."'" ) if not result or #result == 0 then outputChatBox 'table is empty' else local money = result[1]['money'] if money <= 50000 then setAccountData( account,'My Level','Newbie' ) setElementData( thePlayer,'Level','Newbie' ) elseif money <= 250000 and tonumber( money ) > 50000 then setAccountData( account,'My Level','Regular' ) setElementData( thePlayer,'Level','Regular' ) elseif money <= 450000 and tonumber( money ) > 250000 then setAccountData( account,'My Level','Experienced' ) setElementData( thePlayer,'Level','Experienced' ) elseif money <= 1000000 and tonumber( money ) > 450000 then setAccountData( account,'My Level','Veteran' ) setElementData( thePlayer,'Level','Veteran' ) elseif money <= 5000000 and tonumber( money ) > 1000000 then setAccountData( account,'My Level','Guru' ) setElementData( thePlayer,'Level','Guru' ) elseif money > 10000000 then setAccountData( account,'My Level','Legend' ) setElementData( thePlayer, 'Level', 'Legend' ) end end end, 500,0,source,account ) --output data if level == 'Newbie' then triggerEvent( 'onNewbieLogin',source ) elseif level == 'Regular' then triggerEvent( 'onRegularLogin',source ) elseif level == 'Experienced' then triggerEvent( 'onExperiencedLogin',source ) elseif level == 'Veteran' then triggerEvent( 'onVeteranLogin',source ) elseif level == 'Guru' then triggerEvent( 'onGuruLogin',source ) elseif level == 'Legend' then triggerEvent('onLegendLogin',source ) end end end ) addEventHandler( 'onPlayerLogout',root, function( ) uTimers [ source ] = setTimer ( function( thePlayer ) setElementData( thePlayer,'My Level','Guest' ) end, 500,1,source ) end ) addEventHandler( 'onPlayerQuit',root, function( ) uTimers [ source ] = nil end ) Because result table is empty.
  6. function aFunction( element,dim ) if getElementType ( element ) == "player" and not isPedInVehicle( element ) then -- check if player hit colshape and player not in vehicle. --Do something end end addEventHandler ( "onColShapeLeave", aCol, aFunction ) You mean this?
  7. Kenix

    Help with GUI

    Ah in first time i not see where your function ( you attach function to event handler ) No problem. So structure: addEvent( 'onSomeEvent',true ) local t = { 'some_value' } function some( ) return 'some' end function onSomeEvent( ) outputChatBox '--> onSomeEvent' end addEventHandler( 'onSomeEvent',root,onSomeEvent ) 1.add event 2.variables/tables 3.functions. 4.event handler.
  8. Kenix

    spawn timer

    Server function spawnAgain( player ) spawnPlayer( player, 0.0, 0.0, 0.0 ) end addEventHandler( 'onPlayerWasted',root, function( ) setTimer( spawnAgain, 2000, 1,source ) end )
  9. Try local uTimers = { } addEventHandler( 'onPlayerLogin',root, function( ) local account = getPlayerAccount( source ) if account then local level = getAccountData( account ,'My Level' ) or 0 uTimers[ source ] = setTimer( function( thePlayer,account ) local result = executeSQLQuery( "SELECT money FROM Money WHERE player = '"..getPlayerName( thePlayer ).."'" ) local money = result[1]['money'] if money <= 50000 then setAccountData( account,'My Level','Newbie' ) setElementData( thePlayer,'Level','Newbie' ) elseif money <= 250000 and tonumber( money ) > 50000 then setAccountData( account,'My Level','Regular' ) setElementData( thePlayer,'Level','Regular' ) elseif money <= 450000 and tonumber( money ) > 250000 then setAccountData( account,'My Level','Experienced' ) setElementData( thePlayer,'Level','Experienced' ) elseif money <= 1000000 and tonumber( money ) > 450000 then setAccountData( account,'My Level','Veteran' ) setElementData( thePlayer,'Level','Veteran' ) elseif money <= 5000000 and tonumber( money ) > 1000000 then setAccountData( account,'My Level','Guru' ) setElementData( thePlayer,'Level','Guru' ) elseif money > 10000000 then setAccountData( account,'My Level','Legend' ) setElementData( thePlayer, 'Level', 'Legend' ) end end, 500,0,source,account ) --output data if level == 'Newbie' then triggerEvent( 'onNewbieLogin',source ) elseif level == 'Regular' then triggerEvent( 'onRegularLogin',source ) elseif level == 'Experienced' then triggerEvent( 'onExperiencedLogin',source ) elseif level == 'Veteran' then triggerEvent( 'onVeteranLogin',source ) elseif level == 'Guru' then triggerEvent( 'onGuruLogin',source ) elseif level == 'Legend' then triggerEvent('onLegendLogin',source ) end end end ) addEventHandler( 'onPlayerLogout',root, function( ) uTimers [ source ] = setTimer ( function( thePlayer ) setElementData( thePlayer,'My Level','Guest' ) end, 500,1,source ) end ) addEventHandler( 'onPlayerQuit',root, function( ) uTimers [ source ] = nil end )
  10. Kenix

    What wrong?

    He doesn't understand that he had made.
  11. Kenix

    Question

    addEventHandler( 'onClientRender',root, function( ) local x,y,z = getElementPosition( localPlayer ) dxDrawLine3D( x,y,z,x,y+2,z,tocolor ( 0, 255, 0, 230 ), 2 ) dxDrawLine3D( x,y,z,x,y-2,z,tocolor ( 0, 255, 0, 230 ), 2 ) dxDrawLine3D( x,y,z,x+2,y,z,tocolor ( 0, 255, 0, 230 ), 2 ) dxDrawLine3D( x,y,z,x-2,y,z,tocolor ( 0, 255, 0, 230 ), 2 ) dxDrawLine3D( x,y,z,x,y,z+2,tocolor ( 0, 255, 0, 230 ), 2 ) dxDrawLine3D( x,y,z,x,y,z-2,tocolor ( 0, 255, 0, 230 ), 2 ) end )
  12. He should use event/function or element data ( if source player element ).
  13. local cones = { } function spawnCones ( thePlayer ) if not cones[ thePlayer ] then cones[ thePlayer ] = { } end local x,y,z = getElementPosition ( thePlayer ) local index = #cones[ thePlayer ] +1 cones[ thePlayer ][ index ] = createObject ( 1238, x, y, z-0.6 ) outputChatBox( "Created cone, ID: ".. index .."!",thePlayer,0,255,0 ) end addCommandHandler ( "cone", spawnCones ) function destroyCones( thePlayer, cmd, id ) if not cones[ thePlayer ] then cones[ thePlayer ] = { } end local id = tonumber( id ) if isElement( cones[ thePlayer ][ id ] ) then destroyElement( cones[ thePlayer ][ id ] ) outputChatBox( "Removed cone, ID: ".. id .."!",thePlayer,0,255,0 ) end end addCommandHandler ( "deletecone", destroyCones ) addEventHandler( 'onPlayerQuit',root, -- if player quit then remove all cones. function( ) if #cones[ source ] > 0 then for i = 1,#cones[ source ] do destroyElement( cones[ source ][ i ] ) cones[ source ] = nil end end end )
  14. Kenix

    Help with GUI

    sWidth,sHeight = guiGetScreenSize() showCursor(true) LoginW = guiCreateWindow(sWidth/3.3,sHeight/3.3,500,300,"Oriental Night Gaming - Login",false) NameL = guiCreateLabel(28,139,35,15,"Name:",false,LoginW) guiSetFont(NameL,"default-bold-small") PassL = guiCreateLabel(18,180,56,15,"Password:",false,LoginW) guiSetFont(PassL,"default-bold-small") NameED = guiCreateEdit(78,132,233,31,"",false,LoginW) PassED = guiCreateEdit(80,174,233,31,"",false,LoginW) SepAD = guiCreateLabel(335,24,5,276,"|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n",false,LoginW) LoginB = guiCreateButton(23,244,120,32,"Login",false,LoginW) RegisterB = guiCreateButton(192,244,120,32,"Register",false,LoginW) AD = guiCreateStaticImage(339,23,168,278,"images/AD.jpg",false,LoginW) Logo = guiCreateStaticImage(9,27,322,88,"images/Logo.jpg",false,LoginW) Name = guiGetText(NameED) Pass = guiGetText(PassED) addEventHandler( "onClientGUIClick",RegisterB,RegisterC,false ) addEventHandler( "onClientGUIClick",LoginB,LoginE,false ) function RegisterC() destroyElement(LoginW) RegisterW = guiCreateWindow(sWidth/3.3,sHeight/3.3,500,300,"Oriental Night Gaming - Register",false) NameLR = guiCreateLabel(28,77,35,15,"Name:",false,RegisterW) guiSetFont(NameLR,"default-bold-small") PassLR = guiCreateLabel(14,120,56,15,"Password:",false,RegisterW) guiSetFont(PassLR,"default-bold-small") NameEDR = guiCreateEdit(78,69,233,31,"",false,RegisterW) PassEDR = guiCreateEdit(80,111,233,31,"",false,RegisterW) SepADR = guiCreateLabel(335,24,5,276,"|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n",false,RegisterW) BackB = guiCreateButton(23,244,120,32,"Back",false,RegisterW) RegisterBR = guiCreateButton(192,244,120,32,"Register",false,RegisterW) ConfEDR = guiCreateEdit(80,154,233,31,"",false,RegisterW) ConfLR = guiCreateLabel(18,163,56,15,"Confirm:",false,RegisterW) guiSetFont(ConfLR,"default-bold-small") AD = guiCreateStaticImage(339,23,168,278,"images/AD.jpg",false,RegisterW) NameR = guiGetText(NameEDR) PassR = guiGetText(PassEDR) addEventHandler( "onClientGUIClick",BackB,LoginC,false ) addEventHandler( "onClientGUIClick",RegisterBR,RegisterE,false ) end function LoginC() destroyElement(RegisterW) LoginW = guiCreateWindow(sWidth/3.3,sHeight/3.3,500,300,"Oriental Night Gaming - Login",false) NameL = guiCreateLabel(28,139,35,15,"Name:",false,LoginW) guiSetFont(NameL,"default-bold-small") PassL = guiCreateLabel(18,180,56,15,"Password:",false,LoginW) guiSetFont(PassL,"default-bold-small") NameED = guiCreateEdit(78,132,233,31,"",false,LoginW) PassED = guiCreateEdit(80,174,233,31,"",false,LoginW) SepAD = guiCreateLabel(335,24,5,276,"|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n",false,LoginW) LoginB = guiCreateButton(23,244,120,32,"Login",false,LoginW) RegisterB = guiCreateButton(192,244,120,32,"Register",false,LoginW) AD = guiCreateStaticImage(339,23,168,278,"images/AD.jpg",false,LoginW) Logo = guiCreateStaticImage(9,27,322,88,"images/Logo.jpg",false,LoginW) addEventHandler( "onClientGUIClick",RegisterB,RegisterC,false ) addEventHandler( "onClientGUIClick",LoginB,LoginE,false ) end function LoginE() local Name = guiGetText(NameED) local Pass = guiGetText(PassED) triggerServerEvent("login",localPlayer,localPlayer,Name,Pass) end function RegisterE() local NameR = guiGetText(NameEDR) local PassR = guiGetText(PassEDR) local Confirm = guiGetText(ConfEDR) triggerServerEvent("register",localPlayer,localPlayer,NameR,PassR,Confirm) end addEvent("agree",true) addEventHandler("agree",getRootElement(), function() destroyElement(LoginW) WelcomeW = guiCreateWindow(0.2188,0.1325,0.5445,0.7725,"Oriental Night Game - Agreement",true) guiWindowSetMovable(WelcomeW,false) guiWindowSetSizable(WelcomeW,false) EngL = guiCreateLabel(18,31,41,16,"English:",false,WelcomeW) MemoEng = guiCreateMemo(20,54,653,224,"Thank you for joining \"Oriental Night Gaming\"!\n\nThis is a server in development and it's just starting, so please be patient while we complete the development and add all the new functions and resources that will make this server a better one!\n\nFor now, please enjoy our Freeroam play, but follow these rules:\n\n1. Do not kill players while using a Jetpack\n2. You are not allowed to kill a player while you're in a vehicle and the player you want to kill is on foot (Get off the vehicle and kill it)\n3. Absolutely NO SPAWN KILLING, if they spawn, let them spawn normally, do not camp them or the present admin will ban you permanently.\n4. No HeliKill (Do not kill with the chopper razors) NOTE: The vehicle weapons have been disabled.\n5. Do not disrespect admins! (If the admin disrespects you, report it!)\n6. No admin impresionation! (Do not copy their names, if they are admins, they will do an admin function or appear in a team)\n7. No Ramming (Do not step on people with a car)\n_______________________________________________\n\nThis is the Member List so far:\n\n- WolfPire\n- Cross\n- MoonLight\n- Toxiccastle\n- Land\n\nDo not accept copy's!\n_______________________________________________\n\nThat's all! Accept if you agree and enjoy our server! =)",false,WelcomeW) guiMemoSetReadOnly(MemoEng,true) MemoEsp = guiCreateMemo(20,334,653,224,"Gracias por entrar a \"Oriental Night Gaming\"!\n\nEste servidor esta en desarrollo y solo esta empezando, asi que por favor se paciente mientras completamos el desarrollo y anadimos todas las nuevas funciones y recursos que haran de este server uno mejor!\n\nPor ahora, disfruta de nuestro juego Freeroam, pero sigue estas reglas:\n\n1. No mates a otros jugadores mientras usas un Jetpack\n2. No tienes permitido matar a otro jugador mientras estas en un auto y el otro jugador a pie (Salte del auto y matalo)\n3. Absolutamente NO MATAR GENTE DONDE APARECEN, si aparecen, dejalos aparecer normalmente, no los esperes o el admin presente te baneara permanentemente.\n4. No matar con el helicoptero (No los mates con las aspas de el helicoptero) NOTA: Las armas de los vehiculos estan desactivadas.\n5. No le faltes el respeto a los admins! (Si el admin te falta el respeto, reportalo!)\n6. No falsifiques a un admin! (No copies sus nombres, si ellos son admins, ellos haran alguna funcion admin o apareceran en algun equipo)\n7. No pises a los demas (No los pises con un auto)\n\n_______________________________________________\n\nEsta es la Lista de Miembros hasta ahora:\n\n- WolfPire\n- Cross\n- MoonLight\n- Toxiccastle\n- Land\n\nNo aceptes copias!\n_______________________________________________\n\nEso es todo! Acepta nuetras reglas si estas de acuerdo y disfruta nuestro server! =)",false,WelcomeW) guiMemoSetReadOnly(MemoEsp,true) Line = guiCreateLabel(21,278,654,20,"______________________________________________________________________________________________________________",false,WelcomeW) guiLabelSetColor(Line,0,255,0) EspL = guiCreateLabel(18,303,44,16,"Espanol:",false,WelcomeW) AcceptB = guiCreateButton(24,568,220,36,"Accept / Aceptar",false,WelcomeW) addEventHandler( "onClientGUIClick",AcceptB,AcceptC,false ) end ) function AcceptC( ) destroyElement(WelcomeW) showCursor(false) end
  15. Kenix

    What wrong?

    Learn https://wiki.multitheftauto.com/wiki/Scr ... troduction
  16. Спасибо большое, что-то ступил я.. 1. t = { [1] = '1'; [2] = '2'; [3] = '3'; } 2. t = { } t[1] = { } t[1][1] = '1'; t[1][2] = '2'; t[1][3] = '3';
  17. Нужно результат вернуть весь. Именно из функции. Т.е к примеру вызывал функцию в аргументе таблица. Ну и на выходе уже выходила таблица 1 дименсионная, а не 2,3,4 и т.д. P.S Плохо умею объяснять ..
  18. В том то и дело , что нет. Если в таблице есть таблицы то они их не перебирает. t = { a = { 'a'; ['c'] = { 'b' } } } for _,v in pairs( t ) do print( v ) end -- table: 0x2538600 Нужно вообще всё перебрать. Ладно если индекс числовой , а вот если нет?
  19. Сейчас есть проблема. Очень нужна функция , которая бы перебирала ВСЮ таблицу. Например. local t = { a = '1'; b = { '2'; c = { '3'; ['4'] = { '5' } } } }
×
×
  • Create New...