ETMods.net

N!tmod, a Wolfenstein: Enemy Territory Modification!

You are not logged in.

Announcement

You can donate to help us keeping services online.

#1 19-Oct-11 08:59:02

gavrila
BETA Tester
From: Usa
Registered: 15-Aug-10
Posts: 70
Website

connect.LUA

little help if anyone knows,everything works ok but does not show IP ,I changed the line 13 and 23 but still does not display the IP to connect players,works perfectly on the NQ is not compatible with NITMOD? Thank you in advance

--[[
    Connect Announce #1
    ===================
    by Phishermans Phriend

    Further information:
    --------------------
    http://www.splashdamage.com/forums/showthread.php?p=377700#post377700

    Features:
    ---------
    This script prints an enhmod-like line to chat whenever a client connects to the server. Example:
    "^dConnect: ^3*^0KFG^3*^1Bullet ^yconnected from ^7Netherlands ^y(^8Admin^y). ^5PB ^3REF"

    Important:
    ----------
    In order to use this script properly, you need to active g_countryflags. Read more about this on:
    http://shitstorm.org/noquarter/wiki/?title=Admin_CVARs#g_countryflags_.28Changed_in_1.3.0.29
--]]

-- CONFIG SECTION

    message = "^dConnect: ^7<name> ^yconnected from ^7<country> ^y(^7<shrublvl>^y)."
                    -- Message line on clientconnect: The variables are replaced with the corresponding player data
                    -- You can remove any variable from the string to not display it.

    showPlayerFlags = true        -- If set to true, dynamic player flags will be shown after the connect-message:
                    -- "^5PB" if the player's client punkbuster is enabled
                    -- "^1NO_GUID" if the player's GUID is unknown or empty
                    -- "^3REF" if the player has referee status
                    -- "^1MUTED" if the player is muted

-- END OF CONFIG SECTION


-------------------------------------------------------------
--DONT CHANGE ANYTHING BELOW UNLESS YOU KNOW WHAT YOURE DOING
-------------------------------------------------------------

shrubname = {}

