Jump to content

Kenix

Retired Staff
  • Posts

    4,121
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Kenix

  1. Ah i not understand your first post Yes, mysql is not case sensitive. Request,tables,... But you can create it. http://dev.mysql.com/doc/refman/5.0/en/ ... ivity.html
  2. Kenix

    Help pls

    In script files resource.
  3. Kenix

    Help pls

    Paste the code it up. _getPlayerName = getPlayerName function getPlayerName( el ) if isElement( el ) then local name = _getPlayerName( el ) if name then return string.gsub( name, '#%x%x%x%x%x%x', '' ) or name end return false end return false end
  4. Server local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 20 local mysqldb addEvent( "submitLogin", true ) addEvent( "submitRegister", true ) function connectToMysql ( ) mysqldb = mysql_connect( "localhost", "", "", "mtadb" ) if mysqldb then outputDebugString( 'CONNECTION SUCCES' ) else outputDebugString( 'CONNECTION NOT SUCCES' ) end end function disconnectToMysql( ) if mysqldb then mysql_close( mysqldb ) end end function loginHandler( username, password ) local result = mysql_query( mysqldb, "SELECT * FROM players WHERE username = '"..username.. "' AND pass = '"..password.. "'" ) if not result then outputDebugString( "EVENT:submitLogin mysql_query failed: (" .. tostring( mysql_errno( mysqldb ) ).. ") " ..tostring( mysql_error( mysqldb ) ) ) else if mysql_num_rows( result ) > 0 then spawnPlayer( source, spawnX, spawnY, spawnZ ) fadeCamera( source, true) setCameraTarget( source, source ) outputChatBox( "Welcome to My Server.", source ) else outputChatBox( "Invalid username and password. Please try again.",source ) triggerClientEvent ( "falseLogin", root ) end mysql_free_result( result ) end end function registerHandler( user, pass, repass ) local result = mysql_query( mysqldb, "SELECT * FROM players WHERE username = '"..user.."'" ) if not result then outputDebugString( "EVENT:submitRegister mysql_query failed: (" .. tostring( mysql_errno( mysqldb ) ).. ") " ..tostring( mysql_error( mysqldb ) ) ) else if mysql_num_rows( result ) > 0 then outputChatBox( "Username which you selected already exists!",source, 255, 0, 0 ) else local Result = mysql_query( mysqldb, "INSERT INTO players (username, pass) VALUES ('"..user.."', '"..pass.."')" ) if Result then outputChatBox( "Succes register", source ) mysql_free_result( Result ) else outputDebugString( "Register not succes: mysql_query failed: (" .. tostring( mysql_errno( mysqldb ) ).. ") " ..tostring( mysql_error( mysqldb ) ) ) end end mysql_free_result( result ) end end addEventHandler( "onPlayerWasted", root, function() setTimer( spawnPlayer, 2000, 1, source, spawnX, spawnY, spawnZ ) end ) --addCommandHandler( "vehicle", createVehicleForPlayer ) addEventHandler ( "onResourceStart", resourceRoot,connectToMysql ) addEventHandler( 'onResourceStop', resourceRoot,disconnectToMysql ) addEventHandler( "submitRegister", root, registerHandler ) addEventHandler( "submitLogin", root, loginHandler ) Client addEvent( "falseLogin", true) function createLoginRegisterGUI( ) local X = 0.375 local Y = 0.375 local Width = 0.35 local Height = 0.35 myFont = guiCreateFont( "password.ttf", 15 ) wdwLogin = guiCreateWindow(X, Y, Width, Height, "Login/Register window", true) local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, wdwLogin) local tabLogin = guiCreateTab( "Login", tabPanel ) local tabRegister = guiCreateTab( "Register", tabPanel ) X = 0.0825 Y = 0.2 Width = 0.25 Height = 0.25 guiCreateLabel(X, Y, Width, Height, "Username", true, tabLogin) Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, tabLogin) X = 0.315 Y = 0.2 Width = 0.6 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, tabLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, tabLogin) guiSetFont(edtPass, myFont ) guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) X = 0.05 Y = 0.7 Width = 0.9 Height = 0.15 btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, tabLogin) --========================Regsiter=============================================== X = 0.0825 Y = 0.21 Width = 0.2 Height = 0.2 guiCreateLabel(X, Y, Width, Height, "Username", true, tabRegister) Y = 0.41 guiCreateLabel(X, Y, Width, Height, "Password", true, tabRegister) Y = 0.61 guiCreateLabel(X, Y, Width, Height, "Repeat password", true, tabRegister) X = 0.315 Y = 0.2 Width = 0.6 Height = 0.1 edtReUser = guiCreateEdit(X, Y, Width, Height, "", true, tabRegister) Y = 0.4 edtRegPass = guiCreateEdit(X, Y, Width, Height, "", true, tabRegister) Y = 0.6 edtRePass = guiCreateEdit(X, Y, Width, Height, "", true, tabRegister) myFont = guiCreateFont( "password.ttf", 10 ) guiSetFont( edtRegPass, myFont ) guiSetFont( edtRePass, myFont ) guiEditSetMaxLength(edtReUser, 50) guiEditSetMaxLength(edtRegPass, 50) guiEditSetMaxLength(edtRePass, 50) X = 0.05 Y = 0.8 Width = 0.9 Height = 0.15 btnRegister = guiCreateButton(X, Y, Width, Height, "Register", true, tabRegister) guiSetVisible(wdwLogin, false) addEventHandler( "onClientGUIClick", btnLogin, clientSubmitLogin, false ) addEventHandler( "onClientGUIClick", btnRegister, clientSubmitRegister, false ) end function clientSubmitRegister(button, state) if button == "left" and state == "up" then local username = guiGetText(edtReUser) local password = guiGetText(edtRegPass) local repass = guiGetText(edtRePass) if username and password then triggerServerEvent( "submitRegister", localPlayer, username, password, repass ) end end end function clientSubmitLogin( button,state ) if button == "left" and state == "up" then local username = guiGetText( edtUser ) local password = guiGetText( edtPass ) if username and password then triggerServerEvent( "submitLogin", localPlayer, username, password ) guiSetInputEnabled( false) guiSetVisible( wdwLogin, false) showCursor( false ) else outputChatBox("Please enter a username and password.") end end end addEventHandler( "onClientResourceStart", resourceRoot, function ( ) createLoginRegisterGUI( ) outputChatBox( "Welcome to My MTA:SA Server." ) if wdwLogin then guiSetVisible( wdwLogin, true ) else outputChatBox( "An unexpected error has occurred and the log in GUI has not been created." ) end showCursor( true ) guiSetInputEnabled( true ) end ) addEventHandler( "falseLogin", root, function( ) guiSetInputEnabled( true ) guiSetVisible( wdwLogin, true ) showCursor( true ) end ) Try it /debugscript 3.
  5. You can show how you connect to db.? Better show full code.
  6. Kenix

    Help pls

    Find file joinquit.lua in resource joinquit. Open and replace with this: g_Root = getRootElement() _getPlayerName = getPlayerName function getPlayerName( el ) if isElement( el ) then local name = _getPlayerName( el ) if name then return string.gsub( name, '#%x%x%x%x%x%x', '' ) or name end return false end return false end addEventHandler('onClientPlayerJoin', g_Root, function() outputChatBox('* ' .. getPlayerName(source) .. ' has joined the game', 255, 100, 100) end ) addEventHandler('onClientPlayerChangeNick', g_Root, function(oldNick, newNick) outputChatBox('* ' .. oldNick .. ' is now known as ' .. newNick, 255, 100, 100) end ) addEventHandler('onClientPlayerQuit', g_Root, function(reason) outputChatBox('* ' .. getPlayerName(source) .. ' has left the game [' .. reason .. ']', 255, 100, 100) end ) In other resources paste this: _getPlayerName = getPlayerName function getPlayerName( el ) if isElement( el ) then local name = _getPlayerName( el ) if name then return string.gsub( name, '#%x%x%x%x%x%x', '' ) or name end return false end return false end Upper code.
  7. Kenix

    Help pls

    In resources joinquit,killmessages use this function: _getPlayerName = getPlayerName function getPlayerName( el ) if isElement( el ) then local name = _getPlayerName( el ) if name then return string.gsub( name, '#%x%x%x%x%x%x', '' ) or name end return false end return false end Example _getPlayerName = getPlayerName function getPlayerName( el ) if isElement( el ) then local name = _getPlayerName( el ) if name then return string.gsub( name, '#%x%x%x%x%x%x', '' ) or name end return false end return false end -- .... code Example resource joinquit: joinquit.lua g_Root = getRootElement() _getPlayerName = getPlayerName function getPlayerName( el ) if isElement( el ) then local name = _getPlayerName( el ) if name then return string.gsub( name, '#%x%x%x%x%x%x', '' ) or name end return false end return false end addEventHandler('onClientPlayerJoin', g_Root, function() outputChatBox('* ' .. getPlayerName(source) .. ' has joined the game', 255, 100, 100) end ) addEventHandler('onClientPlayerChangeNick', g_Root, function(oldNick, newNick) outputChatBox('* ' .. oldNick .. ' is now known as ' .. newNick, 255, 100, 100) end ) addEventHandler('onClientPlayerQuit', g_Root, function(reason) outputChatBox('* ' .. getPlayerName(source) .. ' has left the game [' .. reason .. ']', 255, 100, 100) end )
  8. Try Server addEvent( "submitLogin", true ) function loginHandler( username, password ) local result = mysql_query( mysqldb, "SELECT * FROM players WHERE username = '"..username.. "' AND pass = '"..password.. "'" ) if not result then outputDebugString( "mysql_query failed: (" .. tostring( mysql_errno( mysqldb ) ).. ") " ..tostring( mysql_error( mysqldb ) ) ) else if mysql_num_rows( result ) > 0 then spawnPlayer( source, spawnX, spawnY, spawnZ ) fadeCamera( source, true) setCameraTarget( source, source ) outputChatBox( "Welcome to My Server.", source ) else outputChatBox( "Invalid username and password. Please try again.",source ) triggerClientEvent ( "falseLogin", root ) end end mysql_free_result( result ) end addEventHandler( "submitLogin", root, loginHandler ) Client addEvent( "falseLogin", true) function clientSubmitLogin( button,state ) if button == "left" and state == "up" then local username = guiGetText( edtUser ) local password = guiGetText( edtPass ) if username and password then triggerServerEvent( "submitLogin", localPlayer, username, password ) guiSetInputEnabled( false) guiSetVisible( wdwLogin, false) showCursor( false ) else outputChatBox("Please enter a username and password.") end end end addEventHandler( "onClientResourceStart", resourceRoot, function ( ) createLoginRegisterGUI( ) outputChatBox( "Welcome to My MTA:SA Server." ) if wdwLogin then guiSetVisible( wdwLogin, true ) else outputChatBox( "An unexpected error has occurred and the log in GUI has not been created." ) end showCursor( true ) guiSetInputEnabled( true ) end ) addEventHandler( "falseLogin", root, function( ) guiSetInputEnabled( true ) guiSetVisible( wdwLogin, true ) showCursor( true ) end ) Your variables spawnX, spawnY, spawnZ define?
  9. Kenix

    Gravity Problem

    Tested. local timer,state local underX,underY,underZ local x,y,z function playerOptions( ) setPedCanBeKnockedOffBike( localPlayer,false ) addEventHandler( "onClientPlayerVehicleEnter",localPlayer,enableGravityWheels ) addEventHandler( "onClientPlayerVehicleExit",localPlayer,disableGravityWheels ) end function checkCarWheels( vehicle ) if isVehicleOnGround( vehicle ) then changeGravity( vehicle ) end end function changeGravity( vehicle ) setVehicleGravity( vehicle,underX - x,underY - y,underZ - z ) end function disableGravityWheels( vehicle ) setVehicleGravity( vehicle, 0, 0, -1 ) end function enableGravityWheels( vehicle ) local vehicle if not isElement( vehicle ) then vehicle = getPedOccupiedVehicle( localPlayer ) end x,y,z = getElementPosition( vehicle ) underX,underY,underZ = getVehicleUnderGravity( vehicle ) if isVehicleOnGround( vehicle ) and isPedInVehicle( source or localPlayer ) then if isTimer( timer ) then killTimer( timer ) end timer = setTimer( checkCarWheels, 1000, 0,vehicle ) end end function getVehicleUnderGravity( element ) local matrix = getElementMatrix ( element ) local offX = 0 * matrix[1][1] + 0 * matrix[2][1] - 1 * matrix[3][1] + matrix[4][1] local offY = 0 * matrix[1][2] + 0 * matrix[2][2] - 1 * matrix[3][2] + matrix[4][2] local offZ = 0 * matrix[1][3] + 0 * matrix[2][3] - 1 * matrix[3][3] + matrix[4][3] return offX,offY,offZ end addCommandHandler( "gravity",enableGravityWheels ) addEventHandler( "onClientResourceStart",resourceRoot,playerOptions ) or maybe you need this? local state addCommandHandler( "gravity", function( ) local veh = getPedOccupiedVehicle( localPlayer ) if veh then state = not state if state then setVehicleGravity( veh, 0, 0, 0 ) else setVehicleGravity( veh, 0, 0, -1 ) end end end ) /debugscript 3 use. You need learn lua http://www.lua.org/manual/5.1/ And this https://wiki.multitheftauto.com/wiki/Scr ... troduction Updated again.
  10. AMARANT, getElementPosition getScreenFromWorldPosition dxDrawText
  11. addEvent( 'onPlayerRaceWasted',true ) addEvent( "stats", true ) exports[ 'scoreboard' ]:addScoreboardColumn( 'Race Wins' ) exports[ 'scoreboard' ]:addScoreboardColumn( 'Race Loses' ) exports[ 'scoreboard' ]:addScoreboardColumn( 'ratio' ) local restriction = { } function restrictionEnd( playerName ) restriction[ playerName ] = nil end function updateRatio ( thePlayer ) if isElement( thePlayer ) then local account = getPlayerAccount( theplayer ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 if loses == 0 then setAccountData( account, "ratio", "-" ) setElementData( thePlayer,'ratio', '-' ) else local kdr = round( wins / loses, 2 ) setAccountData( account, "ratio", kdr ) setElementData( thePlayer,'ratio', kdr ) end end end end function publicstatsinfo( ) if isElement( source ) then local account = getPlayerAccount( source ) if account then if isGuestAccount( account ) then return end local askdname = getPlayerName( source ) local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 local ratio = getAccountData( account, "Ratio" ) or 0 if loses and wins then outputChatBox("#FFA824*" .. askdname .. " won " .. tostring( wins ) .. " times and he lost " ..tostring( loses ).. " times, his ratio is " .. tostring( ratio ) .. "%", root, 255, 12, 15, true) else outputChatBox("#FFA824*" .. askdname .. " doesen't losed or won " , root, 255, 12, 15, true) end end else outputChatBox( "Error source is not player" ) end end function checkCommand( message, messageType ) if messageType == 0 then if message == "!stats" then triggerEvent( "stats", source ) elseif message == "!st" then triggerEvent( "stats", source ) cancelEvent( ) end end end function getPlayerFromNamePart( thePlayerName ) local thePlayer = getPlayerFromName( thePlayerName ) if thePlayer then return thePlayer end for _,thePlayer in ipairs( getElementsByType 'player' ) do if string.find( string.gsub( getPlayerName( thePlayer ):lower( ),"#%x%x%x%x%x%x", "" ), thePlayerName:lower( ), 1, true ) then return thePlayer end end return false end function DestructionWin( vehicle ) local alivePlayers = getAlivePlayers( ) if #alivePlayers == 1 then if isElement( alivePlayers[1] ) then local account = getPlayerAccount( alivePlayers[1] ) if isGuestAccount( account ) then return end local count = tonumber( getAccountData( account,"Race Wins" ) or 0 ) + 1 setAccountData( account,"Race Wins",count ) setElementData( alivePlayers[1],'Race Wins', count ) outputChatBox ( "#FFA824The player " .. getPlayerName( alivePlayers[1] ) .. " won!", root, 255, 255, 255, true ) end else local account = getPlayerAccount( source ) if isGuestAccount( account ) then return end local loses = tonumber( getAccountData( account,"Race Loses" ) or 0 ) + 1 setAccountData( account,"Race Loses", loses ) setElementData( source,'Race Loses', loses ) end end addCommandHandler("stats", function ( thePlayer, cmd, whoToCheck ) local playerName = getPlayerName( thePlayer ) if restriction[ playerName ] then outputChatBox( "#FFA824You have to wait 30 seconds", thePlayer, 255, 0, 0, true ) else restriction[ playerName ] = true setTimer( restrictionEnd, 30000, 1, playerName ) local player = getPlayerFromNamePart( whoToCheck ) if player then local account = getPlayerAccount( player ) if account then if isGuestAccount( account ) then return end local wins = getAccountData( account, "Race Wins" ) or 0 local loses = getAccountData( account, "Race Loses" ) or 0 local ratio = math.max( 0, math.min( 100, math.floor( wins / ( loses + wins ) * 100 ) ) ) outputChatBox( "#FFA824*[sTATS] Player's "..tostring( getPlayerName( player ) ).." stats : " , root, 255, 12, 15, true ) outputChatBox( "#FFA824*Wins: "..tostring( wins ).."!", root, 255, 12, 15, true ) outputChatBox( "#FFA824*Loses: "..tostring( loses ).."!", root, 255, 12, 15, true ) outputChatBox( "#FFA824*Ratio: "..tostring( ratio ).."% !", root, 255, 12, 15, true ) end else outputChatBox( "Player not found!" ) end end end ) addEventHandler( 'onPlayerJoin',root, function( ) setElementData( source,'Race Wins', 0 ) setElementData( source,'Race Loses', 0 ) setElementData( source,'ratio', 0 ) end ) addEventHandler( "stats", root, publicstatsinfo ) addEventHandler( "onPlayerChat", root, checkCommand ) addEventHandler( "onPlayerRaceWasted", root,DestructionWin )
  12. You can use https://wiki.multitheftauto.com/wiki/Ser ... _functions. But drawing functions in client side https://wiki.multitheftauto.com/wiki/Cli ... _functions better anyway.
  13. No. You need use setElementData/getElementData. Algorithm. Map started -> sql request if map have in table then setElementData -> get data -> draw in( onClientRender ).
  14. Kenix

    Nitro Color

    Yes. In all vehicles same nitro color.
  15. Client addEvent( "play", true ) local sound function play ( ) local x,y,z = getElementPosition( source ) if isElement( sound ) then setElementPosition( sound,x,y,z ) else sound = playSound3D( 'http://stream.electroradio.ch:26630/listen.pls', x,y,z ) setSoundVolume( sound, 1.0 ) -- max 1.0 not 10 setSoundMaxDistance( sound, 100 ) end end addEventHandler( "play",root, play ) Server local timer = { } function play2 ( thePlayer ) if isTimer( timer[ thePlayer ] ) then killTimer( timer[ thePlayer ] ) end timer[ thePlayer ] = setTimer( function( player ) triggerClientEvent ( "play", player ) end, 1000, 0 ,thePlayer ) end addCommandHandler( "play", play2 ) addEventHandler( 'onPlayerQuit',root, function( ) timer[ source ] = nil end ) Updated again.
  16. https://wiki.multitheftauto.com/wiki/Slothman/Slothbot
  17. function msToSeconds( int ) if type( int ) == 'number' then return int/1000 end return false end
  18. Лучше бы о себе подумали. Предлагаю закончить эту беседу. Ибо нет смысла разговаривать с вами.
×
×
  • Create New...