Lua Scripts/Questions/Help
6,770 replies Hmm? Hook adding function requires "string".
addhook(Hook,"Function String")
Anyway, your function is working now...
I haven't tried, but it shouldn't work like this:
addhook(Hook,"Function String")
Anyway, your function is working now...

Code:
1
2
2
-- Probably it's returning integer (nil valuable) in this case...
addhook(always,my_function)
addhook(always,my_function)
When I use the 'strip' command on an inventory item I get an error message. Is it impossible to remove non-weapons?
Also waiting for the ammo changing script Blazzingxx mentioned two pages ago. I've looked into it, but I really can't find a way to do this (unless there's some hidden/invisible 'player' or 'item' table with variables that change their respective properties).
Also waiting for the ammo changing script Blazzingxx mentioned two pages ago. I've looked into it, but I really can't find a way to do this (unless there's some hidden/invisible 'player' or 'item' table with variables that change their respective properties).
What about forcing teams?
I can force a teamchange if someone chooses the team I don't want them to join, but then they automaticly switch back to their team of choice after they die (which they do when I force the teamchange). Maybe a way to remove the team from the menu?
EDIT: Also, I'm still curious about hidden tables. Anything undocumented, in fact.
I can force a teamchange if someone chooses the team I don't want them to join, but then they automaticly switch back to their team of choice after they die (which they do when I force the teamchange). Maybe a way to remove the team from the menu?
EDIT: Also, I'm still curious about hidden tables. Anything undocumented, in fact.
edited 1×, last 27.12.09 09:50:34 pm
How can I use default "pink" translucent color in "image" function?
And how can I use only one "piece" of image?
And how can I use only one "piece" of image?
Yes, black, but can I use exactly |255,0,255| color?
piece: I want to draw a tile from tileset, but I dont want to make many tiles cropped from that tileset
Just I am going to do Stereoscopic thing (Exactly:Anaglyph)
And How to turn string into the value?
piece: I want to draw a tile from tileset, but I dont want to make many tiles cropped from that tileset
Just I am going to do Stereoscopic thing (Exactly:Anaglyph)
And How to turn string into the value?
edited 1×, last 27.12.09 10:46:13 pm
You should try different blending modes and see if one of them works.
As far as I know, you can't blit a rectangle from a bitmap with CS2D's functions.
If you want to turn a string into a number, you sould use tonumber(), if you want to call a function thru a string, you should put your function inside a table and call it like this
Or you could use metatables but that would be too complicated and maybe even useless in this case
Edit: Oh sorry, I fail terribly, you don't need to put the functions in a table, you can simply call your function from the main table _G["Your function"](Your parameters)
As far as I know, you can't blit a rectangle from a bitmap with CS2D's functions.
If you want to turn a string into a number, you sould use tonumber(), if you want to call a function thru a string, you should put your function inside a table and call it like this
Code:
1
2
3
4
5
6
2
3
4
5
6
epic_table={
function da_function(a_string)
print(a_string)
end
}
epic_table["da_function"]("A printed text") --Here we call the function
function da_function(a_string)
print(a_string)
end
}
epic_table["da_function"]("A printed text") --Here we call the function
Or you could use metatables but that would be too complicated and maybe even useless in this case

Edit: Oh sorry, I fail terribly, you don't need to put the functions in a table, you can simply call your function from the main table _G["Your function"](Your parameters)
edited 3×, last 28.12.09 11:32:49 am
28.12.09 10:46:09 pm
I would like to use the "effect" command in a script. HOwever,this requires me to use two sets of quotes, which lua assumes is not part of the quote (the code is
parse("effect "colorsmoke" "..player(, etc.
parse("effect "colorsmoke" "..player(, etc.
ok i make script for my new mod but i donot why it dosen't
work the hook is add to game ( i see it from console) but nothing happen, its about that when your HP goes under 50 a msg pop up and tell you " you are Hurt,Get Covered" but when i start the game and my Hp gose under 50 a msg on console that shows Lua error the "player" must have a nil number somthing like that ? what wrong on it ?
work the hook is add to game ( i see it from console) but nothing happen, its about that when your HP goes under 50 a msg pop up and tell you " you are Hurt,Get Covered" but when i start the game and my Hp gose under 50 a msg on console that shows Lua error the "player" must have a nil number somthing like that ? what wrong on it ?
Call Of Duty - World At War [Work on progress] | official CoD scripts site
memo has written:
ok i make script for my new mod but i donot why it dosen't
work the hook is add to game ( i see it from console) but nothing happen, its about that when your HP goes under 50 a msg pop up and tell you " you are Hurt,Get Covered" but when i start the game and my Hp gose under 50 a msg on console that shows Lua error the "player" must have a nil number somthing like that ? what wrong on it ?
work the hook is add to game ( i see it from console) but nothing happen, its about that when your HP goes under 50 a msg pop up and tell you " you are Hurt,Get Covered" but when i start the game and my Hp gose under 50 a msg on console that shows Lua error the "player" must have a nil number somthing like that ? what wrong on it ?
Code:
1
2
3
4
5
6
2
3
4
5
6
addhook("hit","cod4.hit")
function cod4.hit(id)
if player(id,"health") < 50 then
msg2(id, "You are hurt, Get Cover!")
end
end
function cod4.hit(id)
if player(id,"health") < 50 then
msg2(id, "You are hurt, Get Cover!")
end
end
leegao has written:
memo has written:
ok i make script for my new mod but i donot why it dosen't
work the hook is add to game ( i see it from console) but nothing happen, its about that when your HP goes under 50 a msg pop up and tell you " you are Hurt,Get Covered" but when i start the game and my Hp gose under 50 a msg on console that shows Lua error the "player" must have a nil number somthing like that ? what wrong on it ?
work the hook is add to game ( i see it from console) but nothing happen, its about that when your HP goes under 50 a msg pop up and tell you " you are Hurt,Get Covered" but when i start the game and my Hp gose under 50 a msg on console that shows Lua error the "player" must have a nil number somthing like that ? what wrong on it ?
Code:
1
2
3
4
5
6
2
3
4
5
6
addhook("hit","cod4.hit")
function cod4.hit(id)
if player(id,"health") < 50 then
msg2(id, "You are hurt, Get Cover!")
end
end
function cod4.hit(id)
if player(id,"health") < 50 then
msg2(id, "You are hurt, Get Cover!")
end
end
lol, sorry to interrupt (leegao's code should work, I've done that stuff before). Shouldn't it be... "You are badly hurt, get to cover!"
thanks Trotsygrad but this msg come after i die i want it befroe dieing ?? like when my HP go on 49 the msg come on middle of the scrren thats what i want but thanks any way
Call Of Duty - World At War [Work on progress] | official CoD scripts site
memo has written:
thanks Trotsygrad but this msg come after i die i want it befroe dieing ?? like when my HP go on 49 the msg come on middle of the scrren thats what i want but thanks any way
You should thank leegao.
And this won't work very well if you get hit by an RPG/2xZ.AWP/Laser in case you were testing the script with those guns.
edited 1×, last 29.12.09 03:22:09 am
Flacko has written:
You should thank leegao.
And this won't work very well if you get hit by an RPG/2xZ.AWP/Laser.
And this won't work very well if you get hit by an RPG/2xZ.AWP/Laser.
Can't you add a code that returns 0 if certain weapon hit you?

Code:
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
addhook("hit","cod4.hit")
function cod4.hit(id,source,weapon,hpdmg,apdmg)
if player(id,"health") < 50 then
if "weapon = bla bla" then
return 0
else
msg2(id, "You are hurt, Get Cover!")
end
end
end
function cod4.hit(id,source,weapon,hpdmg,apdmg)
if player(id,"health") < 50 then
if "weapon = bla bla" then
return 0
else
msg2(id, "You are hurt, Get Cover!")
end
end
end