Jump to content

Need Same help


sckatchof

Recommended Posts

hello guys i want to make ascript that sho in scorboad like this pic

help.png

This is my script :

  
exports["scoreboard"]:scoreboardAddColumn("Zone",root,30,"City") 
  
function CityZ() 
     local playerX, playerY, playerZ = getElementPosition ( localPlayer )  
     local playerZoneName = getZoneName ( playerX, playerY, playerZ ) 
     setElementData (source,"Zone" , playerZoneName) 
end 
setTimer(CityZ, 1000, 1) 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), CityZ ) 

Link to comment
localPlayer only in client side ..

And this :

exports["scoreboard"]:scoreboardAddColumn("Zone",root,30,"City")

function CityZ()

local city = getZoneName ( x, y, z )

setElementData (city,"Zone" , getZoneName (source))

end

setTimer(CityZ, 1000, 1)

addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), CityZ )

Link to comment
exports["scoreboard"]:scoreboardAddColumn( "Zone",root,30,"City" ) 
  
local uTimers = { } 
  
function setZoneData( player ) 
    local player = player or source 
    if isTimer( uTimers[ player ] ) then 
        killTimer( uTimers[ player ] ) 
    end 
    uTimers[ player ] = setTimer( 
        function( player ) 
            local playerX, playerY, playerZ = getElementPosition ( player )  
            local playerZoneName = getZoneName ( playerX, playerY, playerZ ) 
            setElementData ( player,"Zone" , playerZoneName ) 
        end, 
    1000, 
    0, player )  
end 
  
addEventHandler( 'onResourceStart',resourceRoot, 
    function( ) 
        for _,v in pairs( getElementsByType 'player' ) do 
            setZoneData( v ) 
        end 
    end 
) 
  
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        if isTimer( uTimers[ source ] ) then 
            killTimer( uTimers[ source ] ) 
        end 
        uTimers[ source ] = nil 
    end 
)    
     
addEventHandler( 'onPlayerJoin',root,setZoneData ) 
  
  

Updated.

Learn it https://wiki.multitheftauto.com/wiki/Scr ... troduction

Link to comment
  
exports.scoreboard:addScoreboardColumn( "Zone",root,3,0.15 ) 
  
local uTimers = { } 
  
function setZoneData( player ) 
    local player = player or source 
    if isTimer( uTimers[ player ] ) then 
        killTimer( uTimers[ player ] ) 
    end 
    uTimers[ player ] = setTimer( 
        function( player ) 
            local playerX, playerY, playerZ = getElementPosition ( player )  
            local playerZoneName = getZoneName ( playerX, playerY, playerZ ) 
            setElementData ( player,"Zone" , playerZoneName ) 
        end, 
    1000, 
    0, player )  
end 
  
addEventHandler( 'onResourceStart',resourceRoot, 
    function( ) 
        for _,v in pairs( getElementsByType 'player' ) do 
            setZoneData( v ) 
        end 
    end 
) 
  
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        if isTimer( uTimers[ source ] ) then 
            killTimer( uTimers[ source ] ) 
        end 
        uTimers[ source ] = nil 
    end 
)    
     
addEventHandler( 'onPlayerJoin',root,setZoneData ) 
  
  

Updated again.

Tested.

I see now export functions in resource scoreboard and i not found 'scoreboardAddColumn'.

So you need use function addScoreboardColumn or add scoreboardAddColumn to meta.xml( export function).

Link to comment

Thank you for help Kenix but you don't understand me what i want

like this pic when i go to los santos it show in scrorboad like this

Zone ===> LS or LV or SF

addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
    function() 
                call(getResourceFromName("scoreboard"),"addScoreboardColumn","Zone", getRootElement(), 5, 0.04) 
    end 
) 
  
  
function Zone() 
    local playerX, playerY, playerZ = getElementPosition( getLocalPlayer() ) 
    local playerZoneName =  getZoneName( playerX, playerY, playerZ ) 
     setElementData ( source, "Zone", playerZoneName ) 
setTimer(getwan,100,0) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), Zone ) 

Link to comment
  
exports.scoreboard:addScoreboardColumn( "Zone",root,3,0.15 ) 
  
local uTimers = { } 
  
function setZoneData( player ) 
    local player = player or source 
    if isTimer( uTimers[ player ] ) then 
        killTimer( uTimers[ player ] ) 
    end 
    uTimers[ player ] = setTimer( 
        function( player ) 
            local playerX, playerY, playerZ = getElementPosition ( player )  
            local playerZoneName = getZoneName ( playerX, playerY, playerZ,true ) 
            setElementData ( player,"Zone" , playerZoneName ) 
        end, 
    1000, 
    0, player )  
end 
  
addEventHandler( 'onResourceStart',resourceRoot, 
    function( ) 
        for _,v in pairs( getElementsByType 'player' ) do 
            setZoneData( v ) 
        end 
    end 
) 
  
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        if isTimer( uTimers[ source ] ) then 
            killTimer( uTimers[ source ] ) 
        end 
        uTimers[ source ] = nil 
    end 
)    
     
addEventHandler( 'onPlayerJoin',root,setZoneData ) 
  
  

Link to comment
  
exports.scoreboard:addScoreboardColumn( "Zone",root,3,0.15 ) 
  
local uTimers = { } 
  
function setZoneData( player ) 
    local player = player or source 
    if isTimer( uTimers[ player ] ) then 
        killTimer( uTimers[ player ] ) 
    end 
    uTimers[ player ] = setTimer( 
        function( player ) 
            local playerX, playerY, playerZ = getElementPosition ( player )  
            local playerZoneName = getZoneName ( playerX, playerY, playerZ,true ) 
            setElementData ( player,"Zone" , playerZoneName ) 
        end, 
    1000, 
    0, player )  
end 
  
addEventHandler( 'onResourceStart',resourceRoot, 
    function( ) 
        for _,v in pairs( getElementsByType 'player' ) do 
            setZoneData( v ) 
        end 
    end 
) 
  
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        if isTimer( uTimers[ source ] ) then 
            killTimer( uTimers[ source ] ) 
        end 
        uTimers[ source ] = nil 
    end 
)    
     
addEventHandler( 'onPlayerJoin',root,setZoneData ) 
  
  

I think he is saying that he wants like when you are in Los Santos, Zone will be "LS", if you are in San Fierro will be "SF", if you are in Las Venturas will be "LV".

Link to comment
exports.scoreboard:addScoreboardColumn( "Zone",root,3,0.15 ) 
  
local uTimers = { } 
local zoneNames = { 
    ["Los Santos"] = "LS", 
    ["San Fierro"] = "SF", 
    ["Las Venturas"] = "LV" 
} 
  
function setZoneData( player ) 
    local player = player or source 
    if isTimer( uTimers[ player ] ) then 
        killTimer( uTimers[ player ] ) 
    end 
    uTimers[ player ] = setTimer( 
        function( player ) 
            local playerX, playerY, playerZ = getElementPosition ( player ) 
            local playerZoneName = getZoneName ( playerX, playerY, playerZ, true ) 
            setElementData ( player, "Zone", zoneNames[playerZoneName] or playerZoneName ) 
        end, 
    1000, 
    0, player ) 
end 
addEventHandler( 'onPlayerJoin',root,setZoneData ) 
  
addEventHandler( 'onResourceStart',resourceRoot, 
    function( ) 
        for _,v in pairs( getElementsByType 'player' ) do 
            setZoneData( v ) 
        end 
    end 
) 
  
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        if isTimer( uTimers[ source ] ) then 
            killTimer( uTimers[ source ] ) 
        end 
        uTimers[ source ] = nil 
    end 
) 

Link to comment
  
    
   
