Forum

> > CS2D > General > Small scripts needed.
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Small scripts needed.

23 replies
Page
To the start Previous 1 2 Next To the start

old Small scripts needed.

RedPillow
User Off Offline

Quote
So, if someone has time, i need some small scripts.

1.

A script which teles me to certain location when i write /stele to chatbar, at this time to coords (50,50).

2.

A script which includes kick,ipban & give commands.

> When i write /kick (id) to chat bar it kicks the player.
> When i write /ban (id) to chat bar it bans the player.
> When i write /givec (amount) (id) to chat bar it gives certain amount of money to selected player.

3.

A script which give me and ID of player when i type /getid (playername) to chatbat.

4.

Some kind of private-messaging-script like /pm (id) (what you want to say).

Thats all, i hope i get some scripts, remember.. only I may use these, so add that usgn-id-restriction to every script BUT getid and pm can be used by every player.

Thanks!

old Re: Small scripts needed.

ohaz
User Off Offline

Quote
Jonzku777 has written
A script which includes kick,ipban & give commands.

> When i write /kick (id) to chat bar it kicks the player.
> When i write /ban (id) to chat bar it bans the player.

1
2
3
4
5
6
7
8
9
10
11
addhook("say","jonzku_say")
function jonzku_say(id,t)
	if(string.sub(t,1,5) == "/kick") then
		kickedplayer = 	string.sub(t,7,string.len(t))
		parse("kick "..kickedplayer)
	end
	if(string.sub(t,1,4) == "/ban")then
		bannedplayer=string.sub(t,6,string.len(t))
		parse("ban "..bannedplayer)
	end
end
Attention, you need to put ID's after that, and everyone can kick with that. if you want it to be restricted to some USGN ID's only, you need to add something

old Re: Small scripts needed.

Lee
Moderator Off Offline

Quote
1. I've already given you the script in the other thread. Use
1
2
3
4
5
6
7
8
9
function adm_teletile_admin(p, typ, cmd) 
     cmd = split(cmd) 
     local i = cmd[1] 
     local x = cmd[2] 
     local y = cmd[3] 
     if not y then return end 
     if not player(i, "exists") then return end 
     parse(string.format("setpos %s %s %s", i, x*32+16, y*32+16)) 
end
as a guide, where toTable() is a space split function and returns a table at the lua scipting thread

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function split(t, b) 
     return toTable(t, b) 
end 

function toTable(t, b) 
     local cmd = {} 
     local match = "[^%s]+" 
     if b then 
          match = "%w+" 
     end 
     if type(b) == "string" then match = "[^"..b.."]+" end 
     if not t then return cmd end 
     for word in string.gmatch(t, match) do 
          table.insert(cmd, word) 
     end 
     return cmd 
end 

function trim(t) 
     t = split(t) 
     s = "" 
     if not t then return end 
     for i, v in ipairs(t) do 
          s = s.." "..v 
     end 
     s = string.sub(s, 2) 
     return s 
end

Use http://code.assembla.com/mod2d/subversion/nodes/core/basic.lua as a reference . Number 4 is in that script as well.

3.
no hooks, function only.
1
2
3
4
5
6
7
8
9
10
11
function adm_getid_admin(p, cmd)
	cmd = trim(cmd)
	local names = {}
	for i =1, 32, 1 do
		if player(i, "exists") then
			names[player(i, "name")] = i
		end
	end
	if names[cmd] then msg2(p, "Player "..cmd.." is at ID: "..names[cmd]) end
	return 2
end

And you do your own thing to add the hooks onto some say command and check to see if the first parameter is /getip and call adm_getid_admin with the same parameters

old Re: Small scripts needed.

Zune5
COMMUNITY BANNED Off Offline

Quote
btw lee, in your amx2d mod, do I have to add all the dofiles for ALL of your .lua files?

old Re: Small scripts needed.

RedPillow
User Off Offline

Quote
Hey, whats the idea with this setpos-command?

