Jump to content

Kenix

Retired Staff
  • Posts

    4,121
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Kenix

  1. Kenix

    Stats

    This is not good believe me, I also wrote some long ago . Just example: 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 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 What code better?
  2. Kenix

    Stats

    Solidsnake14,Why you not tabulate your code? You need tabulate your code , because someone not understand your code . You are Scripting moderator.
  3. Kenix

    XML question

    Use your xml to map You can use getElementsByType And you can use your house data/markers and etc. I always use this in gm , because you can create something in map editor and easy change it. In gm you just get data in map.
  4. Use function dxDrawColoredText function dxDrawColoredText(str, ax, ay, bx, by, color, scale, font,left,top) left = "left" if not top then top = "top" end local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font,left,top,true) ax = ax + w color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font,left,top,true) end end ( found in forum )
  5. Kenix

    Spawn help

    This should work addEventHandler( "onResourceStart", resourceRoot, function( ) resetMapInfo( ) for _,player in ipairs( getElementsByType 'player' ) do spawn( player ) end end ) function spawn( player ) if not isElement( player ) then return end showChat( player, true ) local acc = getPlayerAccount( player ) if acc and not isGuestAccount( acc ) then if isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "DanWesson" ) ) then repeat until spawnPlayer ( player, -49.161193847656, -225.46385192871, 5.4296875, 90, 287, 0, 0 ) elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "SWAT" ) ) then repeat until spawnPlayer ( player, -550.86010742188, 2594.9943847656, 53.93478012085, 90, 285, 0, 0 ) elseif isObjectInACLGroup ( "user.".. getAccountName( acc ), aclGetGroup ( "GBO" ) ) then repeat until spawnPlayer ( player, 1058.5606689453, 1279.9813232422, 10.8203125, 90, 120, 0, 0 ) end else outputChatBox( 'guest account' ) end fadeCamera( player, true ) setCameraTarget( player, player ) end addEventHandler( "onPlayerJoin", root, function( ) spawn( source ) end ) addEventHandler( "onPlayerWasted", root, function( ) setTimer( spawn, 1800, 1, source ) end ) You need be a logged. And not forgot about /debugscript 3.
  6. Бинго. Обычное явление особенно питере , когда каждый день трубы лопаются ...
  7. local scan_radius = 10 function getPointFromDistanceRotation(x, y, dist, angle) local a = math.rad(90 - angle); local dx = math.cos(a) * dist; local dy = math.sin(a) * dist; return x+dx, y+dy; end addEventHandler( 'onClientRender',root, function( ) local rot local bx,by,bz = getPedBonePosition( localPlayer,8 ) rot = ( rot or 0 ) + 1 if rot > 360 then rot = 0 end local nx,ny = getPointFromDistanceRotation( bx,by,scan_radius,rot ) local hit = processLineOfSight( bx,by,bz,nx,ny,bz, true, -- checkBuildings false, -- checkVehicles false, -- checkPlayers false, -- checkObjects false, -- checkDummies false, -- seeThroughStuff false, -- ignoreSomeObjectsForCamera false, -- shootThroughStuff nil, -- ignoredElement false -- includeWorldModelInformation ) if not hit then dxDrawText( 'not hit',200,200 ) end end ) This code for localPlayer just for test... If it working change for ped. Added:if line not hit then draw text 'not hit'. If you start something, you should start small.
  8. Kenix

    spawnPlayer

    I test it in runcode and in freeroam and i not lost weapons
  9. I use SQLite Database Browser Download http://downloads.sourceforge.net/projec ... or=citylan
  10. Full rewrite Client addEvent( 'onClientRobberMenu',true ) addEvent( 'onSoundRobbery',true ) addEvent( 'onSoundRobberyStop',true ) local bankWindow = guiCreateWindow( 0.3184,0.3568,0.3809,0.306,"ROBBER",true ) local buttonYes = guiCreateButton( 36,147,89,46,"Yes",false,bankWindow ) local buttonNo = guiCreateButton( 251,147,89,46,"No",false,bankWindow ) guiSetVisible( bankWindow,false ) addEventHandler( "onSoundRobbery",root, function( ) sound = playSound3D ( "alarm.mp3", 364.00500488281,163.38682556152,1010.3828125, true ) setSoundMaxDistance ( sound, 50 ) end ) addEventHandler( "onSoundRobberyStop",root, function( ) if isElement( sound ) then stopSound( sound ) end end ) addEventHandler( 'onClientRobberMenu',localPlayer, function( ) showCursor( true ) guiSetVisible( bankWindow,true ) addEventHandler ( "onClientGUIClick", buttonYes, function( ) showCursor( false ) guiSetVisible( bankWindow,false ) outputChatBox( "`Вы захватили банк вы должны продержаться 5 минут.",255,0,0 ) outputChatBox( "`Вы сможете захватить банк через 180 минут.",255,0,0 ) outputChatBox( "`Если вы выйдите из банка то миссия будет провалена!",255,0,0 ) triggerServerEvent( 'onStartRobber',localPlayer ) end ,false ) addEventHandler ( "onClientGUIClick", buttonNo, function ( ) showCursor( false ) guiSetVisible( bankWindow,false ) end ,false ) end ) Server addEvent( 'onStartRobber',true ) addEvent( 'onEndRobber',true ) local timer,timerOpenBank local bankMarker = createMarker( 364.00500488281,163.38682556152,1008.3828125,"cylinder",3,150,0,0,255 ) local bankBip = createBlip ( 2416.5532226563, 1124.1168212891, 10.8203125, 36, 2 ) setElementInterior( bankMarker,3,364.00500488281,163.38682556152,1007.4828125 ) local bankColshape = createColCircle ( 2414.1735839844,1123.9982910156,10.8203125,1 ) function findMarker( source ) if isElement( source ) then local ret = false for _,v in pairs( getElementsByType 'marker' ) do if getElementData( v,'attack' ) == source then ret = v end end return ret end return false end function resetRobber( ) setElementData( bankMarker,'attack',nil ) setElementData( bankColshape,'attackShape',nil ) end function setRobberDefault( ) if isTimer( timerOpenBank ) then killTimer( timerOpenBank ) end if isTimer( timer ) then killTimer( timer ) end setElementData( bankMarker,'attack',nil ) setElementData( bankColshape,'attackShape',nil ) setElementAlpha( bankMarker,255 ) setElementData( bankMarker,'protected',nil ) setElementData( bankColshape,'protectedShape',nil ) triggerClientEvent( 'onSoundRobberyStop',root ) end addEventHandler( 'onColShapeLeave',bankColshape, function( LeaveElement,dim ) if getElementType( LeaveElement ) == 'player' then if getElementData( source,'attackShape' ) == LeaveElement then outputChatBox( "`Миссия провалена вы не захватили банк!",LeaveElement,255,0,0 ) setRobberDefault( ) end end end ) addEventHandler( 'onPlayerWasted',root, function( ) if findMarker( source ) then outputChatBox( "`Миссия провалена вы не захватили банк!",source,255,0,0 ) setRobberDefault( ) end end ) addEventHandler( 'onPlayerQuit',root, function( ) if findMarker( source ) then setRobberDefault( ) end end ) addEventHandler( "onMarkerHit",bankMarker, function( hitElement, matchingDimension ) if getElementType( hitElement ) == 'player' then if not getElementData( source,'attack' ) and not getElementData( source,'protected' ) then triggerClientEvent( hitElement,'onClientRobberMenu',hitElement,source ) else outputChatBox( 'Кто-то захватывает банк ',hitElement,255,0,0 ) end end end ) addEventHandler( 'onEndRobber',root, function( marker ) setElementData( bankMarker,'protected','y' ) setElementData( bankColshape,'protectedShape','y' ) if isTimer( timerOpenBank ) then killTimer( timerOpenBank ) end timerOpenBank = setTimer( setRobberDefault,10000,1 ) -- время через которое банк можно будет снова ограбить end ) addEventHandler( 'onStartRobber',root, function( ) setElementAlpha( bankMarker, 0 ) setElementData( bankMarker,'attack',source ) setElementData( bankColshape,'attackShape',source ) setPlayerWantedLevel( source,6 ) triggerClientEvent( 'onSoundRobbery',root ) if isTimer( timer ) then killTimer( timer ) end timer = setTimer( function( player,mark ) outputChatBox( "`Вы успешно ограбили банк вы получили 100 000 $.",player,255,0,0 ) resetRobber( ) givePlayerMoney( player,100000 ) triggerClientEvent( 'onSoundRobberyStop',root ) triggerEvent( 'onEndRobber',player,mark ) end, 60000,1,source,bankMarker ) end ) Updated.
  11. Show full code. And try rename this cmd to set_team
  12. function setMyTeam( player,_,name ) if name then local team = getPlayerTeam( player ) if not team then if setPlayerTeam ( player, getTeamFromName( name ) ) then outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) else outputChatBox( "Can't set to team.", player, 255, 0, 0 ) end else outputChatBox( "Alreadly in team.", player, 255, 0, 0 ) end else outputChatBox( "SYNTAX: /setteam [team name].", player, 255, 0, 0 ) end end addCommandHandler ( "setteam", setMyTeam )
  13. Kenix

    spawnPlayer

    Yeah i find little problem. Server local tWeap = { } local tTimer = { } function table.empty( t ) if type( t ) ~= "table" then return false end return not next( t ) end local function giveWeaponsFromTable( source ) if not table.empty( tWeap[ source ] ) then if isElement( source ) then for _,v in pairs( tWeap[ source ] ) do giveWeapon( source,v[1],v[2],false ) end tWeap[ source ] = nil return true end return false end return false end local function getAllWeapons( source,ammo ) if isElement( source ) then local Table = { } for i = 0,12 do local weap = getPedWeapon ( source, i ) if not ammo then table.insert( Table,weap ) else local ammos = getPedTotalAmmo( source,i ) if ammos then table.insert( Table, { weap, ammos } ) end end end return Table end return false end addEventHandler( "onPlayerWasted",root, function( ) tWeap[ source ] = getAllWeapons( source,true ) end ) addEventHandler( "onPlayerSpawn",root, function( ) tTimer[ source ] = setTimer( giveWeaponsFromTable,300,1,source ) end ) addEventHandler( "onPlayerQuit",root, function( ) tWeap[ source ] = nil tTimer[ source ] = nil end ) Tested.
  14. local scan_radius = 10 function getPointFromDistanceRotation(x, y, dist, angle) local a = math.rad(90 - angle); local dx = math.cos(a) * dist; local dy = math.sin(a) * dist; return x+dx, y+dy; end addEventHandler( 'onClientRender',root, function( ) local rot local bx,by,bz = getPedBonePosition( localPlayer,8 ) rot = ( rot or 0 ) + 1 if rot > 360 then rot = 0 end local nx,ny = getPointFromDistanceRotation( bx,by,scan_radius,rot ) local hit = processLineOfSight( bx,by,bz,nx,ny,bz, true, -- checkBuildings false, -- checkVehicles false, -- checkPlayers false, -- checkObjects false, -- checkDummies false, -- seeThroughStuff false, -- ignoreSomeObjectsForCamera false, -- shootThroughStuff nil, -- ignoredElement false -- includeWorldModelInformation ) if not hit then -- ... end end ) Code updated. Try it.
  15. function setMyTeam( player ) local team = getPlayerTeam( player ) if team then outputChatBox( "Your team now is "..getTeamName( team )..".", player, 0, 255, 0 ) else outputChatBox( "Bara nayek.", player, 255, 0, 0 ) end end addCommandHandler ( "setteam", setMyTeam )
  16. Kenix

    spawnPlayer

    Try test it in play gm. Not forget use /debugscript 3
  17. Kenix

    New chat

    Very strange i not see errors ... i use 2 debuggers and not see error. Try convert to utf-8 without BOM
  18. Kenix

    spawnPlayer

    1. spawnPlayer takeAllWeapons 2. local tWeap = { } local tTimer = { } function table.empty( t ) if type( t ) ~= "table" then return false end return not next( t ) end local function giveWeaponsFromTable( source ) if not table.empty( tWeap[ source ] ) then if isElement( source ) then for _,v in pairs( tWeap[ source ] ) do giveWeapon( source,v[1],v[2],false ) end return true end return false end return false end local function getAllWeapons( source,ammo ) if isElement( source ) then local Table = { } for i = 0,12 do local weap = getPedWeapon ( source, i ) if not ammo then table.insert( Table,weap ) else local ammos = getPedTotalAmmo( source,i ) if ammos > 0 then table.insert( Table, { weap, ammos } ) end end end return Table end return false end addEventHandler( "onPlayerWasted",root, function( ) tWeap[ source ] = getAllWeapons( source,true ) end ) addEventHandler( "onPlayerSpawn",root, function( ) tTimer[ source ] = setTimer( giveWeaponsFromTable,300,1,source ) tWeap[ source ] = nil end ) addEventHandler( "onPlayerQuit",root, function( ) tWeap[ source ] = nil tTimer[ source ] = nil end ) Updated.
  19. Kenix

    New chat

    It should work.( i have debugger in notepad++ and i not see syntax errors ) You bad copypaste Show code in 1084 line.
  20. You should use source in event https://wiki.multitheftauto.com/wiki/Pre ... ables_list Show full code.We don't know maybe your source player in event or team.
×
×
  • Create New...