exports.scoreboard:addScoreboardColumn( "Zone",root,3,0.15 ) 
  
local uTimers = { } 
local t = 
{ 
    ['Los Santos']      = 'LS'; 
    ['Las Venturas']    = 'LV'; 
    ['San Fierro']      = 'SF'; 
} 
  
function setZoneData( player ) 
    local player = player or source 
    if isTimer( uTimers[ player ] ) then 
        killTimer( uTimers[ player ] ) 
    end 
    uTimers[ player ] = setTimer( 
        function( player ) 
            local playerX, playerY, playerZ = getElementPosition ( player )  
            local playerZoneName = getZoneName ( playerX, playerY, playerZ,true ) 
            if playerZoneName == 'Los Santos' or playerZoneName == 'Las Venturas' 
            or playerZoneName == 'San Fierro' then 
                playerZoneName = t[ playerZoneName ] 
            else 
                playerZoneName = 'none' 
            end 
            setElementData ( player,"Zone" , playerZoneName ) 
        end, 
    1000, 
    0, player )  
end 
  
addEventHandler( 'onResourceStart',resourceRoot, 
    function( ) 
        for _,v in pairs( getElementsByType 'player' ) do 
            setZoneData( v ) 
        end 
    end 
) 
  
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        if isTimer( uTimers[ source ] ) then 
            killTimer( uTimers[ source ] ) 
        end 
        uTimers[ source ] = nil 
    end 
)    
     
addEventHandler( 'onPlayerJoin',root,setZoneData ) 
  
  
  
  

Tested and updated again.

Edited by Guest
Link to comment
Try again.

Your resource named is scoreboard?( not Scoreboard ?Case sensitive )

Not debug errors?

Yes is Scoreboard and i dont have any errors a try many time :

Server side :

exports.scoreboard:addScoreboardColumn( "Zone",root,3,0.15 ) 
  
local uTimers = { } 
local t = 
{ 
    ['Los Santos']      = 'LS'; 
    ['Las Venturas']    = 'LV'; 
    ['San Fierro']      = 'SF'; 
} 
  
function setZoneData( player ) 
    local player = player or source 
    if isTimer( uTimers[ player ] ) then 
        killTimer( uTimers[ player ] ) 
    end 
    uTimers[ player ] = setTimer( 
        function( player ) 
            local playerX, playerY, playerZ = getElementPosition ( player ) 
            local playerZoneName = getZoneName ( playerX, playerY, playerZ,true ) 
            if playerZoneName == 'Los Santos' or playerZoneName == 'Las Venturas' 
            or playerZoneName == 'San Fierro' then 
                playerZoneName = t[ playerZoneName ] 
            else 
                playerZoneName = 'none' 
            end 
            setElementData ( player,"Zone" , playerZoneName ) 
        end, 
    1000, 
    0, player ) 
end 
  
addEventHandler( 'onResourceStart',resourceRoot, 
    function( ) 
        for _,v in pairs( getElementsByType 'player' ) do 
            setZoneData( v ) 
        end 
    end 
) 
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        if isTimer( uTimers[ source ] ) then 
            killTimer( uTimers[ source ] ) 
        end 
        uTimers[ source ] = nil 
    end 
)   
addEventHandler( 'onPlayerJoin',root,setZoneData ) 

and this is my MTA.xml :

"Sckatchof description="Scoreboard" type="script" version="1.0.0" /> 
        server" /> 
        server" /> 
        server" /> 
  
 

Link to comment
Try again.

Your resource named is scoreboard?( not Scoreboard ?Case sensitive )

Not debug errors?

Yes is Scoreboard and i dont have any errors a try many time :

Server side :

exports.scoreboard:addScoreboardColumn( "Zone",root,3,0.15 ) 
  
local uTimers = { } 
local t = 
{ 
    ['Los Santos']      = 'LS'; 
    ['Las Venturas']    = 'LV'; 
    ['San Fierro']      = 'SF'; 
} 
  