countries = {
[0]=    "Unknown",
[1]=    "Asia/Pacific Region", 
[2]=    "Europe", 
[3]=    "Andorra", 
[4]=    "United Arab Emirates",
[5]=    "Afghanistan", 
[6]=    "Antigua and Barbuda", 
[7]=    "Anguilla", 
[8]=    "Albania", 
[9]=    "Armenia",
[10]=    "Netherlands Antilles", 
[11]=    "Angola", 
[12]=    "Antarctica", 
[13]=    "Argentina", 
[14]=    "American Samoa",
[15]=    "Austria", 
[16]=    "Australia", 
[17]=    "Aruba", 
[18]=    "Azerbaijan", 
[19]=    "Bosnia and Herzegovina",
[20]=    "Barbados", 
[21]=    "Bangladesh", 
[22]=    "Belgium", 
[23]=    "Burkina Faso", 
[24]=    "Bulgaria", 
[25]=    "Bahrain",
[26]=    "Burundi", 
[27]=    "Benin", 
[28]=    "Bermuda", 
[29]=    "Brunei Darussalam", 
[30]=    "Bolivia", 
[31]=    "Brazil",
[32]=    "Bahamas", 
[33]=    "Bhutan", 
[34]=    "Bouvet Island", 
[35]=    "Botswana", 
[36]=    "Belarus", 
[37]=    "Belize",
[38]=    "Canada", 
[39]=    "Cocos (Keeling) Islands", 
[40]=    "Congo-Kinshasa",
[41]=    "Central African Republic", 
[42]=    "Congo-Brazzaville", 
[43]=    "Switzerland", 
[44]=    "Cote D'Ivoire", 
[45]=    "Cook Islands",
[46]=    "Chile", 
[47]=    "Cameroon", 
[48]=    "China", 
[49]=    "Colombia", 
[50]=    "Costa Rica", 
[51]=    "Cuba", 
[52]=    "Cape Verde",
[53]=    "Christmas Island", 
[54]=    "Cyprus", 
[55]=    "Czech Republic", 
[56]=    "Germany", 
[57]=    "Djibouti",
[58]=    "Denmark", 
[59]=    "Dominica", 
[60]=    "Dominican Republic", 
[61]=    "Algeria", 
[62]=    "Ecuador", 
[63]=    "Estonia",
[64]=    "Egypt", 
[65]=    "Western Sahara", 
[66]=    "Eritrea", 
[67]=    "Spain", 
[68]=    "Ethiopia", 
[69]=    "Finland", 
[70]=    "Fiji",
[71]=    "Falkland Islands (Malvinas)", 
[72]=    "Micronesia", 
[73]=    "Faroe Islands",
[74]=    "France", 
[75]=    "France, Metropolitan", 
[76]=    "Gabon", 
[77]=    "United Kingdom",
[78]=    "Grenada", 
[79]=    "Georgia", 
[80]=    "French Guiana", 
[81]=    "Ghana", 
[82]=    "Gibraltar", 
[83]=    "Greenland",
[84]=    "Gambia", 
[85]=    "Guinea", 
[86]=    "Guadeloupe", 
[87]=    "Equatorial Guinea", 
[88]=    "Greece", 
[89]=    "South Georgia and the South Sandwich Islands",
[90]=    "Guatemala", 
[91]=    "Guam", 
[92]=    "Guinea-Bissau",
[93]=    "Guyana", 
[94]=    "Hong Kong", 
[95]=    "Heard Island and McDonald Islands", 
[96]=    "Honduras",
[97]=    "Croatia", 
[98]=    "Haiti", 
[99]=    "Hungary", 
[100]=    "Indonesia", 
[101]=    "Ireland", 
[102]=    "Israel", 
[103]=    "India",
[104]=    "British Indian Ocean Territory", 
[105]=    "Iraq", 
[106]=    "Iran",
[107]=    "Iceland", 
[108]=    "Italy", 
[109]=    "Jamaica", 
[110]=    "Jordan", 
[111]=    "Japan", 
[112]=    "Kenya", 
[113]=    "Kyrgyzstan",
[114]=    "Cambodia", 
[115]=    "Kiribati", 
[116]=    "Comoros", 
[117]=    "Saint Kitts and Nevis", 
[118]=    "North Korea",
[119]=    "South Korea", 
[120]=    "Kuwait", 
[121]=    "Cayman Islands",
[122]=    "Kazakhstan", 
[123]=    "Laos", 
[124]=    "Lebanon", 
[125]=    "Saint Lucia",
[126]=    "Liechtenstein", 
[127]=    "Sri Lanka", 
[128]=    "Liberia", 
[129]=    "Lesotho", 
[130]=    "Lithuania", 
[131]=    "Luxembourg",
[132]=    "Latvia", 
[133]=    "Libya", 
[134]=    "Morocco", 
[135]=    "Monaco", 
[136]=    "Moldova",
[137]=    "Madagascar", 
[138]=    "Marshall Islands", 
[139]=    "Macedonia",
[140]=    "Mali", 
[141]=    "Burma", 
[142]=    "Mongolia", 
[143]=    "Macau", 
[144]=    "Northern Mariana Islands",
[145]=    "Martinique", 
[146]=    "Mauritania", 
[147]=    "Montserrat", 
[148]=    "Malta", 
[149]=    "Mauritius", 
[150]=    "Maldives",
[151]=    "Malawi", 
[152]=    "Mexico", 
[153]=    "Malaysia", 
[154]=    "Mozambique", 
[155]=    "Namibia", 
[156]=    "New Caledonia",
[157]=    "Niger", 
[158]=    "Norfolk Island", 
[159]=    "Nigeria", 
[160]=    "Nicaragua", 
[161]=    "Netherlands", 
[162]=    "Norway",
[163]=    "Nepal", 
[164]=    "Nauru", 
[165]=    "Niue", 
[166]=    "New Zealand", 
[167]=    "Oman", 
[168]=    "Panama", 
[169]=    "Peru", 
[170]=    "French Polynesia",
[171]=    "Papua New Guinea", 
[172]=    "Philippines", 
[173]=    "Pakistan", 
[174]=    "Poland", 
[175]=    "Saint Pierre and Miquelon",
[176]=    "Pitcairn Islands", 
[177]=    "Puerto Rico", 
[178]=    "Palestinian Territory",
[179]=    "Portugal", 
[180]=    "Palau", 
[181]=    "Paraguay", 
[182]=    "Qatar", 
[183]=    "Reunion", 
[184]=    "Romania",
[185]=    "Russian Federation", 
[186]=    "Rwanda", 
[187]=    "Saudi Arabia", 
[188]=    "Solomon Islands",
[189]=    "Seychelles", 
[190]=    "Sudan", 
[191]=    "Sweden", 
[192]=    "Singapore", 
[193]=    "Saint Helena", 
[194]=    "Slovenia",
[195]=    "Svalbard and Jan Mayen", 
[196]=    "Slovakia", 
[197]=    "Sierra Leone", 
[198]=    "San Marino", 
[199]=    "Senegal",
[200]=    "Somalia", 
[201]=    "Suriname", 
[202]=    "Sao Tome and Principe", 
[203]=    "El Salvador", 
[204]=    "Syria",
[205]=    "Swaziland", 
[206]=    "Turks and Caicos Islands", 
[207]=    "Chad", 
[208]=    "French Southern Territories",
[209]=    "Togo", 
[210]=    "Thailand", 
[211]=    "Tajikistan", 
[212]=    "Tokelau", 
[213]=    "Turkmenistan",
[214]=    "Tunisia", 
[215]=    "Tonga", 
[216]=    "Timor-Leste", 
[217]=    "Turkey", 
[218]=    "Trinidad and Tobago", 
[219]=    "Tuvalu",
[220]=    "Taiwan", 
[221]=    "Tanzania", 
[222]=    "Ukraine",
[223]=    "Uganda", 
[224]=    "United States Minor Outlying Islands", 
[225]=    "United States", 
[226]=    "Uruguay",
[227]=    "Uzbekistan", 
[228]=    "Holy See (Vatican City State)", 
[229]=    "Saint Vincent and the Grenadines",
[230]=    "Venezuela", 
[231]=    "Virgin Islands, British", 
[232]=    "Virgin Islands, U.S.",
[233]=    "Vietnam", 
[234]=    "Vanuatu", 
[235]=    "Wallis and Futuna", 
[236]=    "Samoa", 
[237]=    "Yemen", 
[238]=    "Mayotte",
[239]=    "Serbia", 
[240]=    "South Africa", 
[241]=    "Zambia", 
[242]=    "Montenegro", 
[243]=    "Zimbabwe",
[244]=    "Anonymous Proxy",
[245]=    "Satellite Provider",
[246]=    "Other",
[247]=    "Aland Islands",
[248]=    "Guernsey",
[249]=    "Isle of Man",
[250]=    "Jersey",
[251]=    "Saint Barthelemy",
[252]=    "Saint Martin",
[255]=    "Localhost",
}

