Forum




C++ Code ~= work with Lua.
I never really attempted much things like that.
1
2
3
4
5
6
7
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);
}
1
2
3
4
5
6
7
8
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
-------------------------------------------------------
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
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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
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.
When i shoot from five-seven (to wall or to player) there is explosion, example:

1
2
3
4
5
6
7
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!
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
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
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
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
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
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
1
2
3
4
5
6
7
8
9
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
RyceR has written
how to make it?:
When i shoot from five-seven (to wall or to player) there is explosion, example:
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 ???
1
2
3
4
5
6
7
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

Those errors are completely normal.
The problem lies in the "primitive" bots (they use lua).
When you use

the one you described.(It cancels out the bot's lua scripts) Let's see if DC decides to make

i get 16000$
Cena has written
Someone make for me when i goto tile x11 y33
i get 16000$
i get 16000$
1
2
3
4
5
6
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
attempt to call global 'rp_ct' (a table value)
1
2
3
4
5
6
2
3
4
5
6
addhook("hit","_hit")
function _hit()
if (rp_ct()==true) then
return 1
end
end
What is the appropriate command to draw an image to the screen at certain coordinates?
Thanks ~DannyDeth.