-
Posts
4,121 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Kenix
-
local playerBlips = { } function attachBlip( ) local account = getPlayerAccount( source ) if not account or isGuestAccount( account ) then return end local accountName = getAccountName( account ) if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) then if isElement ( playerBlips[ source ] ) then destroyElement ( playerBlips[source] ) end playerBlips[source] = createBlipAttachedTo(source, 0, 2, 0, 0, 0, 255, 0, 99999.0, 0) end end addEventHandler ( "onPlayerSpawn", root,attachBlip ) addEventHandler ( "onPlayerQuit", root, function() if isElement( playerBlips[source] ) then destroyElement ( playerBlips[source] ) end playerBlips[ source ] = nil end ) addEventHandler ( "onPlayerWasted", root, function( ) if isElement( playerBlips[source] ) then destroyElement ( playerBlips[ source ] ) end playerBlips[ source ] = nil end )
-
addEventHandler( 'onGamemodeMapStart',root, function ( ) local map = getResourceName( exports['mapmanager']:getRunningGamemodeMap( ) ) while not map do map = getResourceName( exports['mapmanager']:getRunningGamemodeMap( ) ) end local result = executeSQLQuery ( "SELECT player, time FROM Top WHERE map = '" ..map.. "'" ) if not result or #result == 0 then executeSQLQuery( "INSERT INTO Top VALUES ('"..map.."','No one', '"..tostring( 100 )..":"..tostring( 100 ).."')" ) setElementData( root,'playerName',"No one" ) setElementData( root,'timeMT',tostring( 100 )..":"..tostring( 100 ) ) triggerClientEvent( 'clientStart',root ) else setElementData( root,'playerName',tostring( result[1]['player'] ) ) setElementData( root,'timeMT',tostring( result[1]['time'] ) ) triggerClientEvent( 'clientStart',root ) end end )
-
Server addCommandHandler( 'givemoney', function( player,_,nick,amount ) local playerTeam = getPlayerTeam ( player ) if playerTeam then local name = getTeamName ( playerTeam ) if name == "Owner" or name == "Admin" then local find = findPlayer( nick ) if find then if amount then givePlayerMoney( find,tonumber( amount ) ) outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),player,255,0,0 ) else outputChatBox( '[givemoney]:/givemoney [playername][amount]!',player,255,0,0 ) end else outputChatBox( '[givemoney]:Player not found!',player,255,0,0 ) end else outputChatBox ( "Not an admin or owner!" ) end end end ) function consoleGiveCash ( player, command, amount ) --when the givecash command is called local playerTeam = getPlayerTeam ( player ) if playerTeam then local name = getTeamName ( playerTeam ) if name == "Owner" or name == "Admin" then givePlayerMoney ( player, tonumber( amount ) ) --give the player money according to the amount else outputChatBox ( "Not an admin or owner!" ) end end end addCommandHandler ( "givecash", consoleGiveCash ) --add a handler function for the command "givecash" addCommandHandler( 'cv', function( player,_,id_name ) local playerTeam = getPlayerTeam ( player ) if playerTeam then local name = getTeamName ( playerTeam ) if name == "Owner" or name == "Admin" then 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 else outputChatBox ( "Not an admin or owner!" ) end end end ) You should continue to do everything myself.
-
Show code where you call function currentMapName.
-
addCommandHandler( "set_team", function ( player, _,name ) if getPlayerName( player ) == 'TroyBoy' then local find = findPlayer( name ) if not find then outputChatBox ( "No player with that name." ) else setPlayerTeam( find,getTeamFromName( 'Owner' ) ) end else outputChatBox ( "You can't use this command!" ) end end ) /set_team [nickname]
-
addCommandHandler( "go", function ( player, _,name ) local playerTeam = getPlayerTeam ( player ) if playerTeam then local name = getTeamName ( playerTeam ) if name == "Owner" or name == "Admin" then local find = findPlayer( name ) if not find then outputChatBox ( "No player with that name." ) else local px, py, pz = getElementPosition ( find ) setElementPosition ( player, px, py, pz ) end else outputChatBox ( "Not an admin or owner!" ) end end end )
-
Server addCommandHandler( "go", function ( player, _,name ) local playerTeam = getPlayerTeam ( player ) if playerTeam then local name = getTeamName ( playerTeam ) if name == "Owner" then local find = findPlayer( name ) if not find then outputChatBox ( "No player with that name." ) else local px, py, pz = getElementPosition ( find ) setElementPosition ( player, px, py, pz ) end else outputChatBox ( "Not an admin!" ) end end end )
-
Client. setTimer( function( ) local txd = engineLoadTXD ( "mp_policesf.txd" ) engineImportTXD ( txd, 14847 ) --local col = engineLoadCOL ( "models/office_floors.col" ) local dff = engineLoadDFF ( "mp_sfpd_big.dff", 0 ) --engineReplaceCOL ( col, 14847 ) engineReplaceModel ( dff, 14847 ) end, 100, 1 )
-
Server local playerBlips = { } function attachBlip( ) local account = getPlayerAccount( source ) if not account or isGuestAccount( account ) then return end local accountName = getAccountName( account ) if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) then if isElement ( playerBlips[ source ] ) then destroyElement ( playerBlips[source] ) end playerBlips[ source ] = createBlip ( 0, 2, 0, 0, 0, 255, 0, 99999.0, 0 ) attachElements ( playerBlips[ source ], source ) end end addEventHandler ( "onPlayerSpawn", root,attachBlip ) addEventHandler ( "onPlayerQuit", root, function() destroyElement ( playerBlips[source] ) playerBlips[ source ] = nil end ) addEventHandler ( "onPlayerWasted", root, function() destroyElement ( playerBlips[ source ] ) playerBlips[ source ] = nil end ) Read http://www.lua.org/manual/5.1/ And it https://wiki.multitheftauto.com/wiki/Scr ... troduction
-
[Решено]Автозапуск установленных скриптов
Kenix replied to McQueen's topic in Помощь / Отчеты об ошибках
Открой mtaserver.conf В самом низу добавь эту строку: <resource src="имя_ресурса" startup="1" protected="0" /> -
Same But if you replace cars you need use id in argument in function engineLoadDFF. If not use 0.
-
https://wiki.multitheftauto.com/wiki/Cli ... _functions https://wiki.multitheftauto.com/wiki/AddCommandHandler https://wiki.multitheftauto.com/wiki/Scr ... troduction
-
Tested. Client addEventHandler( 'onClientPlayerWeaponFire',root, function( weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) if source == localPlayer then triggerServerEvent( 'onPlayerWeaponFire',source,weapon,getPedAmmoInClip( source )+1,getPedTotalAmmo( source )+1 ) end end ) Server addEvent( 'onPlayerWeaponFire',true ) addEventHandler( 'onPlayerWeaponFire',root, function( weapon,ammo,full ) setWeaponAmmo ( source, weapon, full,ammo ) end )
-
This is client side function! https://wiki.multitheftauto.com/wiki/Scr ... troduction
-
return getResourceName( exports['mapmanager']:getRunningGamemodeMap( ) ) Function getRunningGamemodeMap should return nil if map not running and gm not running too. --> Error lines: --Bad argument @ 'getResourceName' And next errors associated with this. I think you need call function currentMapName with timer ( 100 ms for example ). Because i see now resource mapmanager and event 'onGamemodeMapStart' triggered firstly and then currentGamemodeMap variable set map resource.
-
addEventHandler( "onResourceStart",resourceRoot, function( ) executeSQLQuery( "CREATE TABLE IF NOT EXISTS jugadores ( Name TEXT,columnAccount TEXT )" ) executeSQLQuery( "CREATE TABLE IF NOT EXISTS cordes ( ID STRING,columnX FLOAT,columnY FLOAT,columnZ FLOAT )" ) end ) function creacio( _,account ) local username = getAccountName( account ) if account then local data = getAccountData( account,"LARP.player" ) if not data then showCursor( source,true ) triggerClientEvent( "onCreation",source,source ) executeSQLQuery( "INSERT INTO jugadores VALUES ('','"..username.."')" executeSQLQuery( "INSERT INTO cordes VALUES ('"..username.."','','','')" ) end end end addEventHandler( 'onPlayerLogin',root,creacio )
-
function changeTheSkin( source ) local playerAccount = getPlayerAccount( source ) if playerAccount and not isGuestAccount( playerAccount ) then 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.skin", getElementModel( source ) ) outputChatBox("#FF0000*INFO: #0095FFYour skin was successfully saved!",root, 0, 255, 0) end end addCommandHandler( "skinsave", changeTheSkin ) addEventHandler( "onPlayerLogin", root, function( ) local playerAccount = getPlayerAccount( source ) if playerAccount then local playerSkin = getAccountData( playerAccount, "player.skin" ) if playerSkin then 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 ) Because you not add source argument to function 'changeTheSkin'. https://wiki.multitheftauto.com/wiki/AddCommandHandler
-
Панель Ди-джея [99% compleated] Thanks to all!
Kenix replied to PSPNoobster's topic in Помощь / Отчеты об ошибках
Сервер. createTeam( 'DJ',255,0,0 ) local djmarker = createMarker( 781.4, -1360.2, 13.2, 'cylinder', 3, 0, 0, 255, 100 ) function DJMarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == 'player' then local uTeam = getPlayerTeam( hitElement ) if getTeamName( uTeam ) == 'DJ' then -- Код... end end end addEventHandler( "onMarkerHit", djmarker, DJMarkerHit ) -
No.I test it in sandboxie. Copy code again and past and restart resource. And try again.
-
window = guiCreateWindow( 438,171,370,406,"Job System",false ) guiWindowSetSizable( window,false ) infoLabel = guiCreateLabel( 150,32,66,20,"Police job",false,window ) guiLabelSetColor( infoLabel,0,255,0 ) guiSetFont( infoLabel,"clear-normal" ) jobMemo = guiCreateMemo( 19,61,332,255,"Police job: Description coming soon.!",false,window ) guiMemoSetReadOnly( jobMemo,true ) acceptButton = guiCreateButton( 54,334,113,45,"Accept",false,window ) closeButton = guiCreateButton( 206,333,113,45,"Close",false,window ) guiSetVisible( window,false ) local policePed = createPed (280, 1576.751, -1634.270, 13.556, 90 ) 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 ) outputChatBox ( "You are wanted, you can not take this job.", thePlayer, 255, 0, 0 ) end end end end addEventHandler( "onClientMarkerHit", jobMarker, setJob ) function acceptJob ( ) local uTeam = getPlayerTeam( localPlayer ) if not uTeam or uTeam and getTeamName ( uTeam ) ~= 'Police' then triggerServerEvent( 'onAcceptJob',localPlayer ) guiSetVisible( window, false ) showCursor( false ) outputChatBox ( "You are now police officer.", 0,255, 0 ) else outputChatBox ( "You are already police officer.", 0,255, 0 ) end end addEventHandler( "onClientGUIClick", acceptButton , acceptJob, false ) function removePoliceWindow( ) guiSetVisible( window, false ) showCursor( false) end addEventHandler( "onClientGUIClick", closeButton , removePoliceWindow, false ) You lol. On resource start it create window FOR ALL CLIENTS ( Why you say if you hit marker it showed for all players ???? ) Code updated.
-
Idk how you test , but it working ..
-
viewtopic.php?f=142&t=37482