function et_ClientConnect( clientNum, firstTime, isBot )
    if firstTime == 1 and isBot == 0 then
        local msg = string.gsub(message, "<name>", et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ), "name" ))

        local countryCode = et.gentity_get( clientNum, "sess.uci" )
        local countryName = countries[countryCode]

        if countryName then
            msg = string.gsub(msg, "<country>", countryName)
        else
            msg = string.gsub(msg, "<country>", countryCode)
        end

        local shrubLevel = et.G_shrubbot_level(clientNum)
        local shrubName = shrubname[shrubLevel]

        if shrubName then
            msg = string.gsub(msg, "<shrublvl>", shrubName)
        else
            msg = string.gsub(msg, "<shrublvl>", "Level " .. shrubLevel)
        end

--        msg = string.gsub(msg, "<ip>", shortenIP(et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ),"ip" )))

        if showPlayerFlags then
            if et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ), "cl_punkbuster" ) == "1" then
                msg = msg .. " ^5PB"
            end

            local guid = et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ), "cl_guid" )

            if guid == "NO_GUID" or guid == "unknown" then
                msg = msg .. " ^1NO_GUID"
            end

            if et.gentity_get( clientNum, "sess.referee" ) == 1 then
                msg = msg .. " ^3REF"
            end

            if et.gentity_get( clientNum, "sess.muted" ) == 1 then
                msg = msg .. " ^1MUTED"
            end
        end

        et.trap_SendConsoleCommand(et.EXEC_APPEND,"qsay " .. msg)
    end
end

--[[    Decided to ditch displaying the ip because it lengthens the line too much, especially for long shrubnames

    If you want to re-add this feature, un-comment line 321 and put the following lines back to their original position:
    line 13:   "^dConnect: ^3*^0KFG^3*^1Bullet ^yconnected from ^7Netherlands ^y(^794.214.*.*^y) (^8Admin^y). ^5PB ^3REF"
    line 23:  message = "^dConnect: ^7<name> ^yconnected from ^7<country> ^y(^7<ip>^y) ^y(^7<shrublvl>^y)."
    Also un-comment the function shortenIP() below.

function shortenIP(input)
    if input == "localhost" then
        return input
    end
    return (string.sub(input, 0, string.find(input, "%.", (string.find(input, "%.") + 1))) .. "*.*")
end

--]]

function et_Print(text)
    if string.sub(text,1,19) == "readconfig: loaded " then
        ReadShrubNames()
    end
end

function et_InitGame(levelTime, randomSeed, restart)
    et.RegisterModname("Connect Announce #1")
    ReadShrubNames()
end

function clearSpace(string)
    local output = ""
    local i = string.len(string)
    while (string.sub(string,i,i) == " " or string.sub(string,i,i) == "    ") do
        string = string.sub(string,1,(i-1))
        i = i - 1
    end

    while (string.sub(string,1,1) == " " or string.sub(string,1,1) == "    ") do
        string = string.sub(string,2)
    end

    i = 1
    while string.sub(string,i,i) ~= "" do
        if string.sub(string,i,i) ~= "\"" then
            output = output .. string.sub(string,i,i)
        end
        i = i + 1
    end
    return output
end

function ReadShrubNames()
    local level = ""
    local name = ""

    local fd, len = et.trap_FS_FOpenFile(et.trap_Cvar_Get("g_shrubbot"), et.FS_READ)

    if len > 1 then
        for line in string.gfind(et.trap_FS_Read(fd, len), "([    %C]+)") do
            if clearSpace(line) == "[level]" then
                if level ~= "" then
                    shrubname[level] = name
                    level = ""
                end
                var = true
            elseif clearSpace(line) == "[ban]" or clearSpace(line) == "[mute]" or clearSpace(line) == "[admin]" or clearSpace(line) == "[command]" then
                if level ~= "" then
                    shrubname[level] = name
                    level = ""
                end
                var = false
            elseif var then
                for k,v in string.gmatch(line, "([    %C]*)=(.*)") do
                    if clearSpace(k) == "level" then
                        level = tonumber(clearSpace(v))
                    elseif clearSpace(k) == "name" then
                        name = clearSpace(v)
                    end
                end
            end
        end

        if level ~= "" then
            shrubname[level] = name
        end
    end
end

Last edited by gavrila (19-Oct-11 09:02:19)

Offline

#2 19-Oct-11 20:01:38

N!trox*
Administrator
Registered: 30-Mar-10
Posts: 1,098

Re: connect.LUA

Just tested it on N!tmod 2.2 and it works.

The only thing that doesn't work with 2.2 is level names, because this lua script reads level names from shrubbot.cfg (or whatever g_shrubbot is set to), and N!tmod 2.2 doesn't use these files anymore.

If there is any big interest into this, we can add some LUA features to get a level name from a LUA script, or we can add this feature into the mod (should be pretty easy for us, and easier for admins...)

To show IP, just remove the "--" before this line :

--        msg = string.gsub(msg, "<ip>", shortenIP(et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ),"ip" )))

