Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 2328 329 330338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
@Dark Byte Ideally you could, but you would need to use c++ interface to work with .DLL in Lua.
C++ Code ~= work with Lua.

alt Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Zitieren
Thanks. Now I need to know how to create global variables using the C API. I have this
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?

alt Re: Lua Scripts/Questions/Help

Rainoth
Moderator Off Offline

Zitieren
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

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.

alt Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Zitieren
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

alt Question

sixpack
User Off Offline

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

alt Re: Lua Scripts/Questions/Help

Jake-rus
User Off Offline

Zitieren
WHAT IS THAT ???

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!

alt Re: Lua Scripts/Questions/Help

Vetle
BANNED Off Offline

Zitieren
Can someone make for me when player only has mercedes.png picture he can buy
mercedes_spoiler.png
thank u

heres the script

Zitat
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

alt Re: Lua Scripts/Questions/Help

sixpack
User Off Offline

Zitieren
Cena hat geschrieben
Can someone make for me when player only has mercedes.png picture he can buy
mercedes_spoiler.png
thank u

heres the script

Zitat
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

alt Tibia

Alex_Aaa789
User Off Offline

Zitieren
can make tibia status bar shows MP, but can't make MP perform arithmetic (+-MP)

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




Dantes Inferno hat geschrieben
Can someone help me im trying to make the bullets to explode when the hit something


Example: USP
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

alt Re: Lua Scripts/Questions/Help

JONY
User Off Offline

Zitieren
RyceR hat geschrieben
how to make it?:
When i shoot from five-seven (to wall or to player) there is explosion, example:


Dantes Inferno hat geschrieben
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:
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 hat geschrieben
WHAT IS THAT ???

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

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
@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.

alt Re: Lua Scripts/Questions/Help

JONY
User Off Offline

Zitieren
Cena hat geschrieben
Someone make for me when i goto tile x11 y33
i get 16000$

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

alt Re: Lua Scripts/Questions/Help

Jynxxx
User Off Offline

Zitieren
it has an error can some one help me

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

1
2
3
4
5
6
addhook("hit","_hit")
function _hit()
       if (rp_ct()==true) then
	return 1
	end
end

alt Re: Lua Scripts/Questions/Help

DannyDeth
User Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 2328 329 330338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht