SnoopCat Posted September 10, 2012 Share Posted September 10, 2012 hey my question is how i can add the admin flags to a dxjoinmsg when a player joins? or if cant add flags just adding the country name? should i must use getFormatedCountry and if i have to use it , where i have to put it? font = dxCreateFont("font.ttf", 18) function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI) 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 ) 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, clip, wordbreak, postGUI ) end end local messageJoin = "" local messageQuit = "" function renderPlayerJoined ( ) dxDrawColorText("► ".. messageJoin,400,750.0,574.0,20.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) end function renderPlayerLeft ( ) dxDrawColorText("◄ ".. messageQuit,400,740.0,574.0,32.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) end addEventHandler('onClientPlayerJoin', root, function() messageJoin = getPlayerName(source) .. " #00A6FFhas #FFFFFFJoin #00A6FFThe server." addEventHandler ( "onClientRender", root, renderPlayerJoined ) setTimer ( function ( ) removeEventHandler ( "onClientRender", root, renderPlayerJoined ) end ,7000,1 ) end ) addEventHandler('onClientPlayerQuit', root, function(reason) messageQuit = getPlayerName(source) .. " #00A6FFhas #FFFFFFLeft #00A6FFThe server.#FFFFFF [" .. reason .. "]" addEventHandler ( "onClientRender", root, renderPlayerLeft ) setTimer ( function ( ) removeEventHandler ( "onClientRender", root, renderPlayerLeft ) end ,7000,1 ) end ) fileDelete("joinquit.lua") Link to comment
BorderLine Posted September 10, 2012 Share Posted September 10, 2012 if you have the flags on scoreboard, has you try with getElementData? Link to comment
SnoopCat Posted September 10, 2012 Author Share Posted September 10, 2012 no , but this is what uses the scoreboard country id exports.scoreboard:addScoreboardColumn('Country') function showHome () local Home = call(getResourceFromName("admin"), "getPlayerCountry", source) setElementData(source,"Country",Home) end addEventHandler("onPlayerJoin",getRootElement(),showHome) i want to do something similar but on xdjoin msg Link to comment
Kenix Posted September 10, 2012 Share Posted September 10, 2012 You want draw flag in scoreboard right? http://code.google.com/p/mtasa-resource ... tail?r=882 Link to comment
BorderLine Posted September 10, 2012 Share Posted September 10, 2012 addEventHandler('onClientPlayerJoin', root, function() country = getElementData(source,"Country") messageJoin = getPlayerName(source) .. " #00A6FFhas #FFFFFFJoin #00A6FFThe server "..country.."." addEventHandler ( "onClientRender", root, renderPlayerJoined ) setTimer ( function ( ) removeEventHandler ( "onClientRender", root, renderPlayerJoined ) end ,7000,1 ) end ) try that Link to comment
SnoopCat Posted September 10, 2012 Author Share Posted September 10, 2012 You want draw flag in scoreboard right?http://code.google.com/p/mtasa-resource ... tail?r=882 no, i want to do something like that but on a dxjoinquit msg Link to comment
SnoopCat Posted September 10, 2012 Author Share Posted September 10, 2012 now join msg dont appear debugscrip 3 Link to comment
SnoopCat Posted September 11, 2012 Author Share Posted September 11, 2012 (edited) srry for double post but i rly need help Edited September 11, 2012 by Guest Link to comment
SnoopCat Posted September 11, 2012 Author Share Posted September 11, 2012 now join msg dont appear debugscrip 3 Link to comment
TAPL Posted September 11, 2012 Share Posted September 11, 2012 Where is line 39? and please post the last full code you have while doesn't work. Link to comment
SnoopCat Posted September 11, 2012 Author Share Posted September 11, 2012 now join msg dont appear debugscrip 3 font = dxCreateFont("font.ttf", 18) function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI) 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 ) 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, clip, wordbreak, postGUI ) end end local messageJoin = "" local messageQuit = "" function renderPlayerJoined ( ) dxDrawColorText("► ".. messageJoin,400,750.0,574.0,20.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) end function renderPlayerLeft ( ) dxDrawColorText("◄ ".. messageQuit,400,740.0,574.0,32.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) end addEventHandler('onClientPlayerJoin', root, function() country = getElementData(source,"Country") messageJoin = getPlayerName(source) .. " #00A6FFhas #FFFFFFJoin #00A6FFThe server "..country.."." addEventHandler ( "onClientRender", root, renderPlayerJoined ) setTimer ( function ( ) removeEventHandler ( "onClientRender", root, renderPlayerJoined ) end ,7000,1 ) end ) addEventHandler('onClientPlayerQuit', root, function(reason) messageQuit = getPlayerName(source) .. " #00A6FFhas #FFFFFFLeft #00A6FFThe server.#FFFFFF [" .. reason .. "]" addEventHandler ( "onClientRender", root, renderPlayerLeft ) setTimer ( function ( ) removeEventHandler ( "onClientRender", root, renderPlayerLeft ) end ,7000,1 ) end ) fileDelete("joinquit.lua") Link to comment
TAPL Posted September 11, 2012 Share Posted September 11, 2012 Try. -- Server Side -- function showHome() local Home = exports.admin:getPlayerCountry(source) or "N/A" setElementData(source,"Country",Home) end addEventHandler("onPlayerJoin", root, showHome) -- Client Side -- font = dxCreateFont("font.ttf", 18) function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI) 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 ) 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, clip, wordbreak, postGUI ) end end local messageJoin = "" local messageQuit = "" function renderPlayerJoined() dxDrawColorText("► ".. messageJoin,400,750.0,574.0,20.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) end function renderPlayerLeft() dxDrawColorText("◄ ".. messageQuit,400,740.0,574.0,32.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) end addEventHandler('onClientPlayerJoin', root, function() setTimer(function(source) local country = getElementData(source,"Country") messageJoin = getPlayerName(source).." #00A6FFhas #FFFFFFJoin #00A6FFThe server "..country.."." addEventHandler("onClientRender", root, renderPlayerJoined) setTimer(function() removeEventHandler("onClientRender", root, renderPlayerJoined) end,7000,1) end,250,1,source) end) addEventHandler('onClientPlayerQuit', root, function(reason) messageQuit = getPlayerName(source) .. " #00A6FFhas #FFFFFFLeft #00A6FFThe server.#FFFFFF [" .. reason .. "]" addEventHandler("onClientRender", root, renderPlayerLeft) setTimer(function() removeEventHandler("onClientRender", root, renderPlayerLeft) end,7000,1) end) fileDelete("joinquit.lua") Link to comment
SnoopCat Posted September 12, 2012 Author Share Posted September 12, 2012 it works thx and if i want to create it whit flags image from admn ? like scoreboard? Link to comment
TAPL Posted September 12, 2012 Share Posted September 12, 2012 it works thx and if i want to create it whit flags image from admn ? like scoreboard? You want get the flags image from admin panel? if so local imgPath = ":admin/client/images/flags/"..getElementData(source,"Country")..".png" Link to comment
SnoopCat Posted September 12, 2012 Author Share Posted September 12, 2012 hey bro i replaced that syntax on the server script but this is what i get: i did this: function showHome() local imgPath = ":admin/client/images/flags/"..getElementData(source,"Country")..".png" setElementData(source,"Country",Home) end addEventHandler("onPlayerJoin", root, showHome) Link to comment
TAPL Posted September 12, 2012 Share Posted September 12, 2012 Please explain what you want to do exactly. Link to comment
SnoopCat Posted September 12, 2012 Author Share Posted September 12, 2012 put a flag image on the Dx join msg Link to comment
TwiX! Posted September 13, 2012 Share Posted September 13, 2012 Server function showHome() local Home = exports.admin:getPlayerCountry(source) or "N/A" setElementData(source,"Country",Home) end addEventHandler("onPlayerJoin", root, showHome) Client font = dxCreateFont("font.ttf", 18) function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI) 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 ) 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, clip, wordbreak, postGUI ) end end local messageJoin = "" local messageQuit = "" function renderPlayerJoined() dxDrawColorText("> ".. messageJoin,400,750.0,574.0,20.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) dxDrawImage ( Your posX, Your posY, Your width, Your Height, imgPath , 0, 0, 0,tocolor(255,255,255,255),true) end function renderPlayerLeft() dxDrawColorText("< ".. messageQuit,400,740.0,574.0,32.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) end addEventHandler('onClientPlayerJoin', root, function() setTimer(function(source) local country = getElementData(source,"Country") local imgPath = ":admin/client/images/flags/"..getElementData(source,"Country")..".png" messageJoin = getPlayerName(source).." #00A6FFhas #FFFFFFJoin #00A6FFThe server "..country.."." addEventHandler("onClientRender", root, renderPlayerJoined) setTimer(function() removeEventHandler("onClientRender", root, renderPlayerJoined) end,7000,1) end,250,1,source) end) addEventHandler('onClientPlayerQuit', root, function(reason) messageQuit = getPlayerName(source) .. " #00A6FFhas #FFFFFFLeft #00A6FFThe server.#FFFFFF [" .. reason .. "]" addEventHandler("onClientRender", root, renderPlayerLeft) setTimer(function() removeEventHandler("onClientRender", root, renderPlayerLeft) end,7000,1) end) fileDelete("joinquit.lua") Link to comment
SnoopCat Posted October 15, 2012 Author Share Posted October 15, 2012 its only showing country name :C Link to comment
ELmarcoS. Posted October 15, 2012 Share Posted October 15, 2012 Please explain what you want to do exactly. I think he want this: '' Player has join the server, [Country] [Country Flag]'' Link to comment
Blaawee Posted December 1, 2012 Share Posted December 1, 2012 try this : client : font = dxCreateFont("font.ttf", 18) function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI) 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 ) 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, clip, wordbreak, postGUI ) end end local messageJoin = "" local messageQuit = "" function renderPlayerJoined() local imgPath = ":admin/client/images/flags/"..getElementData(source,"Country")..".png" dxDrawColorText("► ".. messageJoin,400,750.0,574.0,20.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) dxDrawImage( 400 + 10, 750.0, 574.0, 20.0, imgPath, 0, 0, 0, tocolor(255, 255, 255), false ) end function renderPlayerLeft() dxDrawColorText("◄ ".. messageQuit,400,740.0,574.0,32.0,tocolor(255,255,255,255),0.45,font,"left","top",false,false,false) end addEventHandler('onClientPlayerJoin', root, function() setTimer(function(source) local country = getElementData(source,"Country") messageJoin = getPlayerName(source).." #00A6FFhas #FFFFFFJoin #00A6FFThe server "..country.."." addEventHandler("onClientRender", root, renderPlayerJoined) setTimer(function() removeEventHandler("onClientRender", root, renderPlayerJoined) end,7000,1) end,250,1,source) end ) addEventHandler('onClientPlayerQuit', root, function(reason) messageQuit = getPlayerName(source) .. " #00A6FFhas #FFFFFFLeft #00A6FFThe server.#FFFFFF [" .. reason .. "]" addEventHandler("onClientRender", root, renderPlayerLeft) setTimer(function() removeEventHandler("onClientRender", root, renderPlayerLeft) end,7000,1) end ) fileDelete("joinquit.lua") 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