-
Posts
4,121 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Kenix
-
В функции обработчика события был код . Т.е не только вызов функции giveWeap. Непонятно что ли?
-
addEventHandler( 'onGiveWeaponStreamedPed',root, -- Вот нафига? function( ) giveWeap( source ) end ) -- addEventHandler( 'onGiveWeaponStreamedPed',root, giveWeap ) -- Чем такой вариант не устраивает? В первый раз когда я писал был код там и потом уже вызов функции giveWeap
-
Может ты на клиенте код юзаешь. Я должен убидится. Можно ещё сделать если пед в стриме , то давать оружие. Сервер addEvent( 'onGiveWeaponStreamedPed',true ) local ped function giveWeap( source ) if isElement( source ) then return giveWeapon( source,34,100,true ) end return false end addEventHandler( 'onGiveWeaponStreamedPed',root, function( ) giveWeap( source ) end ) addEventHandler( 'onResourceStart',resourceRoot, function( ) ped = createPed ( 280, 1580.5999755859,-1634.3000488281,12.5,0 ) setElementData( ped,'stream','y' ) setTimer( function( ped ) giveWeap( ped ) end, 1000, 1 ,ped ) end ) Клиент addEventHandler( 'onClientElementStreamIn',root, function( ) if getElementType( source ) == "ped" and getElementData( source,'stream' ) == 'y' then triggerServerEvent( 'onGiveWeaponStreamedPed',source ) end end )
-
Full code Server side: 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 ) Updated.
-
local message = { "#ffff00RADIO: #ffffffStream stopped" } local posX, posY, posZ = 269.70001220703, -1895.0999755859, 0.69999998807907 local RadioColshape = createColCircle ( 269.70001220703, -1895.0999755859, 0.69999998807907,150 ) local radioURL = "http://www.181.fm/winamp.pls?station=181-power&style=mp3" local radius = 150 local volume = 4.0 local radio = playSound3D( radioURL, posX, posY, posZ, false ) setSoundVolume( radio, volume) setSoundMaxDistance( radio, radius ) addEventHandler( "onClientColShapeLeave",RadioColshape, function( tplayer ) if getElementType( tplayer ) == "player" and tplayer == localPlayer then setTimer( outputChatBox, 800, 1, math.random( #message ), 255, 255, 255, true ) end end )
-
race/race_server.lua/ function addRaceScoreboardColumns Find function addRaceScoreboardColumns() exports.scoreboard:addScoreboardColumn('race rank') exports.scoreboard:addScoreboardColumn('checkpoint') exports.scoreboard:addScoreboardColumn('state') end Replace function addRaceScoreboardColumns() --exports.scoreboard:addScoreboardColumn('race rank') --exports.scoreboard:addScoreboardColumn('checkpoint') --exports.scoreboard:addScoreboardColumn('state') end Found in revision 839
-
Попробуй через таймер. meta.xml покажи ещё.
-
guiSetVisible(GUIEditor_Window[1[, not guiGetVisible(GUIEditor_Window[1])) GUIEditor_Window[1[ Syntax error in your code,
-
https://wiki.multitheftauto.com/wiki/Ser ... _functions or https://wiki.multitheftauto.com/wiki/Mysql Structure: Map_Name:time 1.If map finished insert to table ( if not one passing .Just you ) getResourceName( mapName )..':'..time Example:Map_Name:time dm_SomeMap:10000 if map have time and time now < time map just update table 2.Get time for dx or something Example:Map_Name:time dm_SomeMap:100 function getTimeFromMap( name ) if name then return tonumber( name:sub( name:find( ':' ) + 1,utfLen( name ) ) ) end return false end getTimeFromMap( 'dm_SomeMap:100' ) -- 100 P.S I think this is very hardcore for you.
-
GUIEditor_Window = {} GUIEditor_Grid = {} GUIEditor_Label = {} GUIEditor_Image = {} GUIEditor_Window[1] = guiCreateWindow( 423,220,477,311,"Level_System v3.0 ",false ) guiWindowSetMovable( GUIEditor_Window[1],false ) guiWindowSetSizable( GUIEditor_Window[1],false ) GUIEditor_Grid[1] = guiCreateGridList( 9,21,264,281,false,GUIEditor_Window[1] ) guiGridListSetSelectionMode( GUIEditor_Grid[1],2 ) row = guiGridListAddRow ( GUIEditor_Grid[1] ) col = guiGridListAddColumn( GUIEditor_Grid[1],"Players",0.2 ) GUIEditor_Label[1] = guiCreateLabel( 286,43,144,23,"Level :",false,GUIEditor_Window[1] ) guiLabelSetColor( GUIEditor_Label[1],0,255,0 ) guiSetFont( GUIEditor_Label[1],"clear-normal" ) GUIEditor_Label[2] = guiCreateLabel( 284,95,102,21,"EXP:",false,GUIEditor_Window[1] ) guiLabelSetColor( GUIEditor_Label[2],0,0,255 ) guiSetFont( GUIEditor_Label[2],"clear-normal" ) GUIEditor_Image[1] = guiCreateStaticImage( 266,152,182,146,"images/mtalogo.png",false,GUIEditor_Window[1] ) if col then for _, players in pairs( getElementsByType 'player' ) do guiGridListSetItemText( GUIEditor_Grid[1],row,col,getPlayerName( players ),false,false ) end end addEventHandler( 'onClientGUIClick',root, function( ) if source == GUIEditor_Grid[1] then local theRow, theCol = guiGridListGetSelectedItem( source ) if theRow and theCol and theRow ~= -1 and theCol ~= -1 then guiGridListGetItemText( source,theRow, theCol ) end end end ) bindKey( 'F7','down', function( ) guiSetVisible( GUIEditor_Window[1], not guiGetVisible( GUIEditor_Window[1] ) ) showCursor( not isCursorShowing( ) ) end ) Your code have syntax error
-
exports.scoreboard:addScoreboardColumn( 'Tiempo Jugado' ) local t = { } local uTimers = { } function checkValues( source,arg1,arg2 ) if arg1 > 60 then t[ source ][ 'min' ] = tonumber( t[ source ][ 'min' ] or 0 ) + 1 t[ source ][ 'sec' ] = 0 elseif arg2 > 3600 then t[ source ][ 'sec' ] = 0 t[ source ][ 'min' ] = 0 t[ source ][ 'hour' ] = tonumber( t[ source ][ 'hour' ] or 0 ) + 1 end end function onPlayerLogOut ( _,account ) if ( account ) and not isGuestAccount ( account ) then local sValue = getElementData( source,'Tiempo Jugado' ) setAccountData ( account, "Tiempo Jugado", tostring( sValue ) ) end if isTimer( uTimers[ source ] ) then killTimer( uTimers[ source ] ) end uTimers[ source ] = nil t[ source ] = nil end function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local sValue = getElementData( source,'Tiempo Jugado' ) setAccountData ( playeraccount, "Tiempo Jugado", tostring( sValue ) ) end if isTimer( uTimers[ source ] ) then killTimer( uTimers[ source ] ) end uTimers[ source ] = nil t[ source ] = nil end function subFind( str,mod ) if mod == 'hour' then return str:sub( 1,str:find( ':' ) -1 ) else return str:sub( str:find( ':' ) + 1,str:len( ) ) end end function onPlayerLogin (_, account ) if account then uTimers[ source ] = setTimer( function( player,acc ) local time = getAccountData ( acc, "Tiempo Jugado" ) if time then if not t[ player ] then t[ player ] = { ["hour"] = tonumber( subFind( time,'hour' ) ), ["min"] = tonumber( subFind( time ) ), ["sec"] = 0 } end else if not t[ player ] then t[ player ] = { ["hour"] = 0, ["min"] = 0, ["sec"] = 0 } end end t[ player ][ 'sec' ] = tonumber( t[ player ][ 'sec' ] or 0 ) + 1 checkValues ( player, t[ player ][ 'sec' ] or 0, t[ player ][ 'min' ] or 0 ) setElementData ( player, "Tiempo Jugado", tostring( t[ player ][ 'hour' ] or 0 )..':'..tostring( t[ player ][ 'min' ] or 0 ) ) end, 1000, 0 ,source,account ) end end addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) addEventHandler( 'onPlayerLogout',root, onPlayerLogOut ) Again updated.
-
Try local t = { } function checkValues( source,arg1,arg2 ) if arg1 > 60 then t[ source ][ 'min' ] = tonumber( t[ source ][ 'min' ] or 0 ) + 1 t[ source ][ 'sec' ] = 0 elseif arg2 > 3600 then t[ source ][ 'sec' ] = 0 t[ source ][ 'min' ] = 0 t[ source ][ 'hour' ] = tonumber( t[ source ][ 'hour' ] or 0 ) + 1 end end setTimer( function( ) for _, v in pairs( getElementsByType( "player" ) ) do if not t[ v ] then t[ v ] = { ["hour"] = 0, ["min"] = 0, ["sec"] = 0 } end t[ v ][ 'sec' ] = tonumber( t[ v ][ 'sec' ] or 0 ) + 1 checkValues ( v, t[ v ][ 'sec' ] or 0, t[ v ][ 'min' ] or 0 ) setElementData( v, "Tiempo Jugado", tostring( t[ v ][ 'hour' ] or 0 )..':'..tostring( t[ v ][ 'min' ] or 0 ) ) end end, 1000, 0 ) function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local sValue = getElementData( source,'Tiempo Jugado' ) setAccountData ( playeraccount, "Tiempo Jugado", tostring( sValue ) ) end t[ source ] = nil end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local time = getAccountData ( playeraccount, "Tiempo Jugado" ) if ( time ) then setElementData ( source, "Tiempo Jugado", tostring( time ) ) end end end addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) I tested it later.
-
local t = { } function checkValues( source,arg1,arg2 ) if arg1 > 60 then t[ source ][ 'min' ] = tonumber( t[ source ][ 'min' ] or 0 ) + 1 t[ source ][ 'sec' ] = 0 elseif arg2 > 3600 then t[ source ][ 'sec' ] = 0 t[ source ][ 'min' ] = 0 t[ source ][ 'hour' ] = tonumber( t[ source ][ 'hour' ] or 0 ) + 1 end end setTimer( function( ) for _, v in pairs( getElementsByType( "player" ) ) do if not t[ v ] then t[ v ] = { ["hour"] = 0, ["min"] = 0, ["sec"] = 0 } end t[ v ][ 'sec' ] = tonumber( t[ v ][ 'sec' ] or 0 ) + 1 checkValues ( v, t[ v ][ 'sec' ] or 0, t[ v ][ 'min' ] or 0 ) setElementData( v, "Tiempo Jugado", tostring( t[ v ][ 'hour' ] or 0 )..':'..tostring( t[ v ][ 'min' ] or 0 ) ) end end, 1000, 0 ) function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local sValue = getElementData( source,'Tiempo Jugado' ) setAccountData ( playeraccount, "Tiempo Jugado", sValue ) end t[ source ] = nil end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local time = getAccountData ( playeraccount, "Tiempo Jugado" ) if ( time ) then setElementData ( source, "Tiempo Jugado", time ) end end end addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) Again updated.
-
Kernell, if ( getPlayerMoney( client ) or 0 ) < 500 then Зачем делать эту проверку ( getPlayerMoney( client ) or 0 ) если getPlayerMoney вернёт 0 в любом случае или false если элемента игрока нету. if getPlayerMoney( client ) < 500 then м?
-
exports.BHZ4_scoreboard:addScoreboardColumn('Tiempo Jugado') local t = { } function table.empty( t ) if type( t ) ~= "table" then return false end return not next( t ) end function checkValues( source,arg1,arg2 ) if arg1 > 60 then t[ source ][ 'min' ] = tonumber( t[ source ][ 'min' ] or 0 ) + 1 t[ source ][ 'sec' ] = 0 elseif arg2 > 3600 then t[ source ][ 'sec' ] = 0 t[ source ][ 'min' ] = 0 t[ source ][ 'hour' ] = tonumber( t[ source ][ 'hour' ] or 0 ) + 1 end return arg1,arg2 end setTimer( function( ) for _, v in pairs( getElementsByType( "player" ) ) do if not t[ v ] then t[ v ] = v end if table.empty( t[ v ] ) then t[ v ] = { } end t[ v ][ 'sec' ] = tonumber( t[ v ][ 'sec' ] or 0 ) + 1 local min,hour = checkValues ( v, t[ v ][ 'min' ] or 0, t[ v ][ 'hour' ] or 0 ) setElementData( v, "Tiempo Jugado", tostring( hour )..':'..tostring( min ) ) end end, 1000, 0 ) function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local sValue = getElementData( source,'Tiempo Jugado' ) setAccountData ( playeraccount, "Tiempo Jugado", sValue ) end t[ source ] = nil end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local time = getAccountData ( playeraccount, "Tiempo Jugado" ) if ( time ) then setElementData ( source, "Tiempo Jugado", time ) end end end addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) Updated.
-
local state = { } function setStat( player ) local currentWeaponID = getPedWeapon( player ) if currentWeaponID == 34 then state[ player ] = not state[ player ] if state[ player ] then setPedStat ( player, 79, 999 ) outputChatBox( "Works", player, 255, 69, 0 ) else setPedStat ( player, 79, 300 ) outputChatBox( "works!!.", player, 255, 69, 0 ) end else outputChatBox( 'Weapon should be 34 ID' ) end end addEventHandler( "onPlayerJoin",root, function ( ) bindKey( source,"x","down",setStat ) end ) addEventHandler( 'onPlayerQuit',root, function( ) state[ source ] = nil end ) addEventHandler( "onResourceStart",resourceRoot, function ( ) for _, v in pairs( getElementsByType 'player' ) do bindKey( v,"x","down",setStat ) end end )
-
I just post full code. And it code better and shorter My bindKey( 'F1','down', function( ) guiSetVisible( GUIEditor_Window[1],not guiGetVisible( GUIEditor_Window[1] ) ) showCursor( not isCursorShowing( ) ) guiSetInputEnabled( not guiGetInputEnabled( ) ) end ) Your bindKey('F1','down', function() if (guiGetVisible(GUIEditor_Window[1]) == true) then guiSetVisible(GUIEditor_Window[1],false) showCursor(false) guiSetInputEnabled(false) else guiSetVisible(GUIEditor_Window[1],true) showCursor(true) guiSetInputEnabled(true) end end)
-
gytisan,Full code Client side. local GUIEditor_Window = { } local GUIEditor_Memo = { } local GUIEditor_Checkbox = { } local GUIEditor_Image = { } local GUIEditor_Progress = { } local GUIEditor_Button = { } GUIEditor_Window[1] = guiCreateWindow( 151,53,522,505,"Welcome. Have Fun ",false ) GUIEditor_Memo[1] = guiCreateMemo( 12,76,256,155,"Commands:\n\nFor repair...../r\nFor flip...../f\nFor nitro...../n\n\nWARNING: Dont spam commands.",false,GUIEditor_Window[1] ) guiMemoSetReadOnly( GUIEditor_Memo[1],true ) GUIEditor_Memo[2] = guiCreateMemo( 10,247,259,116,"Rules:\n\nDont cheat~\nDont camp~\nPlay fair~\nBe good~\nAccept~\n",false,GUIEditor_Window[1] ) guiMemoSetReadOnly( GUIEditor_Memo[2],true ) GUIEditor_Checkbox[1] = guiCreateCheckBox( 61,72,36,33,"",false,false,GUIEditor_Memo[2] ) GUIEditor_Memo[3] = guiCreateMemo( 11,375,258,31,"Try to be the best ))))",false,GUIEditor_Window[1] ) guiMemoSetReadOnly( GUIEditor_Memo[3],true ) GUIEditor_Image[1] = guiCreateStaticImage( 249,92,235,289,"images/mtalogo.png",false,GUIEditor_Window[1] ) GUIEditor_Progress[1] = guiCreateProgressBar( 20,419,478,72,false,GUIEditor_Window[1] ) GUIEditor_Progress[2] = guiCreateProgressBar( 17,22,484,49,false,GUIEditor_Window[1] ) GUIEditor_Button[1] = guiCreateButton( 270,165,5,5,"",false ) guiSetVisible( GUIEditor_Window[1],false ) bindKey( 'F1','down', function( ) guiSetVisible( GUIEditor_Window[1],not guiGetVisible( GUIEditor_Window[1] ) ) showCursor( not isCursorShowing( ) ) guiSetInputEnabled( not guiGetInputEnabled( ) ) end )
-
You can create pseudo-class with metatable. http://lua-users.org/wiki/LuaClassesWithMetatable
-
0/0 = -nan 2/0 = inf 0/2 = 0 Understand? You can try in lua demo http://www.lua.org/cgi-bin/demo And i create check this.if -nan or inf it created 0 Updated code. addEvent( 'onPlayerRaceWasted',true ) restriction = {} 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 setAccountData( account,"Race Wins", tonumber( getAccountData( account,"Race Wins" ) or 0 ) + 1 ) outputChatBox ( "#FFA824The player " .. getPlayerName( alivePlayers[1] ) .. " won!", root, 255, 255, 255, true ) end end end addEventHandler( "onPlayerRaceWasted", root,DestructionWin ) addEventHandler( "onPlayerWasted", root, function( ) local account = getPlayerAccount( source ) if isGuestAccount( account ) then return end setAccountData( account,"Race Loses", tonumber( getAccountData( account,"Race Loses" ) or 0 ) + 1 ) 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", "-" ) else local kdr = round( wins / loses, 2 ) setAccountData( account, "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 addEvent( "stats", true ) addEventHandler( "stats", root, publicstatsinfo ) 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 addEventHandler( "onPlayerChat", root, checkCommand ) 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 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 = ( tonumber( wins )/tonumber( loses ) )*10 if tostring( ratio ):find '-nan' then ratio = 0 elseif tostring( ratio ):find 'inf' then ratio = 0 end 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 ) function restrictionEnd( playerName ) restriction[ playerName ] = nil end
-
restriction = {} function DestructionWin( ) local alivePlayers = getAlivePlayers( ) if #alivePlayers == 1 then if isElement( alivePlayers[1] ) then local account = getPlayerAccount( alivePlayers[1] ) if isGuestAccount( account ) then return end setAccountData( account,"Race Wins", tonumber( getAccountData( account,"Race Wins" ) or 0 ) + 1 ) outputChatBox ( "#FFA824The player " .. getPlayerName( alivePlayers[1] ) .. " won!", root, 255, 255, 255, true ) end end end addEventHandler( "onPlayerWasted", root, function( ) local account = getPlayerAccount( source ) if isGuestAccount( account ) then return end setAccountData( account,"Race Loses", tonumber( getAccountData( account,"Race Loses" ) or 0 ) + 1 ) 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", "-" ) else local kdr = round( wins / loses, 2 ) setAccountData( account, "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 addEvent( "stats", true ) addEventHandler( "stats", root, publicstatsinfo ) 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 addEventHandler( "onPlayerChat", root, checkCommand ) 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 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 = ( tonumber( wins )/tonumber( loses ) )*10 if tostring( ratio ):find '-nan' then ratio = 0 end 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 ) function restrictionEnd( playerName ) restriction[ playerName ] = nil end How you call function DestructionWin?
-
What I wrote is not empty words .. Think about it.
-
it created marker( get house elements in map file ). local marker local function onHit ( element,dim ) if getElementType( element ) == 'player' and not isPedInVehicle( element ) then -- your code end end local function onLeave ( element,dim ) if getElementType( element ) == 'player' and not isPedInVehicle( element ) then -- your code end end addEventHandler( 'onResourceStart',resourceRoot, function( ) local markers = getElementsByType 'house' if #markers > 0 then for _,v in pairs( markers ) do marker = createMarker( getElementData( 'markerPosX' ), getElementData( 'markerPosY' ), getElementData( 'markerPosZ' ) ) setElementData( marker,'houseName',getElementData( v,'houseName' ) ) setElementData( marker,'owner',getElementData( v,'owner' ) ) addEventHandler( 'onMarkerHit',marker,onHit ) addEventHandler( 'onMarkerLeave',marker,onLeave ) end end end ) Also you can create edf for easy change you houses in map editor. ( Just change marker pos and etc ). For owner , houseName and etc better use SQL/MySQL.