lua load/unload

Discussions about ET modding (sdk code, player/weapon modeling)

Moderators: Forum moderators, developers

crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

lua load/unload

Post by crazyfrag »

i use the lugeronly lua which i want to load /unload by vote!

yes the easiest way to to do this is to load a config but
isnt it possible to let the lua see a vote /activate see the vote again /deactivate?
User avatar
Deus
Posts: 1053
Joined: Fri Mar 12, 2004 2:24 am
Location: Germany
Contact:

Post by Deus »

you have to modify the lua file for inventing a new cvar to enable/disable lugeronly, not just unload the lua. Then you can change the cvar by vote
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

but how i intercept the other things in the lua to get executed?
can someone help me with this?
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

i use this one

Code: Select all

Version = 	1.2
Author  =   "im2good4u"
Description = "Disable Weapons\n"
--[[---------------------------------------------------[[--
 Changelog:
 	
    1.1:
		Made Configable
 
    1.0:
        Konwn bugs u still get a knife
        initial release
--]]---------------------------------------------------]]--
 
--global vars
et.MAX_WEAPONS = 50
samplerate = 200
--

--note sme got no comment thats becase it arent weapons
weapons = {
	nil,	--// 1
	true,	--WP_LUGER,				// 2
	false,	--WP_MP40,				// 3
	false,	--WP_GRENADE_LAUNCHER,	// 4
	false,	--WP_PANZERFAUST,		// 5
	false,	--WP_FLAMETHROWER,		// 6
	true,	--WP_COLT,				// 7	// equivalent american weapon to german luger
	false,	--WP_THOMPSON,			// 8	// equivalent american weapon to german mp40
	false,	--WP_GRENADE_PINEAPPLE,	// 9
	false,	--WP_STEN,				// 10	// silenced sten sub-machinegun
	false,	--WP_MEDIC_SYRINGE,		// 11	// JPW NERVE -- broken out from CLASS_SPECIAL per Id request
	true,	--WP_AMMO,				// 12	// JPW NERVE likewise
	true,	--WP_ARTY,				// 13
	false,	--WP_SILENCER,			// 14	// used to be sp5
	true,	--WP_DYNAMITE,			// 15
	nil,	--// 16
	nil,	--// 17
	nil,		--// 18
	false,	--WP_MEDKIT,			// 19
	true,	--WP_BINOCULARS,		// 20
	nil,	--// 21
	nil,	--// 22
	false,	--WP_KAR98,				// 23	// WolfXP weapons
	false,	--WP_CARBINE,			// 24
	false,	--WP_GARAND,			// 25
	false,	--WP_LANDMINE,			// 26
	false,	--WP_SATCHEL,			// 27
	false,	--WP_SATCHEL_DET,		// 28
	nil,	--// 29
	false,	--WP_SMOKE_BOMB,		// 30
	false,	--WP_MOBILE_MG42,		// 31
	false,	--WP_K43,				// 32
	false,	--WP_FG42,				// 33
	nil,	--// 34
	false,	--WP_MORTAR,			// 35
	nil,	--// 36
	false,	--WP_AKIMBO_COLT,		// 37
	false,	--WP_AKIMBO_LUGER,		// 38
	nil,	--// 39
	nil,	--// 40
	false,	--WP_SILENCED_COLT,		// 41
	false,	--WP_GARAND_SCOPE,		// 42
	false,	--WP_K43_SCOPE,			// 43
	false,	--WP_FG42SCOPE,			// 44
	false,	--WP_MORTAR_SET,		// 45
	false,	--WP_MEDIC_ADRENALINE,	// 46
	false,	--WP_AKIMBO_SILENCEDCOLT,// 47
	false	--WP_AKIMBO_SILENCEDLUGER,// 48
}

function et_InitGame(levelTime,randomSeed,restart)
	maxclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) )	--gets the maxclients
	et.G_Print("[NOWEAPON] Version:".. Version .." Loaded\n")
	et.RegisterModname("NoWeapon:".. Version .."slot:".. et.FindSelf())
end

function et_ClientSpawn(clientNum,revived)
	for i=1,(et.MAX_WEAPONS-1),1 do
	    if not weapons[i] then
			et.gentity_set(clientNum,"ps.ammoclip",i,0)
			et.gentity_set(clientNum,"ps.ammo",i,0)
		end
	end
end

-- called every server frame
function et_RunFrame( levelTime )
 	
	if math.mod(levelTime, samplerate) ~= 0 then return end
	-- for all clients
	for j = 0, (maxclients - 1) do
		for k=1, (et.MAX_WEAPONS - 1), 1 do
	    	if not weapons[k] then
				et.gentity_set(j, "ps.ammoclip", k, 0)
				et.gentity_set(j, "ps.ammo", k, 0)
				et.gentity_set(j, "ps.ammo", 7, 150)
				et.gentity_set(j, "ps.ammo", 2, 150)
			end
		end		
	end
		
end

User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post by Luk4ward »

Deus wrote:Then you can change the cvar by vote
u can change by vote only the cvars from the commands which are listed to vote like timelimit etc.
wolFTeam.pl
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

sure!

but u can create an ugly vote with

vote map with luger
and the lua checkes 4 the cmd XD

or u create a vote callvote config lugerwar
-> voted passes , but gets aborted and the cvar changes

but i dont know how to code such thing so i question here !
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post by Luk4ward »

crazyfrag wrote:sure!

but u can create an ugly vote with

vote map with luger
and the lua checkes 4 the cmd XD

or u create a vote callvote config lugerwar
-> voted passes , but gets aborted and the cvar changes

but i dont know how to code such thing so i question here !
i posted the code here:

http://bani.anime.net/banimod/forums/vi ... php?t=6890
wolFTeam.pl
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

yeah i know thats not the probleme!

the problem is how to activate and deavtivate the luger thing
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

so i need a lua which detectes that a vote has passed and then changes a cvar 1/0

and another wich sees

cvar 1 = luggermode activates
cvar 0 = lugermode deactivates

is this possible ?
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

anyone who could help me with this?
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post by gotenks »

i successfully did this once (couple years ago)... will see what i can do again
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

u got anything?
User avatar
=FF=im2good4u
Posts: 3821
Joined: Wed Feb 05, 2003 7:30 am
Location: The Netherlands, HOLLAND
Contact:

Post by =FF=im2good4u »

hmm detecting votes in lua lol iv tryed that before wasnt verry easy
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post by gotenks »

sry, been very busy (I'm training to be a shift tech in a medical lab... and I'm studying to be a computer engineer, and i'm a father of 3 soccer kids, and i'm a cub scout leader, and i'm trying to change my MOS
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

did anyone manage this ?
Post Reply