Forum

> > CS2D > Scripts > vote lua
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Deutsch vote lua

11 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt vote lua

haha1955
User Off Offline

Zitieren
suche einen lua script:
wo man f2 drückt und voten kann, und dazu noch einen report system, das wenn ein spieler scheiße baut und die leute ihn dann reporten so das ich das mitbekommen kann.

MfG.

alt Re: vote lua

Bowlinghead
User Off Offline

Zitieren
Wenn du schon jemanden bittest, ein Code zu erstellen dann mach ihn das Leben doch einfach mit genauen Informationen

Hier, ein Script "wo man f2 drückt und voten kann"
Spoiler >

Und wie sollen die Leute den Griefer reporten? Per Chat mit !report? Per F3 Menü?

alt Re: vote lua

haha1955
User Off Offline

Zitieren
@user Bowlinghead: ah endlich mal jemand der mich kapiert hat danke lieber Gott...

mit per chat ist es besser also !report

alt Re: vote lua

Cebra
User Off Offline

Zitieren
naja, mehr info wäre immernoch hilfreich, zB wie willst du informiert werden?

Spoiler >

alt Re: vote lua

haha1955
User Off Offline

Zitieren
@user Cebra: das wenn andere spieler jemanden reporten,
das der eintrag dann in eine text datei gespeichert wird

alt Re: vote lua

Cebra
User Off Offline

Zitieren
der code ist ungestestet

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
yourUsgn = 129720

function stringSplit(inputstr, sep)
	if sep == nil then
		sep = "%s"
	end
	local t={} ; i=1
	for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
		t[i] = str
		i = i + 1
	end
	return t
end

addhook("say","_say")
function _say(id,txt)
	newTxt = stringSplit(txt) -- newTxt ist ein Array, mit den einzelnen Komponenten, also z.B. = {"!pun","1"}
	if newTxt ~= null and #newTxt == 2 then
			if newTxt[1] == "!report" and player(newTxt[2],"exists") then -- wenn befehl gefunden 
				local file=io.open("sys/lua/report.txt","a+")
				file:write(os.time()..": "..player(newTxt[2],"name").." with USGN-ID "..player(newTxt[2],"usgn").."\n")
				file:close()
				return 1
			end
	end
end

edit: code korrigiert (logik fehler)
1× editiert, zuletzt 16.04.19 23:01:52

alt Re: vote lua

haha1955
User Off Offline

Zitieren
@user Cebra: Danke für die Codes, aber wie füge ich das jetzt ein? Also muss ich mir jetzt einen eigenen Text dokument erstellen und es als lua bearbeiten oder wie?

alt Re: vote lua

Cebra
User Off Offline

Zitieren
ja, füge den code in einen text editor deiner wahl ein und speichere die Datei dann als .lua im ordner (relativ zu deinem cs2d verzeichnis) /sys/lua/autorun

alt Re: vote lua

haha1955
User Off Offline

Zitieren
@user Cebra: so das problem ist, hab das so wie du gesagt hast gemacht aber ging ned. kann das sein das das mit meinem hc admin script was zu tun hat?

alt Re: vote lua

Cebra
User Off Offline

Zitieren
Ja, hab grad mal ein bisschen damit rumgetestet.
In Kombination mit dem HC Admin Script werden die autorun scripts zwar ausgeführt, aber die addhook-function tut's nicht ordnungsgemäß

anstatt es mit einem eigenen script zu versuchen, benutze das hier:

user Happy Camper hat geschrieben
Adding new say commands

Here is an example of how to add a new moderation command. Open sys/lua/hc/modules/moderation.lua in a text editor. Look for the function hc.moderation.init(). Add this line to that function (before end):
1
hc.add_say_command("kick", hc.moderation.kick_say_command, hc.MODERATOR1, "<id>", "Kick a player.")
This adds a new say command, !kick. Players that are moderator level 1 or higher will be able to use it. When a player triggers it, the function hc.moderation.kick_say_command will be invoked. Now add that function below the init function (after end):
1
2
3
function hc.moderation.kick_say_command(p, id)
     hc.exec(p, "kick " .. id)
end
hc.exec will parse the command and log it. Now you can test the command by saying (if you are authorized):

!kick 5


für deine anforderungen sähe das dann in etwa so aus:
1
hc.add_say_command("report", hc.moderation.report_say_command, hc.USER, "<id>", "Report a player")
und
1
2
3
4
5
function hc.moderation.report_say_command(p, id)
	local file=io.open("sys/lua/report.txt","a+")
	file:write(os.time()..": "..player(id,"name").." with USGN-ID "..player(id,"usgn").."\n")
	file:close()
end

(ungetesteter code)
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht