Jump to content

Kenix

Retired Staff
  • Posts

    4,121
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Kenix

  1. Kenix

    little problem

    Server addEvent( 'onAcceptJob',true ) addEventHandler( 'onAcceptJob',root, function( ) setPlayerTeam ( source,getTeamFromName( 'Police' ) ) setElementModel ( source, 280 ) end ) addEventHandler ( 'onResourceStart', resourceRoot, function( ) createTeam ( "Police", 25, 50, 255 ) end ) Client local jobMarker = createMarker ( 1574.700, -1634.300, 12.600, "cylinder", 1.5, 25, 50, 255, 255 ) function setJob( player, dim ) if player == localPlayer then local wanted = getPlayerWantedLevel ( ) if wanted == 0 then if not guiGetVisible( window ) then guiSetVisible( window, true ) showCursor( true ) elseif wanted > 0 then showCursor( false ) guiSetVisible( window, false ) end end end end addEventHandler( "onClientMarkerHit", jobMarker, setJob ) function acceptJob ( ) local uTeam = getPlayerTeam( localPlayer ) if uTeam and getTeamName ( uTeam ) ~= 'Police' then triggerServerEvent( 'onAcceptJob',localPlayer ) guiSetVisible( window, false ) showCursor( false ) outputChatBox ( "You are now police officer.", thePlayer, 0,255, 0 ) else outputChatBox ( "You are wanted, you can not take this job.", thePlayer, 255, 0, 0 ) end end addEventHandler( "onClientGUIClick", acceptButton , acceptJob, false ) You need learn https://wiki.multitheftauto.com/wiki/Scr ... troduction You should use in side( client or server ) appropriate function or event. Example if you create gui you need use in client side ( not in server side ) P.S variable window is defined? P.S updated.
  2. Kenix

    Got problem...

    guiCreateColorLabel,is return element in your script?
  3. addCommandHandler( 'create_vehicle', function( player,_,id_name ) local x,y,z = getElementPosition( player ) local model = getVehicleModelFromName( id_name ) if not model then model = tonumber( id_name ) end if createVehicle( model,x+1,y,z ) then outputChatBox( 'Success created: '..tostring( getVehicleNameFromModel( model ) ) ) else outputChatBox( 'Vehicle not created: '..tostring( getVehicleNameFromModel( model ) ) ) end end ) /create_vehicle [id/name]
  4. Kenix

    Got problem...

    My bad not see it. But anyway it should work. Tested.
  5. Kenix

    Got problem...

    addEvent( 'onAccountsSend',true ) local labels = { } addEventHandler( 'onAccountsSend',root, function( t ) if #labels == 0 then for index, data in ipairs( t ) do guiCreateColorLabel( 13,20 * index + 39,500,276,'#ffffff#'..tostring( index )..": "..tostring( data.account ),false,tab_leaderboard ) if index == 10 then break end end labels[ 1 ] = true end end ) I tested your resource. It working.
  6. Kenix

    addPedClothes

    for i = 0,17 do -- cycle from 0 to 17 local arg1,arg2 = getPedClothes( source, i ) -- get ped Clothes ( 0 - 17 ) setAccountData( playerAccount, -- player account "player.clothes."..tostring( i ), -- setAccountData in cycle from 0 to 17 tostring( arg1 )..","..tostring( arg2 ) -- tostring( because function getPedClothes can return false ( boolean type , not string ) ) ) end for i = 0,17 do -- cycle from 0 to 17 local acc = getAccountData( playerAccount, 'player.clothes.'..i ) -- getAccountData in cycle from 0 to 17 if not acc:find 'false' then -- Check if returned value getAccountData not have false ( If getAccountData have model/texture ) addPedClothes( source, -- element ( player in our case ) acc:sub( 1,acc:find( ',' ) - 1 ), -- return string from 1,( to the end until you find a character ',' ) example 100,1000 --[[ tostring( '100,1000' ):sub( 1,tostring( '100,1000' ):find( ',' ) - 1 ) So it return 100 You can test it in lua demo [url=http://www.lua.org/cgi-bin/demo]http://www.lua.org/cgi-bin/demo[/url] print( tostring( '100,1000' ):sub( 1,tostring( '100,1000' ):find( ',' ) - 1 ) ) ]] acc:sub( acc:find( ',' ) + 1,acc:len( ) ), --[[ -- return string from , and to string length -- tostring( '100,1000' ):sub( tostring( '100,1000' ):find( ',' ) + 1,tostring( '100,1000' ):len( ) ) -- return 1000 You can test it too in lua demo [url=http://www.lua.org/cgi-bin/demo]http://www.lua.org/cgi-bin/demo[/url] print( tostring( '100,1000' ):sub( tostring( '100,1000' ):find( ',' ) + 1,tostring( '100,1000' ):len( ) ) ) -- return 1000 ]] i ) -- add Ped Clothes cycle from 0 to 17 end end
  7. <meta> <info author="#BoSnA#" version="3.0" type="script" name="stats" description="this is shop,stats...." /> <script src="common.lua" type="server" /> <script src="core_client.lua" type="client" /> <script src="dxcolor_c.lua" type="client" /> <script src="panel_client.lua" type="client" /> <script src="textlib.lua" type="server" /> <script src="utility_client.lua" type="client" /> </meta> https://wiki.multitheftauto.com/wiki/Meta.xml
  8. Kenix

    Got problem...

    You have syntax problem with 'end'. Your code function theButtons() if source == btn_show_points then triggerServerEvent("recievePrefix", localPlayer, "Points") end addEventHandler ( "onClientGUIClick", btn_show_points, theButtons ) Correct function theButtons() if source == btn_show_points then triggerServerEvent("recievePrefix", localPlayer, "Points") end end addEventHandler ( "onClientGUIClick", btn_show_points, theButtons ) Tabulate code and you can see where you forgot 'end'.
  9. Kenix

    Got problem...

    Can you give me full code? I test it and fix. via pm.
  10. Kenix

    Got problem...

    addEvent( 'onAccountsSend',true ) local labels = { } addEventHandler( 'onAccountsSend',root, function( t ) for index, data in ipairs( t ) do if isElement( labels[ index ] ) then destroyElement( labels[ index ] ) end labels[ index ] = guiCreateColorLabel( 13,20 * index + 39,500,276,'#ffffff#'..tostring( index )..": "..tostring( data.account ),false,tab_leaderboard ) if index == 10 then break end end end )
  11. addEventHandler( 'onClientMarkerHit', yourMarkerElement, -- yourMarkerElement элемент маркер function( elem, dim ) if elem == localPlayer then -- Если игрок вошедший в маркер это локальный игрок то -- код end end )
  12. Kenix

    addPedClothes

    addEventHandler( "onPlayerQuit", root, function( ) local playerAccount = getPlayerAccount( source ) if playerAccount then local playerMoney = getPlayerMoney( source ) local playerSkin = getElementModel( source ) for i = 0,17 do local arg1,arg2 = getPedClothes( source, i ) setAccountData( playerAccount, "player.clothes."..tostring( i ),tostring( arg1 )..","..tostring( arg2 ) ) end setAccountData( playerAccount, "player.money", playerMoney ) setAccountData( playerAccount, "player.skin", playerSkin ) end end ) addEventHandler( "onPlayerLogin", root, function( ) local playerAccount = getPlayerAccount( source ) if playerAccount then local playerMoney = getAccountData( playerAccount, "player.money" ) local playerSkin = getAccountData( playerAccount, "player.skin" ) if playerMoney then setPlayerMoney( source, playerMoney ) setElementModel( source, playerSkin ) for i = 0,17 do local acc = getAccountData( playerAccount, 'player.clothes.'..i ) if not acc:find 'false' then addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) end end end end end )
  13. Server addEvent( "pilotJobx", true ) ----- pilot ------- function pilotjob ( ) if getPlayerNametagText ( source ) == "[COP]" then setPlayerNametagText ( source, getPlayerName ( source ) ) end setElementModel ( source, 61 ) takeWeapon ( source, 14 ) takeWeapon ( source, 23 ) takeWeapon ( source, 3 ) setPlayerTeam ( source, teampilot ) setPlayerNametagColor ( source, 148, 0, 211 ) --takeAllWeapons ( thePlayer ) setPedArmor ( source, 0 ) end addEventHandler( "pilotJobx", root, pilotjob ) Client pilotmark = createMarker( 1953.82,-2177.61,12.65,"cylinder",1,148,0,211,70 ) xWindow = guiCreateWindow( 0.3184,0.2568,0.2500,0.356,"",true ) buttonYes = guiCreateButton( 0.03,0.86,0.45,0.10,"yes!",true,xWindow ) buttonNo = guiCreateButton( 0.505,0.86,0.45,0.10,"no",true,xWindow ) guiSetVisible( xWindow,false ) addEventHandler( "onClientMarkerHit",pilotmark, function( hitElement, matchingDimension ) if hitElement == localPlayer then showCursor( true ) guiSetVisible( xWindow,not guiGetVisible( xWindow ) ) --guiCreateStaticImage (0.05, 0.2, 0.9, 0.5,"/bankrob.png",true,xWindow) addEventHandler ( "onClientGUIClick", buttonYes, function( ) showCursor( false ) guiSetVisible( xWindow,false ) triggerServerEvent( "pilotJobx", localPlayer ) --triggerServerEvent("ServerPlaySoundRobbery",localPlayer) ---outputChatBox( "`Вы захватили банк вы должны продержаться 5 минут.",255,0,0 ) end ,false ) addEventHandler ( "onClientGUIClick", buttonNo, function ( ) showCursor( false ) guiSetVisible( xWindow,false ) end ,false ) end end ) Updated. Variable teampilot is defined?
  14. function findPlayer( namepart ) local player = getPlayerFromName( namepart ) if player then return player end for _,player in pairs( getElementsByType 'player' ) do if string.find( string.gsub( getPlayerName( player ):lower( ),"#%x%x%x%x%x%x", "" ), namepart:lower( ), 1, true ) then return player end end return false end function sendMessage( thePlayer, _, id_nick, ... ) local find = ids[ tonumber( id_nick ) ] or findPlayer( id_nick ) if find then outputChatBox( "*PM Sent!",thePlayer,0,255,0 ) outputChatBox( "*PM from "..getPlayerName( thePlayer )..":"..table.concat( { ... },' ' ),find,255,255,0 ) else outputChatBox( "*Wrong id/name!",thePlayer,255,0,0 ) end end addCommandHandler( 'private_message',sendMessage ) /private_message [ ид/ник ][ сообщение ]
  15. 16 line is handler function parameters. 17 line call function and it function return player element or false 18 line check. You mean this? I made comments in the code Read please.
×
×
  • Create New...