sckatchof Posted February 25, 2012 Share Posted February 25, 2012 hello guys i want to make ascript that sho in scorboad like this pic 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
Kenix Posted February 25, 2012 Share Posted February 25, 2012 localPlayer only in client side .. Link to comment
sckatchof Posted February 25, 2012 Author Share Posted February 25, 2012 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
Kenix Posted February 25, 2012 Share Posted February 25, 2012 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
sckatchof Posted February 25, 2012 Author Share Posted February 25, 2012 thank you agian for help but it dont work. Link to comment
Kenix Posted February 25, 2012 Share Posted February 25, 2012 /debugscript 3? meta.xml ? Link to comment
sckatchof Posted February 25, 2012 Author Share Posted February 25, 2012 /debugscript 3?meta.xml ? Meta : /debugscript 3 nothings Link to comment
Kenix Posted February 25, 2012 Share Posted February 25, 2012 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
sckatchof Posted February 25, 2012 Author Share Posted February 25, 2012 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
Kenix Posted February 25, 2012 Share Posted February 25, 2012 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
sckatchof Posted February 25, 2012 Author Share Posted February 25, 2012 thank you again but dont work . Link to comment
drk Posted February 25, 2012 Share Posted February 25, 2012 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
Castillo Posted February 25, 2012 Share Posted February 25, 2012 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
Kenix Posted February 25, 2012 Share Posted February 25, 2012 (edited) 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 February 25, 2012 by Guest Link to comment
sckatchof Posted February 25, 2012 Author Share Posted February 25, 2012 thank snake but nothing shows Link to comment
Castillo Posted February 25, 2012 Share Posted February 25, 2012 I've tested mine and worked, I was in Los Santos and "Zone" was "LS". Link to comment
Kenix Posted February 25, 2012 Share Posted February 25, 2012 Use my code i tested it now. If you in los santos then LS. If in country side then none. Link to comment
sckatchof Posted February 25, 2012 Author Share Posted February 25, 2012 I've tested mine and worked, I was in Los Santos and "Zone" was "LS". i tested it but sometimes it show and sometimes does not show Link to comment
Kenix Posted February 25, 2012 Share Posted February 25, 2012 (edited) Use my code i tested it now.If you in los santos then LS. If in country side then none. http://imageshack.us/photo/my-images/81 ... 021047.png http://imageshack.us/photo/my-images/29 ... 021058.png Edited February 25, 2012 by Guest Link to comment
sckatchof Posted February 25, 2012 Author Share Posted February 25, 2012 Use my code i tested it now.If you in los santos then LS. If in country side then none. Kenix i use ur code but some problem i make ss : Link to comment
Kenix Posted February 25, 2012 Share Posted February 25, 2012 Try again. Your resource named is scoreboard?( not Scoreboard ?Case sensitive ) Not debug errors? Link to comment
sckatchof Posted February 25, 2012 Author Share Posted February 25, 2012 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
drk Posted February 25, 2012 Share Posted February 25, 2012 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
sckatchof Posted February 25, 2012 Author Share Posted February 25, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now