function setZoneData( player ) 
    local player = player or source 
    if isTimer( uTimers[ player ] ) then 
        killTimer( uTimers[ player ] ) 
    end 
    uTimers[ player ] = setTimer( 
        function( player ) 
            local playerX, playerY, playerZ = getElementPosition ( player ) 
            local playerZoneName = getZoneName ( playerX, playerY, playerZ,true ) 
            if playerZoneName == 'Los Santos' or playerZoneName == 'Las Venturas' 
            or playerZoneName == 'San Fierro' then 
                playerZoneName = t[ playerZoneName ] 
            else 
                playerZoneName = 'none' 
            end 
            setElementData ( player,"Zone" , playerZoneName ) 
        end, 
    1000, 
    0, player ) 
end 
  
addEventHandler( 'onResourceStart',resourceRoot, 
    function( ) 
        for _,v in pairs( getElementsByType 'player' ) do 
            setZoneData( v ) 
        end 
    end 
) 
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        if isTimer( uTimers[ source ] ) then 
            killTimer( uTimers[ source ] ) 
        end 
        uTimers[ source ] = nil 
    end 
)   
addEventHandler( 'onPlayerJoin',root,setZoneData ) 

and this is my MTA.xml :

"Sckatchof description="Scoreboard" type="script" version="1.0.0" /> 
        server" /> 
        server" /> 
        server" /> 
  
  
 

MTA.xml? LOL

meta.xml.

And it's wrong.

Correct:

"Sckatchof" description="Scoreboard" type="script" version="1.0.0" /> 

Link to comment
Try again.

Your resource named is scoreboard?( not Scoreboard ?Case sensitive )

Not debug errors?

Yes is Scoreboard and i dont have any errors a try many time :

Server side :

exports.scoreboard:addScoreboardColumn( "Zone",root,3,0.15 ) 
  
local uTimers = { } 
local t = 
{ 
    ['Los Santos']      = 'LS'; 
    ['Las Venturas']    = 'LV'; 
    ['San Fierro']      = 'SF'; 
} 
  
function setZoneData( player ) 
    local player = player or source 
    if isTimer( uTimers[ player ] ) then 
        killTimer( uTimers[ player ] ) 
    end 
    uTimers[ player ] = setTimer( 
        function( player ) 
            local playerX, playerY, playerZ = getElementPosition ( player ) 
            local playerZoneName = getZoneName ( playerX, playerY, playerZ,true ) 
            if playerZoneName == 'Los Santos' or playerZoneName == 'Las Venturas' 
            or playerZoneName == 'San Fierro' then 
                playerZoneName = t[ playerZoneName ] 
            else 
                playerZoneName = 'none' 
            end 
            setElementData ( player,"Zone" , playerZoneName ) 
        end, 
    1000, 
    0, player ) 
end 
  
addEventHandler( 'onResourceStart',resourceRoot, 
    function( ) 
        for _,v in pairs( getElementsByType 'player' ) do 
            setZoneData( v ) 
        end 
    end 
) 
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        if isTimer( uTimers[ source ] ) then 
            killTimer( uTimers[ source ] ) 
        end 
        uTimers[ source ] = nil 
    end 
)   
addEventHandler( 'onPlayerJoin',root,setZoneData ) 

and this is my MTA.xml :

"Sckatchof description="Scoreboard" type="script" version="1.0.0" /> 
        server" /> 
        server" /> 
        server" /> 
  
  
  
 

MTA.xml? LOL

meta.xml.

And it's wrong.

Correct:

"Sckatchof" description="Scoreboard" type="script" version="1.0.0" /> 

Omg i know i have many script in meta.xml and its work ....

meta.xml

---Mode TNS 
     "Sckatchof" type="gamemode" name="CnR/RPG/TUN" description="My first MTA DM server" /> 
     

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...