Jump to content

Kenix

Retired Staff
  • Posts

    4,121
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Kenix

  1. Kenix

    big lol

    No problem I going sleep.
  2. Kenix

    big lol

    Learn it http://www.lua.org/manual/5.1/ https://wiki.multitheftauto.com/wiki/Scr ... troduction source in your code nil. This correct. Server local timer = { } addEventHandler( 'onPlayerLogin',root, function( ) timer[ source ] = setTimer( function( player ) local account = getPlayerAccount( player ) if not isGuestAccount( account ) then local money = getPlayerMoney( player ) if money <= 1000 then setAccountData( account,'My Level','New User' ) setElementData( player,'Level','New User' ) elseif money <= 5000 and money > 1000 then setAccountData( account,'My Level','Regular' ) setElementData( player,'Level','Regular' ) elseif money <= 20000 and money > 1000 then setAccountData( account,'My Level','Experienced' ) setElementData( player,'Level','Experienced' ) elseif money <= 45000 and money > 20000 then setAccountData( account,'My Level','Veteran' ) setElementData( player,'Level','Veteran' ) elseif money > 45000 then setAccountData( account,'My Level','Guru' ) setElementData( player,'Level','Guru' ) end end end, 500,0,source ) end ) addEventHandler( 'onPlayerQuit',root, function( ) timer[ source ] = nil end ) If you create timer in server side and you update player stats or something ,better create with table and player is index. Remember it
  3. Kenix

    big lol

    Show full code maybe?
  4. GanJaRuleZ,Your code is wrong. https://wiki.multitheftauto.com/wiki/Scr ... troduction http://www.lua.org/manual/5.1/manual.html
  5. Kenix

    i need help

    Try Server side. function plantWeedForPlayer( thePlayer, command ) local x,y,z = getElementPosition( thePlayer ) local weed = createObject( 2241,x + 1,y,z - 0.5 ) setTimer( destroyElement, 5000, 1, weed ) addEventHandler ("onElementDestroy", weed, growWeed) end addCommandHandler( "plantseeds", plantWeedForPlayer ) function growWeed ( ) local x, y, z = getElementPosition ( source ) grass = createObject ( 3409, x, y, z - 1 ) end Use /debugscript 3.
  6. You need use getCursorPosition in event onClientRender and check offsets rectangle. Client side example. local scrX, scrY = guiGetScreenSize( ) addCommandHandler( 'mouse_show', function( ) showCursor( not isCursorShowing( ) ) end ) addEventHandler( 'onClientRender',root, function( ) if isCursorShowing( ) then local x, y = getCursorPosition( ) x, y = scrX * x, scrY * y if x >= 537 and x <= 537-50+250 and y >= 745 and y <= 787-50+50 then dxDrawText( 'test',537.0,745.0,703.0,787.0,tocolor( 255,255,255,255 ),2.0,"default","center","center",false,false,false ) else dxDrawText( 'test',537.0,745.0,703.0,787.0,tocolor( 255,255,255,150 ),2.0,"default","center","center",false,false,false ) end end end ) You can create same with rectangle. Just change offsets.
  7. Kenix

    Weapon Stats

    function table.string( t,name,notVar ) if type( t ) ~= 'table' then return false end local eStr if notVar then eStr = '{ ' else eStr = tostring( name or 'Table' )..' = { ' end for i,v in pairs( t ) do eStr = eStr.."["..tostring( i ).."] = "..tostring( v ).."," end return eStr:sub( 0,#eStr - 1 ).." }" end function saveWeaponStats( player ) if isElement( player ) then local account = getPlayerAccount( player ) if not isGuestAccount( account ) then local stats = { } for stat = 69, 81 do stats[ stat ] = getPedStat( player, stat ) end setAccountData( account, "weaponStats", table.string( stats,_,true ) ) stats = nil end end return false end function loadWeaponStats( player ) if isElement( player ) then local account = getPlayerAccount( player ) if not isGuestAccount( account ) then local statsData = getAccountData( account,"weaponStats" ) if statsData then loadstring( 'for i,v in pairs( '..statsData..' ) do '.. 'setPedStat( '..player..',i,v ) '.. 'end' )( ) end end end end addEventHandler("onPlayerQuit",root,function () saveWeaponStats( source ) end ) addEventHandler("onPlayerLogin",root,function () loadWeaponStats( source ) end ) Updated.
  8. For easy check money and take. Why write the same thing? If you can call function and check --> take money.
  9. takeMoney = function( player,cash ) if getPlayerMoney ( player ) >= tonumber( cash ) then return takePlayerMoney ( player,cash ) end return false end errorOutput = function( text,player ) return outputChatBox( text,player,255,0,0 ) end addCommandHandler( 'nitro', function( player ) local veh = getPedOccupiedVehicle( player ) if veh then if takeMoney( player,500 ) then addVehicleUpgrade( veh,1010 ) else errorOutput ( "You don't have money!",player ) end end end ) addCommandHandler( 'flip', function( player ) local veh = getPedOccupiedVehicle( player ) if veh then if takeMoney( player,500 ) then setElementRotation( veh,0,0,0 ) else errorOutput ( "You don't have money!",player ) end end end ) addCommandHandler( 'repair', function( player ) local veh = getPedOccupiedVehicle( player ) if veh then if takeMoney( player,500 ) then setElementHealth( veh,1000 ) else errorOutput ( "You don't have money!",player ) end end end )
  10. https://wiki.multitheftauto.com/wiki/Event localPlayer used only in client side. viewtopic.php?f=91&t=39678
  11. Некоторые игры можно давольно легко сделать. А вот некоторые нет , особенно если дело идёт о качестве и в правильных руках . Чтобы сделать что-то хорошое, нужно потратить немало времени.
  12. Через exports или call Код .. ресурса. addCommandHandler( "set_style", function( source,_,num ) exports['cw_hud']:setPedFightingStyle ( source, tonumber( num ) ) end ) И ещё в твоём ресурсе ( cw_hud ) должен быть экспорт функции ( setPedFightingStyle ) в мете. Я только-что проверил у меня всё работает ..
  13. Kenix

    accounts.xml

    https://wiki.multitheftauto.com/wiki/Ser ... #autologin ?
  14. Kenix

    Mysql table

    Try maybe i wrong... function stworzElementyDomu( ) local query = dbQuery( arp_db, "SELECT * FROM house" ) local result, numrows, errmsg = dbPoll ( query, -1 ) if numrows > 0 then for i = 1,#result do if result[i]["ox"] and result[i]["oy"] and result[i]["oz"] then createObject( 1239,result[i]["ox"],result[i]["oy"],result[i]["oz"] ) outputChatBox( "tworze" ) end end end dbFree( query ) end addEventHandler( "onResourceStart",resourceRoot,stworzElementyDomu )
  15. Я думаю нужно понимать что ты пишешь в коде. Дата элемента 'style' делается для игрока когда он входит на сервер. function FSHUD( ) setPedFightingStyle ( source, 6 ) local FSstatus = getPedFightingStyle ( source ) setElementData( source,"style",FSstatus ) end addEventHandler ( "onPlayerJoin",root, FSHUD ) Дополнение к коду. Вызывай из другого ресурса функцию setPedFightingStyle. addEvent( "onPedFightingStyleChange",true ) _setPedFightingStyle = setPedFightingStyle function setPedFightingStyle ( source, numb ) if isElement( source ) and type( numb ) == 'number' then local t = { [4] = true,[5] = true,[6] = true,[7] = true,[15] = true,[16] = true } if t[ numb ] then triggerEvent( "onPedFightingStyleChange",source,getPedFightingStyle( source ),numb ) return _setPedFightingStyle( source,numb ) end end return false end addEventHandler( "onPedFightingStyleChange",root, function( old,new ) if getElementType( source ) == 'player' then setElementData( source,"style",new ) end end ) Полный код. addEvent( "onPedFightingStyleChange",true ) _setPedFightingStyle = setPedFightingStyle function setPedFightingStyle ( source, numb ) if isElement( source ) and type( numb ) == 'number' then local t = { [4] = true,[5] = true,[6] = true,[7] = true,[15] = true,[16] = true } if t[ numb ] then triggerEvent( "onPedFightingStyleChange",source,getPedFightingStyle( source ),numb ) return _setPedFightingStyle( source,numb ) end end return false end function FSHUD( ) setPedFightingStyle ( source, 6 ) end addEventHandler ( "onPlayerJoin",root, FSHUD ) addEventHandler( "onPedFightingStyleChange",root, function( old,new ) if getElementType( source ) == 'player' then setElementData( source,"style",new ) end end ) Что тут трудного?
  16. Victor214,Your code is litle wrong . NeXTreme's code is correct and should work idk Victor214 how you tested it. You not need use variable source in argument function because event called source and you replace source with nil. https://wiki.multitheftauto.com/wiki/Event Client --... function Scripting ( ) triggerServerEvent("spawnPed", localPlayer ) -- localPlayer is source end --... Server function spawnPed ( ) local x,y,z = getElementPosition ( source ) -- source is player pedio = createPed ( 0, x-2, y+2, z ) end addEvent( "spawnPed", true ) addEventHandler( "spawnPed", root,spawnPed ) P.S Use /debugscript 3 in next time.
  17. getElementsByType( "object" )
  18. Kenix

    Teleports

    GUIEditor_Window = { } GUIEditor_Button = { } GUIEditor_Memo = { } GUIEditor_Grid = { } GUIEditor_Window[1] = guiCreateWindow( 0.2884,0.2591,0.3909,0.6536,"Teleporter by Twisted",true ) guiSetVisible( GUIEditor_Window[1],false ) showCursor( false) GUIEditor_Grid[1] = guiCreateGridList( 0.0562,0.1116,0.6161,0.8167,true,GUIEditor_Window[1] ) guiGridListSetSelectionMode( GUIEditor_Grid[1],1 ) guiGridListAddColumn( GUIEditor_Grid[1],"Teleports",0.5) GUIEditor_Button[1] = guiCreateButton( 0.6854,0.8327,0.2884,0.0916,"Close",true,GUIEditor_Window[1] ) guiSetProperty( GUIEditor_Button[1],"NormalTextColor","FF00FF00" ) GUIEditor_Memo[1] = guiCreateMemo( 0.6985,0.1355,0.2659,0.6713,"This teleporter script was made by Twisted and should not be shared without concent Copyrighted(C) Double click the Teleporter u wish to Travel too <!-- s:) --><img src=\"{SMILIES_PATH}/icon_smile.gif\" alt=\"\" title=\"Smile\" /><!-- s:) --> ",true,GUIEditor_Window[1] ) guiMemoSetReadOnly( GUIEditor_Memo[1],true ) function open( ) if guiGetVisible( GUIEditor_Window[1] ) then guiSetVisible( GUIEditor_Window[1],false ) showCursor( false ) else guiSetVisible( GUIEditor_Window[1],true ) showCursor( true ) addTeleports( ) end end bindKey( "F4","down",open ) function close() if source == GUIEditor_Button[1] then guiSetVisible( GUIEditor_Window[1],false ) showCursor( false ) end end addEventHandler("onClientGUIClick",root,close) function addTeleports() guiGridListClear( GUIEditor_Grid[1] ) if guiGetVisible(GUIEditor_Window[1]) == true then local file = xmlLoadFile "Teleports.xml" if file then for i,v in ipairs( xmlNodeGetChildren( file ) ) do local name = xmlNodeGetAttribute( v,"name") local row = guiGridListAddRow( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, tostring(name), false, true ) end end end end function teleport( ) local row,col = guiGridListGetSelectedItem( source ) if row and col and row ~= -1 and col ~= -1 then local name = guiGridListGetItemText( source, row, 1 ) local file = xmlLoadFile "Teleports.xml" if file then for i,v in ipairs( xmlNodeGetChildren( file ) ) do local teleportName = xmlNodeGetAttribute( v,"name" ) if teleportName == name then local poX = xmlNodeGetAttribute( v,"posX" ) local poY = xmlNodeGetAttribute( v,"posY" ) local poZ = xmlNodeGetAttribute( v,"posZ" ) setElementPosition( getPedOccupiedVehicle( localPlayer ) or localPlayer, tonumber( poX ), tonumber( poY ), tonumber( poZ + 2 ) ) end end end end end addEventHandler( "onClientGUIDoubleClick",GUIEditor_Grid[1],teleport,false ) Just poZ + 2.Regulate it if needed.( line 63 ) Or you can use function getGroundPosition.
  19. Kenix

    Teleports

    I not understand what you mean.
  20. Kenix

    Teleports

    GUIEditor_Window = { } GUIEditor_Button = { } GUIEditor_Memo = { } GUIEditor_Grid = { } GUIEditor_Window[1] = guiCreateWindow( 0.2884,0.2591,0.3909,0.6536,"Teleporter by Twisted",true ) guiSetVisible( GUIEditor_Window[1],false ) showCursor( false) GUIEditor_Grid[1] = guiCreateGridList( 0.0562,0.1116,0.6161,0.8167,true,GUIEditor_Window[1] ) guiGridListSetSelectionMode( GUIEditor_Grid[1],1 ) guiGridListAddColumn( GUIEditor_Grid[1],"Teleports",0.5) GUIEditor_Button[1] = guiCreateButton( 0.6854,0.8327,0.2884,0.0916,"Close",true,GUIEditor_Window[1] ) guiSetProperty( GUIEditor_Button[1],"NormalTextColor","FF00FF00" ) GUIEditor_Memo[1] = guiCreateMemo( 0.6985,0.1355,0.2659,0.6713,"This teleporter script was made by Twisted and should not be shared without concent Copyrighted(C) Double click the Teleporter u wish to Travel too <!-- s:) --><img src=\"{SMILIES_PATH}/icon_smile.gif\" alt=\"\" title=\"Smile\" /><!-- s:) --> ",true,GUIEditor_Window[1] ) guiMemoSetReadOnly( GUIEditor_Memo[1],true ) function open( ) if guiGetVisible( GUIEditor_Window[1] ) then guiSetVisible( GUIEditor_Window[1],false ) showCursor( false ) else guiSetVisible( GUIEditor_Window[1],true ) showCursor( true ) addTeleports( ) end end bindKey( "F4","down",open ) function close() if source == GUIEditor_Button[1] then guiSetVisible( GUIEditor_Window[1],false ) showCursor( false ) end end addEventHandler("onClientGUIClick",root,close) function addTeleports() guiGridListClear( GUIEditor_Grid[1] ) if guiGetVisible(GUIEditor_Window[1]) == true then local file = xmlLoadFile "Teleports.xml" if file then for i,v in ipairs( xmlNodeGetChildren( file ) ) do local name = xmlNodeGetAttribute( v,"name") local row = guiGridListAddRow( GUIEditor_Grid[1] ) guiGridListSetItemText ( GUIEditor_Grid[1], row, 1, tostring(name), false, true ) end end end end function teleport( ) local row,col = guiGridListGetSelectedItem( source ) if row and col and row ~= -1 and col ~= -1 then local name = guiGridListGetItemText( source, row, 1 ) local file = xmlLoadFile "Teleports.xml" if file then for i,v in ipairs( xmlNodeGetChildren( file ) ) do local teleportName = xmlNodeGetAttribute( v,"name" ) if teleportName == name then local poX = xmlNodeGetAttribute( v,"posX" ) local poY = xmlNodeGetAttribute( v,"posY" ) local poZ = xmlNodeGetAttribute( v,"posZ" ) setElementPosition( getPedOccupiedVehicle( localPlayer ) or localPlayer, tonumber( poX ), tonumber( poY ), tonumber( poZ ) ) end end end end end addEventHandler( "onClientGUIDoubleClick",GUIEditor_Grid[1],teleport,false ) Updated again. P.S xmlLoadFile "Teleports.xml" -- this is not mistake we can call function if one argument and if it argument string xmlLoadFile [[Teleports.xml]] -- same http://www.lua.org/manual/5.1/manual.html
  21. https://wiki.multitheftauto.com/wiki/Meta.xml <meta> <script src="s.lua" type="server" /> <!-- server side script --> <script src="c.lua" type="client" /> <!-- client side script --> </meta>
  22. Kenix

    mdc line

    Your variable guiMdcWindow is nil https://wiki.multitheftauto.com/wiki/Int ... ng_the_GUI
×
×
  • Create New...