Jump to content

Help with script


DrPhoX

Recommended Posts

Hello, i tried to put together script "Country and flags" to one scoreboard column but when i tried it, script doesn't work and i don't know why... Can you tell my where's is my mistake? or correct it for me :) I will be happy. There is script:

     exports.scoreboard:addScoreboardColumn('          Home', getRootElement(), 1, 0.025) 
  
            function showcountry() 
            local flag = exports.admin:getPlayerCountry ( source ) 
            local home = call(getResourceFromName("admin"), "getPlayerCountry", source) 
                     if flag and home then 
            setElementData(source,"          Home",":admin/client/images/flags/"..flag..".png",home) 
                        else 
                     flag = "N/A" 
             home = "EU" 
                     end 
                end 
     addEventHandler("onPlayerJoin",getRootElement(),showcountry) 

And do you know how to align text to the middle? Thank you :)

Link to comment

joao1234: Double post was because my topic was old 1 day but without response...

Hunterix: I don't know if i have error in debugscript :D i have many errors and warnings what spamming debugscript chat :/ And yes, scoreboard is edited but there is not problem... I had it split (Flags and country "CZ","EU","PL" etc..) but I decided that I will try to give it to one scoreboard column but i don't know how :/

Link to comment

That doesn't make much sense, "flag" and "home" is the same thing.

exports.scoreboard:addScoreboardColumn('          Home', getRootElement(), 1, 0.025) 
  
function showcountry ( ) 
    local flag = exports.admin:getPlayerCountry ( source ) or "N/A" 
    if ( flag ) then 
        setElementData ( source, "          Home", ":admin/client/images/flags/".. home:lower ( ) ..".png" ) 
    end 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), showcountry ) 

Try it.

Link to comment

Thank you for responding but this code doesn't work :/ I tried it as "server" and "client" side... Don't work :/

EDIT: Castillo, i think you created code without country names.. I want with country flag and shortcut from country names...

Example: " .. flag .. " CZ | PlayerName

" .. flag .. " PL | PlayerName

i hope if you understand

Link to comment

Ok, i have added to scoreboard_client.lua this code:

                            elseif column.name == "          Home" then 
    dxDrawImage( topX+theX, y+s(1), 16, 11, content, 0, 0, 0, cWhite, drawOverGUI ) 

after line 739 because there i have added ping image... So, scoreboard is working but flags and country shortcut names not :/

Link to comment

For scoreboard:

                            elseif column.name == "Home" then 
                                local imagePath = ":admin/client/images/flags/".. content:lower ( ) ..".png" 
                                if ( fileExists ( imagePath ) ) then 
                                    dxDrawImage( topX+theX, y+s(1), 16, 11, imagePath, 0, 0, 0, cWhite, drawOverGUI ) 
                                end 
                                dxDrawText( content, topX+theX+s(1)+20,     y+s(1), topX+x+s(1+column.width),   y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ),    tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) 
                                dxDrawText( content, topX+theX+20,      y,      topX+x+s(column.width),     y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ),          tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) 

Script to set home:

exports.scoreboard:addScoreboardColumn ( 'Home', getRootElement(), 1, 0.06 ) 
  
function showcountry ( ) 
    local flag = exports.admin:getPlayerCountry ( source ) or "N/A" 
    if ( flag ) then 
        setElementData ( source, "Home", flag ) 
    end 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), showcountry ) 

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...