Forum

> > CS2D > Scripts > Bot voting & setpos
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Bot voting & setpos

16 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Bot voting & setpos

Powermonger
User Off Offline

Zitieren
Hello again all scripters,


I tried many times but couldn't get it work:

When player votes a bot, he gets warning.
Elseif he votes a player, normal vote.

1
2
3
4
5
6
addhook("vote","botvote")
function botvote(param)
    if player(param,"bot")==true then
        msg("WARNING: DO NOT VOTE BOTS!")
    end
end

I think you'll get the point. It's very simple, but I don't know how to get it work, maybe you could help me with it?


The other problem is:

I have a menu, where I can teleport/setpos player 1 tile (32pix) to up, down, left or right.
It works fine.

Example, teleporting 1 tile down:
1
2
3
4
5
6
if button==2 then
    id = driver1
    pox = player(id,"x")
    poy = player(id,"y")
    parse("setpos "..id.." "..pox.." "..poy+32)
end

BUT, player can get stuck into a wall, so I need to make "walltiles" unteleportable.
Simply, a player can't teleport into a wall.

Is it possible to make it?


Thanks for help in forehand

mOnger

alt Re: Bot voting & setpos

Yates
Reviewer Off Offline

Zitieren
1
2
3
4
5
6
addhook("vote","botvote")
function botvote(id,mode,param)
    if player(param,"bot")==true then
        msg2(id,"WARNING: DO NOT VOTE BOTS!")
    end
end
Fixed.

alt Re: Bot voting & setpos

Powermonger
User Off Offline

Zitieren
user Yates hat geschrieben
1
2
3
4
5
6
addhook("vote","botvote")
function botvote(id,mode,param)
    if player(param,"bot")==true then
        msg2(id,"WARNING: DO NOT VOTE BOTS!")
    end
end
Fixed.

Already tried this one, with no effect : /
I tried to vote player & bot -> no message.

alt Re: Bot voting & setpos

Suprise
BANNED Off Offline

Zitieren
1
2
3
4
5
6
addhook("vote","botvote")
function botvote(id,param)
	if player(id,"bot") then
		msg("WARNING: DO NOT VOTE BOTS!")
	end
end

alt Re: Bot voting & setpos

Yates
Reviewer Off Offline

Zitieren
1
2
3
4
addhook("vote","botvote")
function botvote(id,mode,param)
	msg2(id,"WARNING: DO NOT VOTE BOTS!")
end
Let's see if the function actually works.

alt Re: Bot voting & setpos

Powermonger
User Off Offline

Zitieren
It works like it should (on every vote).
Does it matter in what order the parameters are?
If (id,mode,param) wouldn't work, maybe another order?

alt Re: Bot voting & setpos

Yates
Reviewer Off Offline

Zitieren
It should work, messing with the orders will not.

Wait until someone who has experience with the vote hook comes.

alt Re: Bot voting & setpos

EngiN33R
Moderator Off Offline

Zitieren
Are you two mad? The order of arguments in Lua is crucial, the naming, on the other hand, is completely not. You can name them 'one', 'banana' and 'lul' and they would still work if they are in the right order.

Try this:
1
2
3
4
5
6
addhook("vote","botvote")
function botvote(id,mode,param)
    if player(param,"bot")==true then
        msg("WARNING: DO NOT VOTE BOTS!")
    end
end

EDIT: No, never mind, you just said it doesn't work.

alt Re: Bot voting & setpos

Powermonger
User Off Offline

Zitieren
Zitat
The order of arguments in Lua is crucial, the naming, on the other hand, is completely not.

True, but I can't figure out anything else that causes the error, so I made a suggestion.

More suggestions to solve the function are welcome.

alt Re: Bot voting & setpos

omg
User Off Offline

Zitieren
1
2
3
4
5
6
addhook("vote","botvote")
function botvote(id,mode,param)
    if mode==1 and player(tonumber(param),"bot") then
        msg2(id,"WARNING: DO NOT VOTE BOTS!@C")
    end
end
pretty sure this is what ur looking for...frankly, i dont know why it wasnt obvious

and
1
2
3
4
5
6
7
8
if button==2 then
    local id = driver1
    local pox = player(id,"x")
    local poy = player(id,"y")+32
    if tile(math.floor(pox/32),math.floor(poy/32),"walkable") then
        parse("setpos "..id.." "..pox.." "..poy)
    end
end
it kind of drives me crazy when ppl ignore scope and dont make variables local when they need to be. seriously, how much faster could u possibly make it run? its just sloppy
1× editiert, zuletzt 23.08.12 01:37:25

alt Re: Bot voting & setpos

TheBosS_
User Off Offline

Zitieren
user omg hat geschrieben
1
2
3
4
5
6
addhook("vote","botvote")
function botvote(id,mode,param)
    if mode==1 and player(tonumber(param),"bot") then
        msg2(id,"WARNING: DO NOT VOTE BOTS!@C")
    end
end
pretty sure this is what ur looking for...frankly, i dont know why it wasnt obvious

and
1
2
3
4
5
6
7
8
if button==2 then
    local id = driver1
    local pox = player(id,"x")
    local poy = player(id,"y")+32
    if tile(math.floor(pox/32),math.floor(poy/32),"walkable") then
        parse("setpos "..id.." "..pox.." "..poy)
    end
end
it kind of drives me crazy when ppl ignore scope and dont make variables local when they need to be. seriously, how much faster could u possibly make it run? its just sloppy


the botvote wont work . . there will be error

alt Re: Bot voting & setpos

Powermonger
User Off Offline

Zitieren
user omg hat geschrieben
1
2
3
4
5
6
addhook("vote","botvote")
function botvote(id,mode,param)
    if mode==1 and player(tonumber(param),"bot") then
        msg2(id,"WARNING: DO NOT VOTE BOTS!@C")
    end
end
pretty sure this is what ur loerverf4.lua:520: bad argument #1 to 'player' (number expected, got nil)"
-> player id couldn't be read.oking for...frankly, i dont know why it wasnt obvious

Gives lua error "sys/lua/myserver/s

Maybe DC knows how it works.

user omg hat geschrieben
1
2
3
4
5
6
7
8
if button==2 then
    local id = driver1
    local pox = player(id,"x")
    local poy = player(id,"y")+32
    if tile(math.floor(pox/32),math.floor(poy/32),"walkable") then
        parse("setpos "..id.." "..pox.." "..poy)
    end
end


Work perfectly, thanks man

Btw, is there a way to check if there is a player in that tile?
I know that I could just check if certain IDs tile matches to local pox & local poy, but then I would have to do it for every ID.

You know any faster and easier way?
1× editiert, zuletzt 29.08.12 02:22:11

alt Re: Bot voting & setpos

EngiN33R
Moderator Off Offline

Zitieren
Uhh, to be honest, at the moment I don't see another way other than

1
player(id,"tilex")==tilex and player(id,"tiley")==tiley

alt Re: Bot voting & setpos

Powermonger
User Off Offline

Zitieren
user EngiN33R hat geschrieben
Uhh, to be honest, at the moment I don't see another way other than

1
player(id,"tilex")==tilex and player(id,"tiley")==tiley

I thought so too, maybe there will be another way in future.

Thanks for your reply
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht