Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google Log In with Steam Sign In
  • Create Account
Photo

Autopromotion - Enemy Territory LUA

- - - - - lua autopromotion autopromo

  • Please log in to reply
11 replies to this topic

#1
OFFLINE   Dragonji

Dragonji

    Advanced Member

  • Members
  • PipPipPipPip
  • 514 posts
142
On the road to fame
  • LocationPoland
File Name: AutoPromo
File Submitter: Dragon
File Submitted: 20 Feb 2012
File Category: LUA

AutoPromo Lua script which automatically sets admin levels basing on player's XP.

Installation:
1. Unzip.
2. Open the file with notepad and configure it for your needs.
3. Upload it into "silent" folder located on your server.
4. Add "autopromo.lua" to lua_modules cvar.

Click here to download this file

Edited by Dragon, 06 August 2012 - 03:03 PM.


#2
OFFLINE   Dookie

Dookie

    Advanced Member

  • Members
  • PipPipPipPip
  • 420 posts
55
Getting Better
  • LocationCroatia
ow this is great! ty! can you just tell me what I need to write in notepad file if i want for example

Level 1 when people reach 1000 xp
Level 2 when people reach 10000xp
Level 3 when people reach 50000xp

thx

Edited by Dookie, 23 May 2012 - 06:38 AM.


#3
OFFLINE   TheSilencerPL

TheSilencerPL

    Advanced Member

  • Management
  • PipPipPipPip
  • 3098 posts
216
On the road to fame
  • LocationPoland
Some comments to the code.
function et_ClientSpawn calls getXP 9 times.
getXP itself asks the game through the et_gentity_get

To make it better, faster, less aggravating for the game store the XP locally and reuse it.
For example:
function et_ClientSpawn( clientNum, revived, teamChange, restoreHealth )
local valXP = getXP(clientNum)
   if valXP >=  lvl1xp and valXP < lvl2xp then	
	  setlevel(clientNum,1,lvl1xp)
   elseif valXP >=  lvl2xp and valXP < lvl3xp then	
	  setlevel(clientNum,2,lvl2xp)
   elseif valXP >=  lvl3xp and valXP < lvl4xp then	
	  setlevel(clientNum,3,lvl3xp)
   elseif valXP >=  lvl4xp and valXP < lvl5xp then	
	  setlevel(clientNum,4,lvl4xp)
   elseif valXP >=  lvl5xp then  
	  setlevel(clientNum,5,lvl5xp)
   end
end


#4
OFFLINE   Chuckun

Chuckun

    Regular Member

  • Members
  • PipPipPip
  • 130 posts
20
On a distinguished road
Sweet LUA man :) Very cool for keeping your regulars 'awarded' :)

#5
OFFLINE   Dookie

Dookie

    Advanced Member

  • Members
  • PipPipPipPip
  • 420 posts
55
Getting Better
  • LocationCroatia
yea, great feature!

#6
OFFLINE   Dookie

Dookie

    Advanced Member

  • Members
  • PipPipPipPip
  • 420 posts
55
Getting Better
  • LocationCroatia
hey, ive got this all except 1 thing, what do I have to put in my server.cfg after ive put autopromotion.lua in my silent folder?

Ive been reading about this lua_allowed_modules but haeavent found sum example or something? So lil help will be appreciated! :D

#7
OFFLINE   gaoesa

gaoesa

    Advanced Member

  • Management
  • PipPipPipPip
  • 4391 posts
341
Will become famous
  • LocationFinland
Only use lua_modules cvar. Don't put anything in lua_allowedModules.

set lua_modules "autopromotion.lua"


#8
OFFLINE   Hitman

Hitman

    Member

  • Members
  • PipPip
  • 35 posts
11
A step in the right direction

can u tell me how can i make like this

If people get X number of xps and if that player is X level then only he gets promotion or not



#9
OFFLINE   TheSilencerPL

TheSilencerPL

    Advanced Member

  • Management
  • PipPipPipPip
  • 3098 posts
216
On the road to fame
  • LocationPoland

It's in the lua file you need to download and install on the server. To specify your own XP levels you have to edit that file.

Click here to download the file. Then install it on the server, suit your needs by editing it and it's done.



#10
OFFLINE   Hitman

Hitman

    Member

  • Members
  • PipPip
  • 35 posts
11
A step in the right direction

can u tell me how can i make like this

If people get X number of xps and if that player is X level then only he gets promotion or not

it is just X Number of xps if someone gains they will get promotion but i want like

if X number of xps gained and if the player is "X" level then only he will get promotion not just xps



#11
OFFLINE   TheSilencerPL

TheSilencerPL

    Advanced Member

  • Management
  • PipPipPipPip
  • 3098 posts
216
On the road to fame
  • LocationPoland

Something I've written ad-hoc to handle your case:

LVL1 = 3
LVL2 = 4
LVL3 = 5
LVL4 = 6

function et_ClientSpawn(clientNum, revived, teamChange, restoreHealth)
local valXP = getXP(clientNum)
local level = et.G_shrubbot_level( clientNum );


if level == LVL1 then
  if valXP >= lvl2xp and valXP < lvl3xp then
    setlevel(clientNum,2,lvl2xp)
  end
elseif level == LVL2 then
  if valXP >= lvl3xp and valXP < lvl4xp then
    setlevel(clientNum,3,lvl3xp)
  end
elseif level == LVL3 then
  if valXP >= lvl4xp and valXP < lvl5xp then
    setlevel(clientNum,4,lvl4xp)
  end
end
end

LVL1 .. LVL4 are levels you want to handle, only for those levels xp check will be done.

The code inside

if level == LVL1 then

is up to you, here is the behavior I would want, which is: check if the xp is of the higher level and if it is, give the higher level.

 

Not tested.



#12
OFFLINE   Hitman

Hitman

    Member

  • Members
  • PipPip
  • 35 posts
11
A step in the right direction

sorry but iam Really "Newbie" in lua things so i should write this lua like this? this is my lua so where i should write this code in this file?

----------------------------------------------------------------------
-- AutoPromo - An Enemy Territory Auto Promoting Mod
----------------------------------------------------------------------
description = "AutoPromo"
version =    "1.1"
----------------------------------------------------------------------
-- This script can be freely used and modified as long as the original
-- authors are mentioned.
-- Created by Perlo_0ung, edited by Dragon
-- Adapted for silEnT mod 0.5.0 and higher
----------------------------------------------------------------------
-- CONFIGURATION
----------------------------------------------------------------------

lvl1xp = 1111  -- XP needed for level 1
lvl2xp = 2999 -- XP needed for level 2
lvl3xp = 4599 -- XP needed for level 3
lvl4xp = 100000 -- XP needed for level 4

----------------------------------------------------------------------
-- DO NOT EDIT BELOW THIS LINE
-- UNLESS YOU KNOW WHAT YOU'RE DOING
----------------------------------------------------------------------

function et_InitGame(levelTime,randomSeed,restart)
    local modname = string.format("%s v%s", description, version)
    et.G_Print(string.format("%s loaded\n", modname))
    et.RegisterModname(modname)
end

-- TheSilencerPL - To make it better, faster and less aggravating
-- for the game, store the XP locally and reuse it
function et_ClientSpawn(clientNum, revived, teamChange, restoreHealth)
    local valXP = getXP(clientNum)
   if valXP >=  lvl1xp and valXP < lvl2xp then    
      setlevel(clientNum,1,lvl1xp)
   elseif valXP >=  lvl2xp and valXP < lvl3xp then    
      setlevel(clientNum,2,lvl2xp)
   elseif valXP >=  lvl3xp and valXP < lvl4xp then    
      setlevel(clientNum,3,lvl3xp)
   elseif valXP >=  lvl4xp then    
      setlevel(clientNum,4,lvl4xp)
   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,"bp \"^nCongratulations ^7"..name.."^n, ^nyou have ^nbeen ^npromoted ^nto ^na ^nlevel ^7"..newlevel.." ^nuser!\"")
      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, "sil_guid" )
   if guid == "NO_GUID" or guid == "unknown" then 
      return true
   end
end

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






Also tagged with one or more of these keywords: lua, autopromotion, autopromo

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users