English Lua Scripts/Questions/Help

6,770 replies
Goto Page
To the start Previous 1 2 ... 328 329 330 ... 338 339 Next To the start
18.12.10 06:02:20 am
Up
archmage
User
Offline Off
Is it possible to call functions from a DLL?
We must secure the existence of our people and a future for white children. 14/88
18.12.10 06:28:45 am
Up
CmDark
User
Offline Off
@Dark Byte Ideally you could, but you would need to use c++ interface to work with .DLL in Lua.
C++ Code ~= work with Lua.
IMG:http://i54.tinypic.com/auk478.png
18.12.10 06:53:11 am
Up
archmage
User
Offline Off
Alright, but how could I use a DLL?
We must secure the existence of our people and a future for white children. 14/88
18.12.10 07:14:59 am
Up
CmDark
User
Offline Off
Read up at Here

I never really attempted much things like that.
IMG:http://i54.tinypic.com/auk478.png
18.12.10 07:51:02 am
Up
archmage
User
Offline Off
Thanks. Now I need to know how to create global variables using the C API. I have this
Code:
1
2
3
4
5
6
7
void LUA_setglobalval(lua_State* L, const char* var, int val)
{
     lua_getglobal(L, var);
     if ( !lua_isnumber(L, -1) )
          lua_setfield(L, LUA_GLOBALSINDEX, var);
     lua_pushnumber(L, val);
}

Would that work properly?
We must secure the existence of our people and a future for white children. 14/88
18.12.10 09:50:48 am
Up
Rainoth
Moderator
Offline Off
Code:
1
2
3
4
5
6
7
8
addhook("minute","addcredits")
function addcredits()
     for i=1,32 do
          if (player(i,"exists")) and (hacker[i]==1) then
               credits[i]=credits[i]+15
          end
     end
end
how do i make instead "if player exists" to "if player lvl[id] 5 or bigger ?

-------------------------------------------------------

can anybody make something like
admins = {15476,1,and so on}
and only admins can acess

Code:
1
2
3
4
5
6
7
8
9
10
if button==6 then--WTF? Admin Commands = buy credits?
menu(id,"Admin Panel,5 Credits|1000$,10 Credits|2000$,15 Credits|2750$,20 Credits|3500$,50 Credits|9000$,100 Credits|15000$,200 Credits|1 Mega Point")
end

if button==7 then--WTF? Music = buy credits?
menu(id,"Songs,Under Development (picking songs),10 Credits|2000$,15 Credits|2750$,20 Credits|3500$,50 Credits|9000$,100 Credits|15000$,200 Credits|1 Mega Point")
end
end

end


dont mind this credit thingy cause so far me and my clan leader are picking what should be in. I just need that only if player USGN = that and that, then he can enter menu with that button, else it will say "sorry you are not Admin". Thank you for your help.
18.12.10 10:33:07 am
Up
Yasday
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
adminList = {16138,16138}

function isAdmin(id,tbl)
if not tbl then tbl = adminList end
for i,v in ipairs(tbl) do
if player(id,"usgn") == v then
return true
end
end
return false
end

--use

if isAdmin(id) then
--code
end
18.12.10 11:04:49 am
Up
sixpack
User
Offline Off
Hello everyone!
Can someone help me on how to use IO to create/read/write and everything else I can do with files.
Give me the way to do it, explain it and some sample code to look.
18.12.10 11:46:46 am
Up
RyceR
User
Offline Off
how to make it?:
When i shoot from five-seven (to wall or to player) there is explosion, example:
IMG:http://img690.imageshack.us/img690/5282/ggdust200000.jpg
IMG:http://img704.imageshack.us/img704/4043/userbargimp.png
18.12.10 12:13:12 pm
Up
Jake-rus
User
Offline Off
WHAT IS THAT ???

Code:
1
2
3
4
5
6
7
LUA ERROR (ai_update_living): bots/includes/collect.lua:16: attempt to call glob
al 'item' (a table value)
Freezing bots to stop Lua error msg flood! Use 'bot_freeze 0' to unfreeze bots!

LUA ERROR (ai_update_living): bots/includes/general.lua:63: attempt to perform a
rithmetic on field '?' (a nil value)
Freezing bots to stop Lua error msg flood! Use 'bot_freeze 0' to unfreeze bots!
IMG:http://i064.radikal.ru/1006/ef/a7ea290dc94d.gif
18.12.10 12:57:10 pm
Up
Jynxxx
User
Offline Off
Can someone help me im trying to make the bullets to explode when the hit something
18.12.10 03:42:47 pm
Up
Vetle
BANNED
Offline Off
Can someone make for me when player only has mercedes.png picture he can buy
mercedes_spoiler.png
thank u

heres the script

Quote:
addhook("use","c1")
function c1(id,event,data,x,y)
if(x==77) and (y==19) then
menu(id,"Mercedes shop,Mercedes|100$")
end
end

addhook ("menu","buycar1")
function buycar1(id,menu,sel)

if (menu=="Mercedes shop") then
if (sel==1 and player(id,"money")>99) then
parse ("setmoney "..id.." "..(player(id,"money")-100))
parse("speedmod "..id.." 20")
freeimage(id)
id1=image("gfx/nfsmodu2/mercedes.png",1,1,200+id)
imagescale(id1,1,1)
imageblend(id1,0)
imagealpha(id1,1.0)
if (player(id,"team") == 2) then
imagecolor(id1,255,255,255)

elseif (player(id,"team") == 1) then
imagecolor(id1,0,0,0)
end
     end
end
end
There will always be someone better than you.
18.12.10 04:12:24 pm
Up
sixpack
User
Offline Off
Cena has written:
Can someone make for me when player only has mercedes.png picture he can buy
mercedes_spoiler.png
thank u

heres the script

Quote:
hasmerc = {}
addhook("use","c1")
function c1(id,event,data,x,y)
if(x==77) and (y==19) then
menu(id,"Mercedes shop,Mercedes|100$")
end
end
addhook("join", "joe")
function joe(id)
hasmerc[id] = 0
end
addhook ("menu","buycar1")
function buycar1(id,menu,sel)

if (menu=="Mercedes shop") then
if (sel==1 and player(id,"money")>99) then
parse ("setmoney "..id.." "..(player(id,"money")-100))
parse("speedmod "..id.." 20")
hasmerc[id] = 1
freeimage(id)
id1=image("gfx/nfsmodu2/mercedes.png",1,1,200+id)
imagescale(id1,1,1)
imageblend(id1,0)
imagealpha(id1,1.0)
if (player(id,"team") == 2) then
imagecolor(id1,255,255,255)

elseif (player(id,"team") == 1) then
imagecolor(id1,0,0,0)
end
     end
end
end

Add the script above (I modified yours) and then if you want to check if someone has a mercendes, use:
if(hasmerc[id]==1) then
--code
end
18.12.10 04:22:43 pm
Up
Alex_Aaa789
User
Offline Off
can make tibia status bar shows MP, but can't make MP perform arithmetic (+-MP)

Code:
1
PLAYERS[id].tmp.mp = PLAYERS[id].tmp.mp+mp





Dantes Inferno has written:
Can someone help me im trying to make the bullets to explode when the hit something


Example: USP
Code:
1
2
3
4
5
6
7
8
9
addhook("hit","gun")
function gun(id, source, weapon, hpdmg, apdmg)
if (weapon == 1) then
local x, y
x = player(id, "x")
y = player(id, "y")
      parse("explosion "..x.." "..y.." <size> <dmg> "..id)
end
end
[ToW Co-Leader]Aaa789 IMG:http://i302.photobucket.com/albums/nn92/aaa789_alexlaw4/Untitled8.gif
Oh it was ended already
18.12.10 06:36:53 pm
Up
JONY
User
Offline Off
RyceR has written:
how to make it?:
When i shoot from five-seven (to wall or to player) there is explosion, example:


Dantes Inferno has written:
Can someone help me im trying to make the bullets to explode when the hit something


hm... that's how to make explosions on the walls. For the players it's harder, if you want, you can PM me and we'll talk about it:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
addhook("attack","makeexplosion",2)
function makeexplosion(id)
     if (player(id,"weapontype")==6) then
          local k=1
          local x=false
          while not (tile(math.cos(math.rad(player(id,"rot")-90))*k + (player(id,"x"))/32,math.sin(math.rad(player(id,"rot")-90))*k + (player(id,"y"))/32,"wall")) and (not x) do
               k=k+1
          
               --[[for i=1, #player(0,"table") do
                    if ((player(i,"x")) == ((math.cos(math.rad(player(id,"rot")-90))*32*k+(player(id,"x"))))) or ((player(i,"y")) == ((math.sin(math.rad(player(id,"rot")-90))*32*k + (player(id,"y")))))   then
                         x = true
                    end
               end]]
                         
               if (k>500) then --just in case check
                    break
               end
          end
          parse("explosion "..(math.cos(math.rad(player(id,"rot")-90))*32*k+(player(id,"x"))).." "..(math.sin(math.rad(player(id,"rot")-90))*32*k + (player(id,"y"))).." 30 1000 "..id)
          
          --msg(k)
     end
end

==========================================
Jake-rus has written:
WHAT IS THAT ???

Code:
1
2
3
4
5
6
7
LUA ERROR (ai_update_living): bots/includes/collect.lua:16: attempt to call glob
al 'item' (a table value)
Freezing bots to stop Lua error msg flood! Use 'bot_freeze 0' to unfreeze bots!

LUA ERROR (ai_update_living): bots/includes/general.lua:63: attempt to perform a
rithmetic on field '?' (a nil value)
Freezing bots to stop Lua error msg flood! Use 'bot_freeze 0' to unfreeze bots!


These are errors show the code...
18.12.10 09:03:54 pm
Up
CmDark
User
Offline Off
@Jony and Jake-Rus,
Those errors are completely normal.
The problem lies in the "primitive" bots (they use lua).
When you use cs2d cmd luareset they generate an error:
the one you described.(It cancels out the bot's lua scripts) Let's see if DC decides to make cs2d cmd luareset not affect the bots scripts.
IMG:http://i54.tinypic.com/auk478.png
18.12.10 09:21:52 pm
Up
Vetle
BANNED
Offline Off
Someone make for me when i goto tile x11 y33
i get 16000$
There will always be someone better than you.
18.12.10 10:02:53 pm
Up
JONY
User
Offline Off
Cena has written:
Someone make for me when i goto tile x11 y33
i get 16000$

Code:
1
2
3
4
5
6
addhook("movetile","get16000")
function get16000(id,x,y)
     if x==11 and y==33 then
          parse("setmoney "..id.." 16000")
     end
end
19.12.10 10:53:12 am
Up
Jynxxx
User
Offline Off
it has an error can some one help me

attempt to call global 'rp_ct' (a table value)

Code:
1
2
3
4
5
6
addhook("hit","_hit")
function _hit()
       if (rp_ct()==true) then
     return 1
     end
end
19.12.10 11:26:28 am
Up
DannyDeth
User
Offline Off
Hi all, I just wantd to ask a small question:
What is the appropriate command to draw an image to the screen at certain coordinates?
Thanks ~DannyDeth.
To the start Previous 1 2 ... 328 329 330 ... 338 339 Next To the start