Forum

> > CS2D > Scripts > Bot voting & setpos
Forums overviewCS2D overview Scripts overviewLog in to reply

English Bot voting & setpos

16 replies
To the start Previous 1 Next To the start

old Bot voting & setpos

Powermonger
User Off Offline

Quote
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

old Re: Bot voting & setpos

Yates
Reviewer Off Offline

Quote
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.

old Re: Bot voting & setpos

Powermonger
User Off Offline

Quote
user Yates has written
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.

old Re: Bot voting & setpos

Suprise
BANNED Off Offline

Quote
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

old Re: Bot voting & setpos

Yates
Reviewer Off Offline

Quote
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.

old Re: Bot voting & setpos

Powermonger
User Off Offline

Quote
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?

old Re: Bot voting & setpos

Yates
Reviewer Off Offline

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

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

old Re: Bot voting & setpos

EngiN33R
Moderator Off Offline

Quote
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.

old Re: Bot voting & setpos

Powermonger
User Off Offline

Quote
Quote
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.

old Re: Bot voting & setpos

omg
User Off Offline

Quote
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
edited 1×, last 23.08.12 01:37:25 am

old Re: Bot voting & setpos

TheBosS_
User Off Offline

Quote
user omg has written
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

old Re: Bot voting & setpos

Powermonger
User Off Offline

Quote
user omg has written
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 has written
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?
edited 1×, last 29.08.12 02:22:11 am

old Re: Bot voting & setpos

EngiN33R
Moderator Off Offline

Quote
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

old Re: Bot voting & setpos

Powermonger
User Off Offline

Quote
user EngiN33R has written
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
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview