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
5 replies to this topic

#1
OFFLINE   Dookie

Dookie

    Advanced Member

  • Members
  • PipPipPipPip
  • 420 posts
55
Getting Better
  • LocationCroatia

Hi, ive got this in .lua 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 = 1  -- XP needed for level 1
lvl2xp = 5 -- XP needed for level 2
lvl3xp = 15 -- 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 >=  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
 
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
 
 
Any this in my server.cfg:
 
// Lua API
set lua_modules "kspree.lua;autopromo.lua"
set lua_allowedModules ""
 
 
 
Anf ofc i uploaded lua file in my silent folder, but its still not working, when any of this XP's are reached nothing happends. Any ideas? thanks

 



#2
OFFLINE   Dragonji

Dragonji

    Advanced Member

  • Members
  • PipPipPipPip
  • 514 posts
142
On the road to fame
  • LocationPoland

Yes, one have to respawn before he receives promotion.



#3
OFFLINE   Dookie

Dookie

    Advanced Member

  • Members
  • PipPipPipPip
  • 420 posts
55
Getting Better
  • LocationCroatia

Hey thanks! Works, but only up to lvl 2,  when i reach over xp 15, and die, it doesnt promote me to lvl 3, it stays on 2. Any ideas?



#4
OFFLINE   tapir76

tapir76

    Member

  • Subscriber
  • PipPip
  • 31 posts
1
A step in the right direction
  • LocationPoland Krk

Hey thanks! Works, but only up to lvl 2,  when i reach over xp 15, and die, it doesnt promote me to lvl 3, it stays on 2. Any ideas?

 

 

 

does not promote at level 4. you do not have a defined lvl4 and lvl 5

 

lvl1xp = 1  -- XP needed for level 1
lvl2xp = 5 -- XP needed for level 2
lvl3xp = 15 -- XP needed for level 3
lvl4xp ="???"
lvl5xp =" ???"


#5
OFFLINE   Dragonji

Dragonji

    Advanced Member

  • Members
  • PipPipPipPip
  • 514 posts
142
On the road to fame
  • LocationPoland

Hey thanks! Works, but only up to lvl 2,  when i reach over xp 15, and die, it doesnt promote me to lvl 3, it stays on 2. Any ideas?

Change this part:
-- 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 and valXP < lvl5xp then    
      setlevel(clientNum,4,lvl4xp)
   elseif valXP >=  lvl5xp then   
      setlevel(clientNum,5,lvl5xp)
   end
end
With this:
-- 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 then
      setlevel(clientNum,3,lvl3xp)
   end
end


#6
OFFLINE   TheSilencerPL

TheSilencerPL

    Advanced Member

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

Best would be to create an array of levels and do the comparison in the loop or something. This way you could extend the number of levels without modifying the et_ClientSpawn function.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users