Uncomment the shortenIP function (put "--]]" before

function shortenIP(input)
    if input == "localhost" then
        return input
    end
    return (string.sub(input, 0, string.find(input, "%.", (string.find(input, "%.") + 1))) .. "*.*")
end

Remove the "--]]" after the above code.

And add "<ip>" to the message you want to display when client connects.

I made these changes and it worked correctly smile


iluvnitmod.png

Offline

#3 30-Oct-11 12:19:54

gavrila
BETA Tester
From: Usa
Registered: 15-Aug-10
Posts: 70
Website

Re: connect.LUA

Thank your  WORKS PERFECT

Offline

#4 04-Nov-11 12:39:16

Belfast
Member
Registered: 04-Nov-11
Posts: 1

Re: connect.LUA

What should I change to be without stars?

return (string.sub(input, 0, string.find(input, "%.", (string.find(input, "%.") + 1))) .. "*.*")


I want to appear in full IP. Please help.

Offline

#5 30-Aug-12 10:03:50

Gauki
BETA Tester
From: Germany
Registered: 30-Aug-12
Posts: 114
Website

Re: connect.LUA

is it possible to change/rework the connect.lau file in a way, that it only  show/print if someone connect

"connect: name from Country. PB" example :  "connect: Gauki from Germany. PB" ?

i want to delete the admin flags, couze of the shrub prob !?

can someone sent me the reworked connect.lau ? Thans 4 help ^^


DooC_sigbanner.gif

Offline

#6 07-Sep-12 19:44:53

ailmanki
BETA Tester
Registered: 08-Jun-12
Posts: 42
Website

Re: connect.LUA

Belfast wrote:

What should I change to be without stars?

return (string.sub(input, 0, string.find(input, "%.", (string.find(input, "%.") + 1))) .. "*.*")


I want to appear in full IP. Please help.

You should not show the full IP, why do you want that?
If you do that, then maybe log it, or show it to admins only?

Gauki wrote:

is it possible to change/rework the connect.lau file in a way, that it only  show/print if someone connect

"connect: name from Country. PB" example :  "connect: Gauki from Germany. PB" ?

i want to delete the admin flags, couze of the shrub prob !?

can someone sent me the reworked connect.lau ? Thans 4 help ^^

Removing the admin flag should be easy, but I dont understand the first request, 'that it only  show/print if someone connect'
Is it not already doing that?


b_350_20_692108_381007_FFFFFF_000000.pngb_350_20_692108_381007_FFFFFF_000000.png

Offline

#7 08-Sep-12 00:50:13

Grandad
BETA Tester
Registered: 29-Dec-11
Posts: 168

Re: connect.LUA

///Someone gave this to me. Shows all IP///
--[[
    Connect Announce #1
    ===================
    by Phishermans Phriend

    Further information:
    --------------------
    http://www.splashdamage.com/forums/show … post377700

    Features:
    ---------
    This script prints an enhmod-like line to chat whenever a client connects to the server. Example:
    "^dConnect: ^3*^0KFG^3*^1Bullet ^yconnected from ^7Netherlands ^y(^794.214.*.*^y) (^8Admin^y). ^5PB ^3REF"

    Important:
    ----------
    In order to use this script properly, you need to active g_countryflags. Read more about this on:
    http://shitstorm.org/noquarter/wiki/?ti … n_1.3.0.29
--]]

-- CONFIG SECTION

    message = "^dCONNECT: ^7<name> ^7<country> ^7<ip>"
                    -- Message line on clientconnect: The variables are replaced with the corresponding player data
                    -- You can remove any variable from the string to not display it.

    showPlayerFlags = true        -- If set to true, dynamic player flags will be shown after the connect-message:
                    -- "^5PB" if the player's client punkbuster is enabled
                    -- "^1NO_GUID" if the player's GUID is unknown or empty
                    -- "^3REF" if the player has referee status
                    -- "^1MUTED" if the player is muted

-- END OF CONFIG SECTION


-------------------------------------------------------------
--DONT CHANGE ANYTHING BELOW UNLESS YOU KNOW WHAT YOURE DOING
-------------------------------------------------------------

shrubname = {}

countries = {
[0]=    "Unknown",
[1]=    "Asia/Pacific Region",
[2]=    "Europe",
[3]=    "Andorra",
[4]=    "United Arab Emirates",
[5]=    "Afghanistan",
[6]=    "Antigua and Barbuda",
[7]=    "Anguilla",
[8]=    "Albania",
[9]=    "Armenia",
[10]=    "Netherlands Antilles",
[11]=    "Angola",
[12]=    "Antarctica",
[13]=    "Argentina",
[14]=    "American Samoa",
[15]=    "Austria",
[16]=    "Australia",
[17]=    "Aruba",
[18]=    "Azerbaijan",
[19]=    "Bosnia and Herzegovina",
[20]=    "Barbados",
[21]=    "Bangladesh",
[22]=    "Belgium",
[23]=    "Burkina Faso",
[24]=    "Bulgaria",
[25]=    "Bahrain",
[26]=    "Burundi",
[27]=    "Benin",
[28]=    "Bermuda",
[29]=    "Brunei Darussalam",
[30]=    "Bolivia",
[31]=    "Brazil",
[32]=    "Bahamas",
[33]=    "Bhutan",
[34]=    "Bouvet Island",
[35]=    "Botswana",
[36]=    "Belarus",
[37]=    "Belize",
[38]=    "Canada",
[39]=    "Cocos (Keeling) Islands",
[40]=    "Congo-Kinshasa",
[41]=    "Central African Republic",
[42]=    "Congo-Brazzaville",
[43]=    "Switzerland",
[44]=    "Cote D'Ivoire",
[45]=    "Cook Islands",
[46]=    "Chile",
[47]=    "Cameroon",
[48]=    "China",
[49]=    "Colombia",
[50]=    "Costa Rica",
[51]=    "Cuba",
[52]=    "Cape Verde",
[53]=    "Christmas Island",
[54]=    "Cyprus",
[55]=    "Czech Republic",
[56]=    "Germany",
[57]=    "Djibouti",
[58]=    "Denmark",
[59]=    "Dominica",
[60]=    "Dominican Republic",
[61]=    "Algeria",
[62]=    "Ecuador",
[63]=    "Estonia",
[64]=    "Egypt",
[65]=    "Western Sahara",
[66]=    "Eritrea",
[67]=    "Spain",
[68]=    "Ethiopia",
[69]=    "Finland",
[70]=    "Fiji",
[71]=    "Falkland Islands (Malvinas)",
[72]=    "Micronesia",
[73]=    "Faroe Islands",
[74]=    "France",
[75]=    "France, Metropolitan",
[76]=    "Gabon",
[77]=    "United Kingdom",
[78]=    "Grenada",
[79]=    "Georgia",
[80]=    "French Guiana",
[81]=    "Ghana",
[82]=    "Gibraltar",
[83]=    "Greenland",
[84]=    "Gambia",
[85]=    "Guinea",
[86]=    "Guadeloupe",
[87]=    "Equatorial Guinea",
[88]=    "Greece",
[89]=    "South Georgia and the South Sandwich Islands",
[90]=    "Guatemala",
[91]=    "Guam",
[92]=    "Guinea-Bissau",
[93]=    "Guyana",
[94]=    "Hong Kong",
[95]=    "Heard Island and McDonald Islands",
[96]=    "Honduras",
[97]=    "Croatia",
[98]=    "Haiti",
[99]=    "Hungary",
[100]=    "Indonesia",
[101]=    "Ireland",
[102]=    "Israel",
[103]=    "India",
[104]=    "British Indian Ocean Territory",
[105]=    "Iraq",
[106]=    "Iran",
[107]=    "Iceland",
[108]=    "Italy",
[109]=    "Jamaica",
[110]=    "Jordan",
[111]=    "Japan",
[112]=    "Kenya",
[113]=    "Kyrgyzstan",
[114]=    "Cambodia",
[115]=    "Kiribati",
[116]=    "Comoros",
[117]=    "Saint Kitts and Nevis",
[118]=    "North Korea",
[119]=    "South Korea",
[120]=    "Kuwait",
[121]=    "Cayman Islands",
[122]=    "Kazakhstan",
[123]=    "Laos",
[124]=    "Lebanon",
[125]=    "Saint Lucia",
[126]=    "Liechtenstein",
[127]=    "Sri Lanka",
[128]=    "Liberia",
[129]=    "Lesotho",
[130]=    "Lithuania",
[131]=    "Luxembourg",
[132]=    "Latvia",
[133]=    "Libya",
[134]=    "Morocco",
[135]=    "Monaco",
[136]=    "Moldova",
[137]=    "Madagascar",
[138]=    "Marshall Islands",
[139]=    "Macedonia",
[140]=    "Mali",
[141]=    "Burma",
[142]=    "Mongolia",
[143]=    "Macau",
[144]=    "Northern Mariana Islands",
[145]=    "Martinique",
[146]=    "Mauritania",
[147]=    "Montserrat",
[148]=    "Malta",
[149]=    "Mauritius",
[150]=    "Maldives",
[151]=    "Malawi",
[152]=    "Mexico",
[153]=    "Malaysia",
[154]=    "Mozambique",
[155]=    "Namibia",
[156]=    "New Caledonia",
[157]=    "Niger",
[158]=    "Norfolk Island",
[159]=    "Nigeria",
[160]=    "Nicaragua",
[161]=    "Netherlands",
[162]=    "Norway",
[163]=    "Nepal",
[164]=    "Nauru",
[165]=    "Niue",
[166]=    "New Zealand",
[167]=    "Oman",
[168]=    "Panama",
[169]=    "Peru",
[170]=    "French Polynesia",
[171]=    "Papua New Guinea",
[172]=    "Philippines",
[173]=    "Pakistan",
[174]=    "Poland",
[175]=    "Saint Pierre and Miquelon",
[176]=    "Pitcairn Islands",
[177]=    "Puerto Rico",
[178]=    "Palestinian Territory",
[179]=    "Portugal",
[180]=    "Palau",
[181]=    "Paraguay",
[182]=    "Qatar",
[183]=    "Reunion",
[184]=    "Romania",
[185]=    "Russian Federation",
[186]=    "Rwanda",
[187]=    "Saudi Arabia",
[188]=    "Solomon Islands",
[189]=    "Seychelles",
[190]=    "Sudan",
[191]=    "Sweden",
[192]=    "Singapore",
[193]=    "Saint Helena",
[194]=    "Slovenia",
[195]=    "Svalbard and Jan Mayen",
[196]=    "Slovakia",
[197]=    "Sierra Leone",
[198]=    "San Marino",
[199]=    "Senegal",
[200]=    "Somalia",
[201]=    "Suriname",
[202]=    "Sao Tome and Principe",
[203]=    "El Salvador",
[204]=    "Syria",
[205]=    "Swaziland",
[206]=    "Turks and Caicos Islands",
[207]=    "Chad",
[208]=    "French Southern Territories",
[209]=    "Togo",
[210]=    "Thailand",
[211]=    "Tajikistan",
[212]=    "Tokelau",
[213]=    "Turkmenistan",
[214]=    "Tunisia",
[215]=    "Tonga",
[216]=    "Timor-Leste",
[217]=    "Turkey",
[218]=    "Trinidad and Tobago",
[219]=    "Tuvalu",
[220]=    "Taiwan",
[221]=    "Tanzania",
[222]=    "Ukraine",
[223]=    "Uganda",
[224]=    "United States Minor Outlying Islands",
[225]=    "United States",
[226]=    "Uruguay",
[227]=    "Uzbekistan",
[228]=    "Holy See (Vatican City State)",
[229]=    "Saint Vincent and the Grenadines",
[230]=    "Venezuela",
[231]=    "Virgin Islands, British",
[232]=    "Virgin Islands, U.S.",
[233]=    "Vietnam",
[234]=    "Vanuatu",
[235]=    "Wallis and Futuna",
[236]=    "Samoa",
[237]=    "Yemen",
[238]=    "Mayotte",
[239]=    "Serbia",
[240]=    "South Africa",
[241]=    "Zambia",
[242]=    "Montenegro",
[243]=    "Zimbabwe",
[244]=    "Anonymous Proxy",
[245]=    "Satellite Provider",
[246]=    "Other",
[247]=    "Aland Islands",
[248]=    "Guernsey",
[249]=    "Isle of Man",
[250]=    "Jersey",
[251]=    "Saint Barthelemy",
[252]=    "Saint Martin",
[255]=    "Localhost",
}

function et_ClientConnect( clientNum, firstTime, isBot )
    if firstTime == 1 and isBot == 0 then
        local msg = string.gsub(message, "<name>", et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ), "name" ))

        local countryCode = et.gentity_get( clientNum, "sess.uci" )
        local countryName = countries[countryCode]

        if countryName then
            msg = string.gsub(msg, "<country>", countryName)
        else
            msg = string.gsub(msg, "<country>", countryCode)
        end

        local shrubLevel = et.G_shrubbot_level(clientNum)
        local shrubName = shrubname[shrubLevel]

        if shrubName then
            msg = string.gsub(msg, "<shrublvl>", shrubName)
        else
            msg = string.gsub(msg, "<shrublvl>", "Level " .. shrubLevel)
        end

        msg = string.gsub(msg, "<ip>", et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ),"ip" ))


        if showPlayerFlags then
            if et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ), "cl_punkbuster" ) == "1" then
                msg = msg .. " ^5PB"
            end

            local guid = et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ), "cl_guid" )

            if guid == "NO_GUID" or guid == "unknown" then
                msg = msg .. " ^1NO_GUID"
            end

            if et.gentity_get( clientNum, "sess.referee" ) == 1 then
                msg = msg .. " ^3REF"
            end

            if et.gentity_get( clientNum, "sess.muted" ) == 1 then
                msg = msg .. " ^1MUTED"
            end
        end

        et.trap_SendConsoleCommand(et.EXEC_APPEND,"qsay " .. msg)
    end