Its messed up or something, when i type Setpost 1 15 15 it just teles me to square x 1 y 1.

I though that it is supposed to tele me 15x and 15y squares, but it teles inches, pixels or something o.O whats wrong?

old Re: Small scripts needed.

RedPillow
User Off Offline

Quote
but why in earth its not 15 squares? why it must be inches or something can someone make script to override this old setpos to make it squareS?

old Re: Small scripts needed.

Zune5
COMMUNITY BANNED Off Offline

Quote
Jonzku777 has written
Hey, whats the idea with this setpos-command?

Its messed up or something, when i type Setpost 1 15 15 it just teles me to square x 1 y 1.

I though that it is supposed to tele me 15x and 15y squares, but it teles inches, pixels or something o.O whats wrong?


It's in pixels. Multiply your 2 tile "Numbers" by 32 then add 16 if you want it to be centered in the middle instead of at the end.
The formula

x*32+16
y*32+16

old Re: Small scripts needed.

RedPillow
User Off Offline

Quote
but can someone make me script s i can only write /tele 10 10 for example and it automatically adds 32+16 to my coords i write?

Leegaos command is weird, i dont even know what to write to tele somewhere o.O

old Re: Small scripts needed.

Lee
Moderator Off Offline

Quote
Jonzku777 has written
Leegaos command is weird, i dont even know what to write to tele somewhere o.O


Your loss, it's up to you to do the preconditioning, if you're going to be making a script, don't rely on others to do all of it for you.

old Re: Small scripts needed.

RedPillow
User Off Offline

Quote
Leegao, can you PLEASE tell me a little about this mod/script you have made

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Initialize
init_mod("sv")

sv.var("prefix","Server echoed: ", "svar")
sv.broadcasttime = initArray(32)
--Act - Command "!echo"

function act_nextmap(p, typ, cmd)
	msg(string.format("nextmap: %s", game("nextmap")))
end

function act_broadcast(p, typ, cmd)
	if os.time() > sv.broadcasttime[p] then
		msg(Color(100, 255, 0), string.format("%s(BROADCAST): %s", player(p, "name"), cmd))
		msg2(p, Color(255, 100, 0),"You have a 60 second cool off period before the next broadcast")
		sv.broadcasttime[p] = os.time() + 60
	else
		msg2(p, Color(255, 100, 0), string.format("You may not make another broadcast for %s more seconds", sv.broadcasttime[p] - os.time()))
	end
end

function adm_echo_admin(p, typ, cmd)
	msg(Color(255, 0, 0), sv.prefix..cmd)
end

function adm_say_admin(p, typ, cmd)
	msg("?032178170"..player(p, "name") .. "(ADMIN): "..cmd)
end

function adm_sayto_admin(p, typ, cmd)
	cmd = toTable(cmd)
	local i = tonumber(cmd[1])
	local _msg = cmd[2]
	if not player(i, "exists") then return invalid(p, typ) end
	if not msg then return invalid() end
	msg2(i, Color(255, 100, 0), string.format("%s (PRIVATE): %s", player(i, "name"), _msg))
end

--Admin - Command "@echo_prefix"

function adm_echoprefix_admin(p, typ, cmd)
	sv.setvar("prefix", cmd, true)
end

function adm_guns_admin(p, typ, cmd)
	cmd = toTable(cmd)
	local ID = tonumber(cmd[1])
	local gunid = trim(tostring(cmd[2]))
	if tonumber(cmd[2]) then gunid = wpn.name[tonumber(cmd[2])] end
	if not gunid then return invalid(p, typ) end
	if not ID then
		ID = p
		gunid = trim(tostring(cmd[1]))
	end
	if not wpn.id[gunid] then return invalid(p, typ, "Wrong Weapon") end
	equip(ID, wpn.id[gunid], true)
end

