Jump to content

Kenix

Retired Staff
  • Posts

    4,121
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Kenix

  1. onClientResourceStart --> trigger to server --> get data( what you need ip and etc ) --> trigger to client --> guiSetText. It very easy.
  2. Kenix

    Need Scripts

    LOL,Just read this: http://www.lua.org/manual/5.1/ http://lua-users.org/wiki/SampleCode And test examples here: http://www.lua.org/cgi-bin/demo
  3. It is easy to implement. If you know the sequence of actions.
  4. I kept my word. Tested. local bStates = { } function lockveh ( uPlayer ) if bStates[ uPlayer ] then local uVehicle = getPedOccupiedVehicle ( uPlayer ) if isPedInVehicle ( uPlayer ) then local data = getElementData( uVehicle,'occupiedVehicle' ) if not data or not data[2] then outputChatBox ( "Your vehicle has been locked.", uPlayer, 255, 0, 0 ) setElementData( uVehicle, "occupiedVehicle", { uPlayer,true } ) setVehicleLocked ( uVehicle, true ) else outputChatBox ( "Your vehicle has been unlocked.", uPlayer, 0, 255, 0 ) setElementData( uVehicle, "occupiedVehicle", { uPlayer,false } ) setVehicleLocked ( uVehicle, false ) end end end end function bindL( veh ) local data = getElementData( veh,'occupiedVehicle' ) if data then if data[1] == source then bStates[ source ] = true end else bStates[ source ] = true end end addEventHandler ( "onPlayerVehicleEnter", root, bindL ) addEventHandler( 'onVehicleStartEnter',root, function( player ) local data = getElementData( source,'occupiedVehicle' ) if data then if isVehicleLocked( source ) and data[1] == player then setVehicleLocked ( source, false ) end end end ) addEventHandler( 'onPlayerJoin',root, function( ) bindKey ( source, "l", "down", lockveh ) end ) addEventHandler( 'onPlayerQuit',root, function( ) bStates[ source ] = nil end ) addEventHandler( 'onResourceStart',root, function( ) for _,v in pairs( getElementsByType 'player' ) do bindKey ( v, "l", "down", lockveh ) end end ) addEventHandler ( "onPlayerVehicleExit", root, function( veh ) local data = getElementData( veh,'occupiedVehicle' ) if data then if data[1] == source and data[2] then setVehicleLocked ( veh, true ) end end bStates[ source ] = false end ) So if you lock your vehicle then nobody can't enter to vehicle, but only you can enter to vehicle. If you need explain this just say.
  5. I not understand what you need. Explain better please.
  6. Изучи луа нормально , иначе дальше не продвинешься. 1.В твоём коде переменная angle nil .Т.е картинка не будет показываться полюбому( даже дебаг бы написал , но ты как я вижу даже не включил дебаг и не проверил , что он выводит ). 2.В функции isLineOfSightClear 14 параметров всего , а ты юзаешь 13 и на 13 у тебя элемент ( localPlayer ( локальный игрок ) ).( На вики не совсем правильный пример ) addEventHandler( "onClientRender",root, function( ) local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix( ) for _, v in ipairs( getElementsByType 'player' ) do tx, ty, tz = getElementPosition( v ) dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) if dist < 30.0 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then local sx, sy, sz = getPedBonePosition( v, 5 ) local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.3 ) if x then -- getScreenFromWorldPosition returns false if the point isn't on screen dxDrawImage ( x, y, x, y, 'admintag.png', 0, 0, -120 ) end end end end end ) Я надеюсь ты прочёл мой пост , а не копи паст сразу. P.S Подправил пример на вики.
  7. Kenix

    About Tables

    2.answer. You need create 100 or something count pickups. Then if player hit pickup check ( if player not hit this pickup ) . Or better this: if player login , just create pickup which player not hit.( if player not hit just not create this pickups ) You can use for this: function table.serialize( t ) if not t or type( t ) ~= 'table' then return false end -- if nil or not a table local buf = '{' for key,value in pairs( t ) do local v_type,k_type = type( value ),type( key ) if v_type ~= 'userdata' and k_type ~= 'userdata' -- ignore fields and keys witch contain userdata, thread or function and v_type ~= 'thread' and k_type ~= 'thread' and v_type ~= 'function' and k_type ~= 'function' then if k_type == 'number' then buf = buf .. '['..key..'] = ' else buf = buf .. '[\''..key..'\'] = ' end if v_type == 'table' then value = table.serialize( value ) elseif v_type == 'string' then value = '\''..value..'\'' else value = tostring( value ) end buf = buf .. value if next( t,key ) then buf = buf..',' end end end return buf .. '}' end and this function table.deserialize( s ) if type( s ) == 'string' then local getTableFromString = loadstring( 'return '..s ) local t = getTableFromString( ) if type( t ) ~= 'table' then return false end return t end return false end Syntax and etc you can see here: viewtopic.php?f=141&t=33091
  8. Сделай таймер и проверяй в нём. Если сходится , то убивай таймер и вызывай дальше , что нужно тебе.
  9. 3д картинка мб? getPedBonePosition getScreenFromWorldPosition dxDrawImage Всё в рендере.
  10. function lockveh ( uPlayer ) local uVehicle = getPedOccupiedVehicle ( uPlayer ) if isPedInVehicle ( uPlayer ) then --if not isVehicleLocked ( uVehicle ) then local data = getElementData( uVehicle,'occupiedVehicle' ) if data then outputChatBox ( "Your vehicle has been unlocked.", uPlayer, 0, 255, 0 ) setElementData( uVehicle, "occupiedVehicle", { uPlayer,false } ) else outputChatBox ( "Your vehicle has been locked.", uPlayer, 255, 0, 0 ) setElementData( uVehicle, "occupiedVehicle", { uPlayer,true } ) end --end end end function bindL( veh ) local data = getElementData( veh,'occupiedVehicle' ) if data then if data[1] == source then bindKey ( source, "l", "down", lockveh ) else removePedFromVehicle( source ) end else bindKey ( source, "l", "down", lockveh ) end end addEventHandler ( "onPlayerVehicleEnter", root, bindL ) addEventHandler ( "onPlayerVehicleExit", root, function( veh ) local data = getElementData( veh,'occupiedVehicle' ) if data then if data[1] == source and data[2] then setVehicleLocked ( uVehicle, true ) end end end )
  11. function lockveh ( uPlayer ) local uVehicle = getPedOccupiedVehicle ( uPlayer ) if isPedInVehicle ( uPlayer ) then --if not isVehicleLocked ( uVehicle ) then if getElementData( uVehicle,'occupiedVehicle' )[2] then outputChatBox ( "Your vehicle has been unlocked.", uPlayer, 0, 255, 0 ) setElementData( uVehicle, "occupiedVehicle", { uPlayer,false } ) else outputChatBox ( "Your vehicle has been locked.", uPlayer, 255, 0, 0 ) setElementData( uVehicle, "occupiedVehicle", { uPlayer,true } ) end --end end end function bindL( veh ) local data = getElementData( veh,'occupiedVehicle' )[1] if data then if data == source then bindKey ( source, "l", "down", lockveh ) else removePedFromVehicle( source ) end else bindKey ( source, "l", "down", lockveh ) end end addEventHandler ( "onPlayerVehicleEnter", root, bindL ) addEventHandler ( "onPlayerVehicleExit", root, function( veh ) if getElementData( veh,'occupiedVehicle' )[1] == source and getElementData( veh,'occupiedVehicle' )[2] then setVehicleLocked ( uVehicle, true ) end end ) Rewrite again I want sleep.
  12. There is another way but it is very difficult.
  13. Stream ( internet radio ).
  14. function lockveh ( uPlayer ) local uVehicle = getPedOccupiedVehicle ( uPlayer ) if isPedInVehicle ( uPlayer ) then if not isVehicleLocked ( uVehicle ) then if getElementData ( uPlayer, "occupiedVehicle" ) then setVehicleLocked ( uVehicle, false ) outputChatBox ( "Your vehicle has been unlocked.", uPlayer, 0, 255, 0 ) else setVehicleLocked ( uVehicle, true ) outputChatBox ( "Your vehicle has been locked.", uPlayer, 255, 0, 0 ) end end end end function bindL( ) bindKey ( source, "l", "down", lockveh ) setElementData( source, "occupiedVehicle", getPlayerName( source ) ) end addEventHandler ( "onPlayerVehicleEnter", root, bindL ) Maybe you mean this? if not isVehicleLocked ( uVehicle ) then If your vehicle not locked? or i not understand you again Updated.
  15. Server function lockveh ( uPlayer ) local uVehicle = getPedOccupiedVehicle ( uPlayer ) if isPedInVehicle ( uPlayer ) then if isVehicleLocked ( uVehicle ) then if getElementData ( uPlayer, "occupiedVehicle" ) then setVehicleLocked ( uVehicle, false ) outputChatBox ( "Your vehicle has been unlocked.", uPlayer, 0, 255, 0 ) else setVehicleLocked ( uVehicle, true ) outputChatBox ( "Your vehicle has been locked.", uPlayer, 255, 0, 0 ) end end end end function bindL( ) bindKey ( source, "l", "down", lockveh ) setElementData( source, "occupiedVehicle", getPlayerName( source ) ) end addEventHandler ( "onPlayerVehicleEnter", root, bindL ) Example You use cmd /setSome 1 You use cmd /getSome it returned 1 addCommandHandler( 'setSome', function( player,_,value ) if value then setElementData( player,'some',value ) end end ) addCommandHandler( 'getSome', function( player ) outputChatBox( 'getSome -- > '..tostring( getElementData( player,'some' ) ) ) end ) Example 2: addCommandHandler( 'occupiedVehicles', function( player ) local t = { } for _,v in pairs( getElementsByType 'player' ) do if getElementData( v,'occupiedVehicle' ) then t[ #t + 1 ] = v end end outputChatBox( 'Players occupied vehicles list:\n'..table.concat( t,'\n' ) ) t = nil end ) Example for your code. GanJaRuleZ said right. Updated post. In this situation you not need use setElementData/getElementData.
  16. fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi( player, seat, jacked ) if source == fbi1 or source == fbi2 or source == fbi3 then if (seat == 0) then if not isObjectInACLGroup("user."..getAccountName( getPlayerAccount( player ) ), aclGetGroup( "FBI" ) ) and not isObjectInACLGroup("user."..getAccountName( getPlayerAccount( player ) ), aclGetGroup( "Admin" ) ) then cancelEvent() outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end end end addEventHandler ( "onVehicleStartEnter", root, lockfbi ) My bad:/ Tested
  17. It should work only for Admins and FBI groups.
  18. You need find this functions ( in paradise gm ) responsible for this.
  19. local enginelessVehicle = { [510]=true, [509]=true, [481]=true } local odometer -- draw the odometer as soon as the player enters the car. function showOdometer( theVehicle, seat ) if not isElement( odometer ) then local id = getElementModel( theVehicle ) if (seat < 2) then if not (enginelessVehicle[id]) then -- If the vehicle has an engine. local x, y = guiGetScreenSize() local vehicle = getPedOccupiedVehicle( source ) local km = getElementData(vehicle, "odometer") local km = math.floor(km/1000) local odoKM = string.format("%07d", km) odometer = guiCreateLabel(x-138, y-215, 200, 200, tostring(odoKM), false) guiSetFont(odometer, "default-bold-small") kilo = guiCreateLabel(x-122, y-202, 200, 200, "km", false) guiSetFont(kilo, "default-bold-small") end end end end addEventHandler("onClientPlayerVehicleEnter", getLocalPlayer(), showOdometer) -- hide the odometer as soon as the player exits the car. function hideOdometer( ) if not (isVehicleLocked(source)) then setTimer( -- So that the odometer doesn't disappear as soon as you press 'F'. function() if (odometer) then destroyElement(odometer) odometer = nil end if (kilo) then destroyElement(kilo) kilo = nil end end, 1700, 1) end end addEventHandler("onClientVehicleStartExit", getLocalPlayer(), hideOdometer) -- update the odometer as the player moves in his vehicle. function updateOdometer( currentKilometers ) if isElement( odometer ) then if (guiGetVisible(odometer)) then local currentKilometers = math.floor(currentKilometers/1000) local odoKM = string.format("%07d", currentKilometers) guiSetText(odometer, tostring(odoKM)) end end end addEvent("updateOdo", true) addEventHandler("updateOdo", getLocalPlayer(), updateOdometer) -- remove the odometer if the player is not a in a vehicle but he is still seeing it. function removeOdometer() if not (isPedInVehicle(getLocalPlayer())) then if (odometer) then destroyElement(odometer) odometer = nil end if (kilo) then destroyElement(kilo) kilo = nil end end end setTimer(removeOdometer, 50, 0) Not understand
  20. fbi1 = createVehicle ( 596, -2429.7998046875, 515.2998046875, 29.700000762939, 0, 0, 215.99670410156 ) fbi2 = createVehicle ( 596, -2425.69921875, 518.5, 29.700000762939, 0, 0, 221.99523925781 ) fbi3 = createVehicle ( 596, -2422.3994140625, 521.599609375, 29.700000762939, 0, 0, 225 ) function lockfbi( player, seat, jacked ) if source == fbi1 or source == fbi2 or source == fbi3 then if (seat == 0) then if not isObjectInACLGroup("user."..getAccountName( getPlayerAccount( player ) ), aclGetGroup( "FBI" ) ) and not isObjectInACLGroup("user."..getAccountName( getPlayerAccount( player ) ), aclGetGroup( "Admin" ) ) then cancelEvent() outputChatBox ( "Only FBI can enter this vehicle", player, 0, 0, 150, true ) end end end end addEventHandler ( "onVehicleStartEnter", root, lockfbi ) TAPL:aclGetGroup( "FBI" or "Admin" ) incorrect , because if value nil or false then used operator 'or'. Example g = false print( g or 0 ) -- 0
  21. Try local enginelessVehicle = { [510]=true, [509]=true, [481]=true } local odometer -- draw the odometer as soon as the player enters the car. function showOdometer( theVehicle, seat ) if not guiGetVisible( odometer ) then local id = getElementModel( theVehicle ) if (seat < 2) then if not (enginelessVehicle[id]) then -- If the vehicle has an engine. local x, y = guiGetScreenSize() local vehicle = getPedOccupiedVehicle( source ) local km = getElementData(vehicle, "odometer") local km = math.floor(km/1000) local odoKM = string.format("%07d", km) odometer = guiCreateLabel(x-138, y-215, 200, 200, tostring(odoKM), false) guiSetFont(odometer, "default-bold-small") kilo = guiCreateLabel(x-122, y-202, 200, 200, "km", false) guiSetFont(kilo, "default-bold-small") end end end end addEventHandler("onClientPlayerVehicleEnter", getLocalPlayer(), showOdometer) -- hide the odometer as soon as the player exits the car. function hideOdometer( ) if not (isVehicleLocked(source)) then setTimer( -- So that the odometer doesn't disappear as soon as you press 'F'. function() if (odometer) then destroyElement(odometer) odometer = nil end if (kilo) then destroyElement(kilo) kilo = nil end end, 1700, 1) end end addEventHandler("onClientVehicleStartExit", getLocalPlayer(), hideOdometer) -- update the odometer as the player moves in his vehicle. function updateOdometer( currentKilometers ) if isElement( odometer ) then if (guiGetVisible(odometer)) then local currentKilometers = math.floor(currentKilometers/1000) local odoKM = string.format("%07d", currentKilometers) guiSetText(odometer, tostring(odoKM)) end end end addEvent("updateOdo", true) addEventHandler("updateOdo", getLocalPlayer(), updateOdometer) -- remove the odometer if the player is not a in a vehicle but he is still seeing it. function removeOdometer() if not (isPedInVehicle(getLocalPlayer())) then if (odometer) then destroyElement(odometer) odometer = nil end if (kilo) then destroyElement(kilo) kilo = nil end end end setTimer(removeOdometer, 50, 0) Updated.
×
×
  • Create New...