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 13-Dec-10 11:27:54

Nawi
Member
Registered: 13-Dec-10
Posts: 12
Website

Re: [Solved] Autopromotion lua

Well hello,

Im Nawi ill start hosting my own server..
i know its my first post but i want to requestthis:
a lua script wich Promotes(!setlevel x) based on the XP.
So visitors can get a little level too if theyre active on my server, something like 0 to 20.

well to the script ,
i dont know how to make luas sad otherwise i could do it myself -.-' and i dont have to annoy u ...

it should be a bit customizeable:

Nawi wrote:
    -> How many Levels Exist
    -> How many XP needed for what level
    -> Maybe a demotion script if he resets xp or something
    -> If it works ( i dont know if ) it should automaticly set the users.
    ~~~>ELSE a /Promoteme command ... ill use that for shrubbot -> !promoteme (i know how it works)

well i hope you guys can make one for me big_smile

P.S.: I know my english is awfull but im working on it xD

--Regards Nawi

Offline

#2 08-Jan-11 20:32:27

yori
Member
Registered: 07-Jan-11
Posts: 2

Re: [Solved] Autopromotion lua

Version =     "0.2a"
Description = "Autosetlevel"
----------------------------------------------------------------------
--made 4 etpub only
--global vars
----------------------------------------------------------------------

lvl1xp = 5000
lvl2xp = 10000
lvl3xp = 15000
--------------hier nix mehr ndern ausser die messages----------------


function et_InitGame(levelTime,randomSeed,restart)
        et.G_Print(""..Description.." Version:".. Version .." Loaded\n")
        et.RegisterModname(""..Description..":".. Version .."slot:".. et.FindSelf())
end

function et_ClientSpawn( clientNum, revived, teamChange, restoreHealth )
    if getXP(clientNum) >=  lvl1xp and getXP(clientNum) < lvl2xp then     -- lvl1setzen
        setlevel(clientNum,1,lvl1xp)
    elseif getXP(clientNum) >=  lvl2xp and getXP(clientNum) < lvl3xp then     -- lvl2setzen
        setlevel(clientNum,2,lvl2xp)
    elseif getXP(clientNum) >=  lvl3xp then    -- lvl3setzen
        setlevel(clientNum,3,lvl3xp)
    end
end

function getXP(playerID)
    return  et.gentity_get(playerID, "ps.persistant", 0)   -- STAT_XP etsrc
end

function getlevel(playerID)
    return et.G_shrubbot_level(playerID)
end

function setlevel(playerID, newlevel, xp)
    local name = et.gentity_get(playerID,"pers.netname") -- name auslesen
    if isBot(playerID) then return end
    if newlevel <= getlevel(playerID) then return end
        et.trap_SendServerCommand(-1,"cp \"^7"..name.." ^0has ^0reached ^1"..xp.."XP ^0he ^0is ^0now ^0a ^1level "..newlevel.." user\"")
        et.trap_SendConsoleCommand( et.EXEC_APPEND, "setlevel ".. playerID.." "..newlevel.."\n" )
        et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" )
end

function isBot(playerID)
    if et.gentity_get(playerID,"ps.ping") == 0 then
    return true
    end
end

Offline

#3 10-Jan-11 14:34:32

Nawi
Member
Registered: 13-Dec-10
Posts: 12
Website

Re: [Solved] Autopromotion lua

Nice thanks working good smile

Offline

#4 14-Jan-11 20:16:49

Smooths
Member
Registered: 03-Aug-10
Posts: 10

Re: [Solved] Autopromotion lua

Our server allows players with NO guide to connect. This script is great accept when setting levels for players with No guide. Once a player with NO guide has reached the minimum xp for level 1, the script attempts to setlevel for that player and continues to repeat it everytime the players xp increases so the screen is spammed with the achieved level message constantly.

Any fix for players with NO guide?

Cheers
Smooths

Offline

#5 14-Jan-11 22:04:52

Dragonji
Member
From: Poland
Registered: 19-Aug-10
Posts: 88
Website

Re: [Solved] Autopromotion lua

Smooths wrote:

...NO guide...

You mean GUID mate big_smile

Smooths wrote:

Any fix for players with NO guide?

I don't think so, as long as it's based on PB GUID :)One solution -> enable PB on your server.

Offline

#6 16-Jan-11 17:38:14

Smooths
Member
Registered: 03-Aug-10
Posts: 10

Re: [Solved] Autopromotion lua

If PB lagg wasn't so bad I would consider it wink

Offline

#7 31-Jan-11 22:48:28

Perlo0ung
Member
Registered: 31-Jan-11
Posts: 3

Re: [Solved] Autopromotion lua

ahha its nice that u removed my authors name of the lua....
well preventing for noguids is easy.. just do this

Version = 	"0.3a"
Author  =   "Perlo_0ung?!"
Description = "Autosetlevel"
Homepage = "www.ef-clan.org"

----------------------------------------------------------------------
--made 4 etpub only 
--global vars
----------------------------------------------------------------------

lvl1xp = 5000
lvl2xp = 10000
lvl3xp = 15000
--------------Do not edit below this line-------------------------


function et_InitGame(levelTime,randomSeed,restart)
        et.G_Print(""..Description.." Version:".. Version .." Loaded\n")
        et.RegisterModname(""..Description..":".. Version .."slot:".. et.FindSelf())
end

function et_ClientSpawn( clientNum, revived, teamChange, restoreHealth )
	if getXP(clientNum) >=  lvl1xp and getXP(clientNum) < lvl2xp then 	
		setlevel(clientNum,1,lvl1xp)
	elseif getXP(clientNum) >=  lvl2xp and getXP(clientNum) < lvl3xp then 	
		setlevel(clientNum,2,lvl2xp)
	elseif getXP(clientNum) >=  lvl3xp then    
		setlevel(clientNum,3,lvl3xp)
	end 
end

function getXP(playerID)
	return  et.gentity_get(playerID, "ps.persistant", 0)   
end 

function getlevel(playerID)
	return et.G_shrubbot_level(playerID)
end 

function setlevel(playerID, newlevel, xp)
	local name = et.gentity_get(playerID,"pers.netname") 
	if isBot(playerID) or noGuid(playerID) then return end
	if newlevel <= getlevel(playerID) then return end 
		et.trap_SendServerCommand(-1,"cp \"^7"..name.." ^0has ^0reached ^1"..xp.."XP ^0he ^0is ^0now ^0a ^1level "..newlevel.." user\"") 
		et.trap_SendConsoleCommand( et.EXEC_APPEND, "setlevel ".. playerID.." "..newlevel.."\n" ) 
		et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" ) 
end

function noGuid(playerID)
        local userinfo = et.trap_GetUserinfo( playerID )
	local guid     = et.Info_ValueForKey( userinfo, "cl_guid" )
	if guid == "unknown" then  
	return true
    end
end

 function isBot(playerID)
	if et.gentity_get(playerID,"ps.ping") == 0 then
	return true
	end
end

Offline

#8 01-Feb-11 21:53:54

M.Bambus
Member
Registered: 15-Jan-11
Posts: 12

Re: [Solved] Autopromotion lua

Perlo0ung wrote:

ahha its nice that u removed my authors name of the lua....
well preventing for noguids is easy.. just do this

Thank you very much mate!

i added your name in our servers lua, didnt know that it was stolen:mad:

I appreciate your work!

Offline

#9 09-Mar-11 21:59:23

frusciante
Member
Registered: 09-Mar-11
Posts: 4

Re: [Solved] Autopromotion lua

Version = "0.2a"
Version =    "0.3a"
Author  =   "Perlo_0ung?!"
Description = "Autosetlevel"
Homepage = "www.ef-clan.org"

----------------------------------------------------------------------
Description = "Autosetlevel"
----------------------------------------------------------------------
--made 4 etpub only
--global vars
----------------------------------------------------------------------

lvl1xp = 750
lvl2xp = 7000
lvl3xp = 10000
lvl4xp = 15000
lvl5xp = 25000

--------------hier nix mehr ?ndern ausser die messages----------------


function et_InitGame(levelTime,randomSeed,restart)
et.G_Print(""..Description.." Version:".. Version .." Loaded\n")
et.RegisterModname(""..Description..":".. Version .."slot:".. et.FindSelf())
end

function et_ClientSpawn( clientNum, revived, teamChange, restoreHealth )
if getXP(clientNum) >= lvl1xp and getXP(clientNum) < lvl2xp then -- lvl1setzen
setlevel(clientNum,1,lvl1xp)
elseif getXP(clientNum) >= lvl2xp and getXP(clientNum) < lvl3xp then -- lvl2setzen
setlevel(clientNum,2,lvl2xp)
elseif getXP(clientNum) >= lvl2xp and getXP(clientNum) < lvl4xp then -- lvl2setzen
setlevel(clientNum,3,lvl3xp)
elseif getXP(clientNum) >= lvl2xp and getXP(clientNum) < lvl5xp then -- lvl2setzen
setlevel(clientNum,4,lvl4xp)
elseif getXP(clientNum) >= lvl5xp then -- lvl3setzen
setlevel(clientNum,5,lvl5xp)
end
end

function getXP(playerID)
return et.gentity_get(playerID, "ps.persistant", 0) -- STAT_XP etsrc
end

function getlevel(playerID)
return et.G_shrubbot_level(playerID)
end

function setlevel(playerID, newlevel, xp)
local name = et.gentity_get(playerID,"pers.netname") -- name auslesen
if isBot(playerID) then return end
if newlevel <= getlevel(playerID) then return end
et.trap_SendServerCommand(-1,"cp \"^7"..name.." ^0has ^0reached ^1"..xp.."XP ^0he ^0is ^0now ^0a ^1 "..newlevel.."!!\"")
et.trap_SendConsoleCommand( et.EXEC_APPEND, "setlevel ".. playerID.." "..newlevel.."\n" )
et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" )
end

function isBot(playerID)
if et.gentity_get(playerID,"ps.ping") == 0 then
return true
end
end

Can someone help me? it doesnt work :'(
did i make error with adding 2 more xp's?

Offline

#10 10-Mar-11 23:50:15

bLiNk
Member
Registered: 31-Mar-10
Posts: 62

Re: [Solved] Autopromotion lua

Not sure how lua scripting works. Give this modify version a try frusciante.

Autopromotion.lua or Autosetlevel.lua <---Not sure which name is right

Version =    "0.3a"
Author  =   "Perlo_0ung?!"
Description = "Autosetlevel"
Homepage = "www.ef-clan.org"

----------------------------------------------------------------------
--made 4 etpub only
--global vars
----------------------------------------------------------------------

lvl1xp = 750
lvl2xp = 7000
lvl3xp = 10000
lvl4xp = 15000
lvl5xp = 25000

--------------Do not edit below this line-------------------------

function et_InitGame(levelTime,randomSeed,restart)
        et.G_Print(""..Description.." Version:".. Version .." Loaded\n")
        et.RegisterModname(""..Description..":".. Version .."slot:".. et.FindSelf())
end

function et_ClientSpawn( clientNum, revived, teamChange, restoreHealth )
   if getXP(clientNum) >=  lvl1xp and getXP(clientNum) < lvl2xp then    
      setlevel(clientNum,1,lvl1xp)
   elseif getXP(clientNum) >=  lvl2xp and getXP(clientNum) < lvl3xp then    
      setlevel(clientNum,2,lvl2xp)
   elseif getXP(clientNum) >=  lvl3xp and getXP(clientNum) < lvl4xp then    
      setlevel(clientNum,3,lvl3xp)
   elseif getXP(clientNum) >=  lvl4xp and getXP(clientNum) < lvl5xp then    
      setlevel(clientNum,4,lvl4xp)
   elseif getXP(clientNum) >=  lvl5xp then   
      setlevel(clientNum,5,lvl5xp)
   end
end

function getXP(playerID)
   return  et.gentity_get(playerID, "ps.persistant", 0)   
end

function getlevel(playerID)
   return et.G_shrubbot_level(playerID)
end

function setlevel(playerID, newlevel, xp)
   local name = et.gentity_get(playerID,"pers.netname")
   if isBot(playerID) or noGuid(playerID) then return end
   if newlevel <= getlevel(playerID) then return end
      et.trap_SendServerCommand(-1,"cp \"^7"..name.." ^0has ^0reached ^1"..xp.."XP ^0he ^0is ^0now ^0a ^1level "..newlevel.." user\"")
      et.trap_SendConsoleCommand( et.EXEC_APPEND, "setlevel ".. playerID.." "..newlevel.."\n" )
      et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" )
end

function noGuid(playerID)
        local userinfo = et.trap_GetUserinfo( playerID )
   local guid     = et.Info_ValueForKey( userinfo, "cl_guid" )
   if guid == "unknown" then 
   return true
    end
end

function isBot(playerID)
   if et.gentity_get(playerID,"ps.ping") == 0 then
   return true
   end
end

Credit goes to Perlo0ung for original lua script.

Edit:
Correction in script.

Offline

#11 11-Mar-11 18:18:46

frusciante
Member
Registered: 09-Mar-11
Posts: 4

Re: [Solved] Autopromotion lua

Works now thanks matey

Offline

#12 14-Mar-11 01:19:25

Perlo0ung
Member
Registered: 31-Jan-11
Posts: 3

Re: [Solved] Autopromotion lua

nah... take care at:

setlevel(clientNum,3,lvl5xp)

its defined like this
setlevel ( who , whatlevel , at what xp)

Offline

#13 14-Mar-11 08:42:57

bLiNk
Member
Registered: 31-Mar-10
Posts: 62

Re: [Solved] Autopromotion lua

Thank you for pointing out my mistake Perlo0ung. Like I said, I know nothing about lua scripting. Hopefully I got it right this time.

See first page for correction frusciante.

Offline

#14 11-Jun-11 23:45:59

stealth
Member
Registered: 16-Oct-10
Posts: 43

Re: [Solved] Autopromotion lua

Is there a way to debug lua scripts?
I tried this script, well I adjusted it a bit  (added an elseif structure) but it seems to get stuck on the setlevel part...?

I was wondering if this is caused by the bug that says "You can not setlevel yourself higher then your current level" when you run setlevel through rcon on 2.0 or if it was a different bug, I looked in the server console, but it didn't say anything.

Offline

#15 12-Jun-11 17:08:03

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

Re: [Solved] Autopromotion lua

In old N!tmod versions you can't setlevel higher than 64 through rcon.

This is fixed in 2.2


iluvnitmod.png

Offline

#16 12-Jun-11 17:09:37

stealth
Member
Registered: 16-Oct-10
Posts: 43

Re: [Solved] Autopromotion lua

N!trox* wrote:

In old N!tmod versions you can't setlevel higher than 64 through rcon.

This is fixed in 2.2

Awesome!

Offline

#17 16-Sep-11 15:38:08

Skyline
Member
Registered: 16-Sep-11
Posts: 13

Re: [Solved] Autopromotion lua

Simple question: how to add a sound when a player has received the level?

Offline

#18 20-Sep-11 00:42:41

loudness
Member
Registered: 20-Sep-11
Posts: 15

Re: [Solved] Autopromotion lua

hi...
search this lines in script


    if newlevel <= getlevel(playerID) then return end
        et.trap_SendServerCommand(-1,"cp \"^7"..name.." ^0has ^0reached ^1"..xp.."XP ^0he ^0is ^0now ^0a ^1level "..newlevel.." user\"")
        et.trap_SendConsoleCommand( et.EXEC_APPEND, "setlevel ".. playerID.." "..newlevel.."\n" )
        et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" )
end

and modify to be like this


    if newlevel <= getlevel(playerID) then return end
        et.trap_SendServerCommand(-1,"cp \"^7"..name.." ^0has ^0reached ^1"..xp.."XP ^0he ^0is ^0now ^0a ^1level "..newlevel.." user\"")
        et.trap_SendConsoleCommand( et.EXEC_APPEND, "setlevel ".. playerID.." "..newlevel.."\n" )
        et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" )
        et.G_globalSound( "sound/misc/skill_up.wav" )
end



i dont tested yet but is a great ideea and  and for sure will work,,,, i put in my scripts too...
cheers

Last edited by loudness (20-Sep-11 00:44:34)

Offline

#19 22-Jun-12 18:10:54

incognida
Member
Registered: 22-Jun-12
Posts: 1

Re: [Solved] Autopromotion lua

Hi first of all gratz 4 this script.
I wish use this one on my serwer but I had a problem.
I using kmod.lua with different admin levels.
To sets admins on kmod I have to type !setlevel via console or rcon
Is chance get this script doing this 4 me ????????
Othervise this script is useless in my situation.
thanks for any help

Offline

#20 20-Dec-12 22:31:54

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

Re: [Solved] Autopromotion lua

the code is not working
module is loaded
but there is no setlevel at specific levelxp

Offline

#21 20-Dec-12 23:24:54

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

Re: [Solved] Autopromotion lua

This script is used on #LSD servers and it works perfectly.

!setlevel is executed when client respawns.


iluvnitmod.png

Offline

#22 21-Dec-12 13:26:09

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

Re: [Solved] Autopromotion lua

haha i workes now 3 days on this lua and its alwyays running.. but i dont wait till the respawn big_smile haha

thanks n!t


DooC_sigbanner.gif

Offline

#23 13-Aug-13 18:32:34

Mardokpl
Member
Registered: 24-Jun-10
Posts: 18

Re: [Solved] Autopromotion lua

Hi I have problem that lua doesnt want work, this may be due to sqlite ? Can not read xp players ??

Offline

#24 02-Sep-13 15:00:05

KoKo
Member
From: FRANCE
Registered: 29-Jun-13
Posts: 8
Website

Re: [Solved] Autopromotion lua

Version =     "0.3c"
Author  =   "Perlo_0ung?!"
Description = "Autosetlevel"
Homepage = "www.ef-clan.org"

--v.03b: added name function
--v0.3c: added more levels

----------------------------------------------------------------------
--made 4 etpub only 
--global vars
--Le Bar Des Clans
----------------------------------------------------------------------

lvl1xp = 1000
lvl2xp = 1500
lvl3xp = 2500
lvl4xp = 4000
lvl5xp = 7500
lvl6xp = 12500
lvl7xp = 15000
lvl8xp = 17500
lvl9xp = 20000
lvl10xp = 30000

--------------Do not edit below this line-------------------------


function et_InitGame(levelTime,randomSeed,restart)
        et.G_Print(""..Description.." Version:".. Version .." Loaded\n")
        et.RegisterModname(""..Description..":".. Version .."slot:".. et.FindSelf())
end

function et_ClientSpawn( clientNum, revived, teamChange, restoreHealth )
    if getXP(clientNum) >=  lvl1xp and getXP(clientNum) < lvl2xp then     -- lvl1setzen
        setlevel(clientNum,1,lvl1xp)
    elseif getXP(clientNum) >=  lvl2xp and getXP(clientNum) < lvl3xp then     -- lvl2setzen
        setlevel(clientNum,2,lvl2xp)
	elseif getXP(clientNum) >=  lvl3xp and getXP(clientNum) < lvl4xp then     -- lvl3setzen
        setlevel(clientNum,3,lvl3xp)
	elseif getXP(clientNum) >=  lvl4xp and getXP(clientNum) < lvl5xp then     -- lvl4setzen
        setlevel(clientNum,4,lvl4xp)
	elseif getXP(clientNum) >=  lvl5xp and getXP(clientNum) < lvl6xp then     -- lvl5setzen
        setlevel(clientNum,5,lvl5xp)	
	elseif getXP(clientNum) >=  lvl6xp and getXP(clientNum) < lvl7xp then     -- lvl6setzen
        setlevel(clientNum,6,lvl6xp)
	elseif getXP(clientNum) >=  lvl7xp and getXP(clientNum) < lvl8xp then     -- lvl7setzen
        setlevel(clientNum,7,lvl7xp)
	elseif getXP(clientNum) >=  lvl8xp and getXP(clientNum) < lvl9xp then     -- lvl8setzen
        setlevel(clientNum,8,lvl8xp)	
	elseif getXP(clientNum) >=  lvl9xp and getXP(clientNum) < lvl10xp then     -- lvl9setzen
        setlevel(clientNum,9,lvl9xp)	
    elseif getXP(clientNum) >=  lvl10xp then    -- lvl10setzen
        setlevel(clientNum,10,lvl10xp)
    end 
end

function getXP(playerID)
    return  et.gentity_get(playerID, "ps.persistant", 0)   -- STAT_XP etsrc
end 

function getlevel(playerID)
    return et.G_shrubbot_level(playerID)
end 

function setlevel(playerID, newlevel, xp)
    local name = et.gentity_get(playerID,"pers.netname") -- name auslesen
    if isBot(playerID) then return end
    if newlevel <= getlevel(playerID) then return end 
        et.trap_SendServerCommand(-1,"cp \"^7"..name.." ^1a obtenu "..xp.." ^1XP, ^7il ^1a ^7maintenant ^1le ^7level ^1"..newlevel.." ^3FELICITATION!\"") 
        et.trap_SendConsoleCommand( et.EXEC_APPEND, "setlevel ".. playerID.." "..newlevel.."\n" ) 
        et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" ) 
end

function isBot(playerID)
    if et.gentity_get(playerID,"ps.ping") == 0 then
    return true
    end
end

This one work on my server.

You didn't forgot to put your lua in your set lua_modules "name.lua" ?


et.png

3981282.png

Offline

#25 13-Sep-13 20:51:50

Mardokpl
Member
Registered: 24-Jun-10
Posts: 18

Re: [Solved] Autopromotion lua

It works without a problem, somehow it working

Offline

Board footer

Powered by FluxBB