end

--[[    Decided to ditch displaying the ip because it lengthens the line too much, especially for long shrubnames

    If you want to re-add this feature, un-comment line 321 and put the following lines back to their original position:
    line 13:   "^dConnect: ^3*^0KFG^3*^1Bullet ^yconnected from ^7Netherlands ^y(^794.214.*.*^y) (^8Admin^y). ^5PB ^3REF"
    line 23:  message = "^dConnect: ^7<name> ^yconnected from ^7<country> ^y(^7<ip>^y) ^y(^7<shrublvl>^y)."
    Also un-comment the function shortenIP() below.

--]] function shortenIP (input)
    if input =="ip"  then
        return input
    end
    return (string.sub(input, 0, string.find(input, "%.", (string.find(input, "%.") + 1))) .. "*.*")
end



function et_Print(text)
    if string.sub(text,1,19) == "readconfig: loaded " then
        ReadShrubNames()
    end
end

function et_InitGame(levelTime, randomSeed, restart)
    et.RegisterModname("Connect Announce #1")
    ReadShrubNames()
end

function clearSpace(string)
    local output = ""
    local i = string.len(string)
    while (string.sub(string,i,i) == " " or string.sub(string,i,i) == "    ") do
        string = string.sub(string,1,(i-1))
        i = i - 1
    end

    while (string.sub(string,1,1) == " " or string.sub(string,1,1) == "    ") do
        string = string.sub(string,2)
    end

    i = 1
    while string.sub(string,i,i) ~= "" do
        if string.sub(string,i,i) ~= "\"" then
            output = output .. string.sub(string,i,i)
        end
        i = i + 1
    end
    return output
end

function ReadShrubNames()
    local level = ""
    local name = ""

    local fd, len = et.trap_FS_FOpenFile(et.trap_Cvar_Get("g_shrubbot"), et.FS_READ)

    if len > 1 then
        for line in string.gfind(et.trap_FS_Read(fd, len), "([    %C]+)") do
            if clearSpace(line) == "[level]" then
                if level ~= "" then
                    shrubname[level] = name
                    level = ""
                end
                var = true
            elseif clearSpace(line) == "[ban]" or clearSpace(line) == "[mute]" or clearSpace(line) == "[admin]" or clearSpace(line) == "[command]" then
                if level ~= "" then
                    shrubname[level] = name
                    level = ""
                end
                var = false
            elseif var then
                for k,v in string.gmatch(line, "([    %C]*)=(.*)") do
                    if clearSpace(k) == "level" then
                        level = tonumber(clearSpace(v))
                    elseif clearSpace(k) == "name" then
                        name = clearSpace(v)
                    end
                end
            end
        end

        if level ~= "" then
            shrubname[level] = name
        end
    end
end

Offline

#8 22-Oct-12 23:50:50

Gauki
BETA Tester
From: Germany
Registered: 30-Aug-12
Posts: 114
Website

Re: connect.LUA

thanks for your help  smile next time i have to read first all sad i just removed the guid check and now its working smile


DooC_sigbanner.gif

Offline

#9 17-Dec-12 14:44:15

TunPal-XXXX
BETA Tester
Registered: 26-Oct-12
Posts: 40

Re: connect.LUA

N!trox* wrote:

Just tested it on N!tmod 2.2 and it works.

The only thing that doesn't work with 2.2 is level names, because this lua script reads level names from shrubbot.cfg (or whatever g_shrubbot is set to), and N!tmod 2.2 doesn't use these files anymore.

If there is any big interest into this, we can add some LUA features to get a level name from a LUA script, or we can add this feature into the mod (should be pretty easy for us, and easier for admins...)

i think we have a big interet into this xD
LUA can't access the database to get player's level. autopromotion and connect dont' wrok correctly
can u add a lua wrapper to sqlite to get it works with it? many lua modules don't work properly eg getlevel function
or add this feature into the mod as u had suggested?

Last edited by TunPal-XXXX (17-Dec-12 14:44:33)

Offline

Board footer

Powered by FluxBB