function adm_teleport_admin(p, typ, cmd)
	cmd = toTable(cmd)
	local i = cmd[1]
	local x = cmd[2]
	local y = cmd[3]
	if not y then return invalid(p, typ) end
	if not player(i, "exists") then return invalid(p, typ, "Invalid Player") end
	parse(string.format("setpos %s %s %s", i, x, y))
end

function adm_teletile_admin(p, typ, cmd)
	cmd = toTable(cmd)
	local i = cmd[1]
	local x = cmd[2]
	local y = cmd[3]
	if not y then return invalid(p, typ) end
	if not player(i, "exists") then return invalid(p, typ, "Invalid Player") end
	parse(string.format("setpos %s %s %s", i, x*32, y*32))
end

function adm_getpos_admin(p, typ, cmd)
	local i = tonumber(cmd)
	if not i then i = p end
	if not player(i, "exists") then return invalid(p, typ) end
	msg2(p, Color(255, 100, 0), string.format("%s is located at (%s, %s)", player(i, "name"), math.ceil(player(i, "x")), math.ceil(player(i, "y"))))
end

function adm_gettile_admin(p, typ, cmd)
	local i = tonumber(cmd)
	if not i then i = p end
	if not player(i, "exists") then return invalid(p, typ) end
	msg2(p, Color(255, 100, 0), string.format("%s is located at (%s, %s)", player(i, "name"), player(i, "tilex"), player(i, "tiley")))
end

function adm_getid_admin(p, cmd)
     cmd = trim(cmd)
     local names = {}
     for i =1, 32, 1 do
          if player(i, "exists") then
               names[player(i, "name")] = i
          end
     end
     if names[cmd] then msg2(p, "Player "..cmd.." is at ID: "..names[cmd]) end
     return 2
end

I seee there is lots of commands and things, but how do i made them to work?
The script is running but i dont know the commands to any of those i have tried to type in chatbar /broadcast
/getid (name)
an other commands, i have tried same without / to console... so whats wrong and how to make this work?

old Re: Small scripts needed.

Lee
Moderator Off Offline

Quote
This is bootstrapped to AMX2D which regresses through the loaded variables in the runtime and picks out specific functions for specific acts (ie: act_ prefix denotes normal commands, adm_ denotes admin commands, hook_ denotes hooks, and menu_ denotes menus). It will only work once you load up AMX2D.

To get the normal commands working just look at the LOGIC of the code, not the actual function names

for example, for act_nextmap, you would use

1
2
3
4
5
6
addhook("say", "act_nextmap")
function act_nextmap(p, t)
	if split(t)[1] == "!nextmap" then
		msg(string.format("nextmap: %s", game("nextmap")))
	end
end

and so on for each of those commands. Remember to look in the Lua Script thread in my 2nd post for the split, trim, Color, msg, and msg2 functions. Also, disregard the "typ" arguments into the act and adm methods since they're more of a novelty than useful (it's good for automatic error reports)

old Re: Small scripts needed.

RedPillow
User Off Offline

Quote
But for example this "adm_sayto_admin"

I suppose that it sends a message or something?

So i must write to chatbar /sayto_admin ??

old Re: Small scripts needed.

Tehmasta
User Off Offline

Quote
@jonzku, no that script requires amx2d to run, none of the commands work because you haven't even created any

old Re: Small scripts needed.

RedPillow
User Off Offline

Quote
uhm, amx2d? never heard about...

TELLMEWHATISIT?! it sounds COOL


Edit: i found it but, what do i do with this?! this jsut has lots of folders and files o.O how to use or do something?!

Edit2: Oh, and may someone give me a simple example of how to make command which gives certain player a certain weapon/weaponpack when i write this to chatbar "/Giveall (id)"

And it should give to that player:
•Laser
•Rocket Launcher
•Desert Eagle
•superarmor
•he
•gas grenade


AND one more thing, this should make a clock to see in every players hud, but it doesnt? why and solution please

Clock-script:

1
2
3
4
5
6
7
local timehud = 'hudtxt %s "%sTime: %s" 130 100 1'
local _time = 0
addhook("second", "changeTime")
function changeTime()
     parse(string.format(timehud, 1, "©255100000", _time))
     _time = _time + 1
end

Thanks.
edited 2×, last 09.04.09 07:55:55 pm

old Re: Small scripts needed.

Lee
Moderator Off Offline

Quote
Quote
----------------------------------------------------------------------------------------------
-- * AMX2D -*=*- README * --
----------------------------------------------------------------------------------------------
This is a usage introduction on AMX2D and how to install it onto
your server.

1) Installation:

- Extract the contents of amx2d.zip to a local directory.
- Copy the folder amx2d to your CS2D/sys/lua/ directory.
- Open CS2D/sys/lua/server.lua:
## Type in
dofile("sys/lua/amx2d/main.lua")
main("sys/lua/amx2d")

2) Usage and Configuration:

- Open Folder CS2D/sys/lua/amx2d/settings/

- Open mods.cfg
Add the name of the mod you want to have loaded into t-
he end of this file.The mods can be found in CS2D/sys/l-
ua/amx2d/mods/

The default mods included with this release includes:
[FUNCTIONAL]
* mod_ads_prim
* mod_authset
* mod_clanwar
* mod_gg
* mod_help
* mod_menupage **
* mod_menutest **
* mod_nadegame
* mod_parse **
* mod_quakeMod
* mod_sampleads[DC] **
* mod_sampleconsole[DC] **
* mod_statsme **
* mod_TF2D **
- ** means that these mods are either examples or are s-
till under development.

[OBSOLETES]
* cron[obsolete]
* mod_auth[obsolete]
* mod_echo[obsolete]
* mod_parse[obsolete]
* mod_wpn[obsolete]
* mod_wpnid[obsolete]

- AMX2D can reload different sets of mods. The default mods con-
fig file is located at CS2D/sys/lua/amx2d/settings/mod.cfg. You
may create more config files for different mod sets. For example:
[CS2D/sys/lua/amx2d/settings/gg.cfg]
mod_gg
mod_help
mod_authset
mod_ads_prim
mod_quakeMod
mod_clanwar
Either in mod.cfg, change the content to gg, or in game, login
using a superadmin account (See below) and type in:
[CHAT CODE] @amx2d gg [/CODE]
This allows the user to be able to reload the AMX2D system and
to be able to change mods without having to shut down the server
**NOTE^^: The change code will take 5 seconds to complete.

- Command Prefixes can be set in cmds.cfg.
[CS2D/sys/lua/amx2d/settings/cmds.cfg]
@ true
! false
? false help
#fu true echo F*** YOU
Where each line uses the following pattern
Symbol isAdmin parseCommand
Thus, if I were to type in
[CHAT CODE] ?gg [/CODE] Note: Add a space at the end
The output would be
[OUTPUT]
All commands with prefix 'gg':
!gg_initialpayment, !gg_level, !gg_maxlvl,
!gg_avgtimealive, !gg_specweapons, !gg_alllevels,
!gg_avgtimeperkill, !gg_timeplayed, !gg_avglvl,
!gg_killmoney, !gg_kills, !gg_totaldeaths, !gg_bonus,
!gg_moneyratio, !gg_totalkills, !gg_minlvl, *gg_collect,
*gg_resetkills, *gg_random, *gg_mratio, *gg_joinlevel,
*gg_buy, *gg_resettimer, *gg_resetdeaths, *gg_reverse,
*gg_killmoney, *gg_reset, *gg_setlevel, *gg_specweapons
[/OUTPUT]

http://amx2d.co.cc/viewtopic.php?f=17&t=61

old Re: Small scripts needed.

RedPillow
User Off Offline

Quote
This doesn`t overwrite that scripts i currently have?


Edit2: AND do i have to move my previous luas to this amx2d-place?

edit4: Where can i find commands for this amdx2 things?
edited 2×, last 09.04.09 09:14:13 pm
To the start Previous 1 2 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview