Jump to content

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

AutoPromo Lua

- - - - -

  • Please log in to reply
4 replies to this topic

#1
OFFLINE   makavelii

makavelii

    Member

  • Members
  • PipPip
  • 49 posts
35
Getting Better

Hey,

I have question about the autopromo lua.
My level system on the server is 15,20,25.. <- levels for regular players and my friend edited for me the lua as I wasn't sure what to do..
Is this right?
 

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

lvl15xp = 1000  -- XP needed for level 1
lvl20xp = 5000 -- XP needed for level 2
lvl25xp = 25000 -- XP needed for level 3

----------------------------------------------------------------------
-- 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 >=  lvl15xp and valXP < lvl20xp then    
      setlevel(clientNum,1,lvl15xp)
   elseif valXP >=  lvl20xp and valXP < lvl25xp then    
      setlevel(clientNum,2,lvl20xp)
   elseif valXP >=  lvl25xp then   
      setlevel(clientNum,5,lvl25xp)
   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

Best regards.



#2
OFFLINE   Dragonji

Dragonji

    Advanced Member

  • Members
  • PipPipPipPip
  • 514 posts
142
On the road to fame
  • LocationPoland
---------------------------------------------------------------------
-- 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
----------------------------------------------------------------------

lvl15xp = 1000  -- XP needed for level 1
lvl20xp = 5000 -- XP needed for level 2
lvl25xp = 25000 -- XP needed for level 3

----------------------------------------------------------------------
-- 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 >=  lvl15xp and valXP < lvl20xp then    
      setlevel(clientNum,15,lvl15xp)
   elseif valXP >=  lvl20xp and valXP < lvl25xp then    
      setlevel(clientNum,20,lvl20xp)
   elseif valXP >=  lvl25xp then   
      setlevel(clientNum,25,lvl25xp)
   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
Just replaced this:
   if valXP >=  lvl15xp and valXP < lvl20xp then    
      setlevel(clientNum,1,lvl15xp)
   elseif valXP >=  lvl20xp and valXP < lvl25xp then    
      setlevel(clientNum,2,lvl20xp)
   elseif valXP >=  lvl25xp then   
      setlevel(clientNum,5,lvl25xp)
   end
With this:
   if valXP >=  lvl15xp and valXP < lvl20xp then    
      setlevel(clientNum,15,lvl15xp)
   elseif valXP >=  lvl20xp and valXP < lvl25xp then    
      setlevel(clientNum,20,lvl20xp)
   elseif valXP >=  lvl25xp then   
      setlevel(clientNum,25,lvl25xp)
   end


#3
OFFLINE   makavelii

makavelii

    Member

  • Members
  • PipPip
  • 49 posts
35
Getting Better

This will work?



#4
OFFLINE   TheSilencerPL

TheSilencerPL

    Advanced Member

  • Management
  • PipPipPipPip
  • 3096 posts
215
On the road to fame
  • LocationPoland
My level system on the server is 15,20,25.. <- levels for regular players and my friend edited for me the lua as I wasn't sure what to do..

 

Do you have more levels in between? I mean, do you also have levels like: 16,17,...,23,24, etc? If you have only the ones you mentioned it should work properly.

 

EDIT1:

Just FYI, here is the xp for each level set:

 

lvl15xp = 1000 -- XP needed for level 15
lvl20xp = 5000 -- XP needed for level 20
lvl25xp = 25000 -- XP needed for level 25

 

In the posted snippet it has only wrong comments.

 

And here the levels are set based on the xp values:

if valXP >=  lvl15xp and valXP < lvl20xp then    
      setlevel(clientNum,15,lvl15xp)
   elseif valXP >=  lvl20xp and valXP < lvl25xp then    
      setlevel(clientNum,20,lvl20xp)
   elseif valXP >=  lvl25xp then   
      setlevel(clientNum,25,lvl25xp)
   end

The values are compared to the new xp definitions.



#5
OFFLINE   makavelii

makavelii

    Member

  • Members
  • PipPip
  • 49 posts
35
Getting Better

Nope I don't :)






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users