Forum

> > CS2D > General > Hook 'Usebutton' not working!
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Hook 'Usebutton' not working!

16 replies
To the start Previous 1 Next To the start

old Hook 'Usebutton' not working!

jabba
User Off Offline

Quote
I tried to do a usebutton hook:

function comprarcasa(id,x,y)
     if(player(id,"exists")) then
     px = player(id,"tilex")
     py = player(id,"tiley")
          if px == 21 and py == 21 then
               msg2(id,"©255000000 ID: "..casas[1].."")
               if casas[1] == 255 then
                    casas[1] = id
                    msg2(id,"©255000000 ID: "..casas[1].."")
                    parse("setmoney "..id.." "..player(id,"money")-1000)
               elseif casas[1] ~= id then
                    msg2(id,"©255000000 Somente o dono pode abrir a casa")
                    msg2(id,"©255000000 ID: "..casas[1].."")
                    return 1
               end
          end
     end
end

And is not working, only for admins... =\

I need to know, is 'usebutton' hook working?

old Re: Hook 'Usebutton' not working!

SQ
Moderator Off Offline

Quote
Anyway, that's not whole script...
You haven't declared any table or other variables. ect "cesas[]"
edited 1×, last 26.01.10 05:38:10 pm

old Re: Hook 'Usebutton' not working!

jabba
User Off Offline

Quote
function iArray(m)
     local array = {}
     for i = 1, m do
          array[i]=255
     end
     return array
end

casas = iArray(10)

addhook("usebutton","comprarcasa")

function comprarcasa(id,x,y)
     if(player(id,"exists")) then
     px = player(id,"tilex")
     py = player(id,"tiley")
          if px == 21 and py == 21 then
               msg2(id,"©255000000 ID: "..casas[1].."")
               if casas[1] == 255 then
                    casas[1] = id
                    msg2(id,"©255000000 ID: "..casas[1].."")
                    parse("setmoney "..id.." "..player(id,"money")-1000)
               elseif casas[1] ~= id then
                    msg2(id,"©255000000 Somente o dono pode abrir a casa")
                    msg2(id,"©255000000 ID: "..casas[1].."")
                    return 1
               end
          end
     end
end
-------

PS:

button position x = 21 y = 21

PS2:

I'm using version 0.1.1.7

Please! All I need to know is if the 'usebutton' hook is working! I don't need no help with Scripting!
edited 2×, last 26.01.10 05:50:17 pm

old Re: Hook 'Usebutton' not working!

jabba
User Off Offline

Quote
Didn't work either..

Again, not a script problem.

Please people, I all need to know...

Is the usebutton hook working for you? (Or only for admins?)

old Re: Hook 'Usebutton' not working!

Cure Pikachu
User Off Offline

Quote
jabba has written
Please people, I all need to know...

Is the usebutton hook working for you? (Or only for admins?)

Tried mat5b's RPG Mod (Involves the usebutton hook, I guess ) and I suppose the hook works for any player.

old Re: Hook 'Usebutton' not working!

jabba
User Off Offline

Quote
I've searched and downloaded every mat5b RPG mod, but I didn't find the usebutton hook..

Can u send me the download link please?

old Re: Hook 'Usebutton' not working!

Lee
Moderator Off Offline

Quote
There's a very easy way to confirm if usebutton is working... your lack of originality is almost amusing

1
2
3
4
5
6
7
8
addhook("usebutton", "test")
function test(...)
	msg("Calling test...")
	local args = {...}
	for _,param in ipairs(args) do
		msg(param)
	end
end

If nothing happens when you press a button, then the usebutton event does not work, after which you have the right to come here and whine, but not before.

old Re: Hook 'Usebutton' not working!

CmDark
User Off Offline

Quote
amazing...

@jabba

of course it works for every player

there is absolutely no player(i,'usgn') or
anything to suggest that it would not work for everyone.

~~

old Re: Hook 'Usebutton' not working!

Cure Pikachu
User Off Offline

Quote
jabba has written
I've searched and downloaded every mat5b RPG mod, but I didn't find the usebutton hook..

Can u send me the download link please?


PMed you the link. Check it

BTW: Download the "mod", extract everything, and search the lua in your maps folder. Its a map LUA.
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview