Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 296 97 98338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
CmDark has written
DC, does os.execute work with cs2d correctly?
I'm working on a primitive player log system
     if os.execute works then my system will work

Edit 2: Nevermind CMD.exe can't call the player functions in cs2d T_T


Lol, of course it can't.
It's a different program, in a different executable that hasn't got anything to do with CS2D

old Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Quote
Err, working on a mod. Besides @C for msg and msg2, are there any other positions? From the way text work im guessing theres one more (Center, Bottom left corner, Upper left Corner)

old Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Quote
addhook("kill","killmsg")
function killmsg(id,killer,victim,weapon,x,y)
name = player(victim,"name")
     hudtext2(id,9,'©255255255','You killed: "..name.."',1,415)
end

No error message, doesnt show up on screen?

old Re: Lua Scripts/Questions/Help

Heartless Soldier
User Off Offline

Quote
Yorty has written
addhook("kill","killmsg")
function killmsg(id,killer,victim,weapon,x,y)
name = player(victim,"name")
     hudtext2(id,9,'©255255255','You killed: "..name.."',1,415)
end

No error message, doesnt show up on screen?


It doesn't show up because for the id you are using "id", and it doesnt know what is id, for return the id you have to use "killer".

kill(killer,victim,weapon,x,y):
there isnt id

old Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Quote
Fapicon has written
Somebody must help me! I can`t complete C&F 1.1 script without car sprites. I have all sprites what I need. But script don`t want choose class and sprite!





Spoiler >


make it at part.
read this.

Spoiler >

old Re: Lua Scripts/Questions/Help

h4uja2
User Off Offline

Quote
Help me pls, i need a vampire class. I want to get 1 hp when i hit an enemy, and get 20 hp when i kill an enemy! Help me

old Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Quote
N-B-K has written
Yorty has written
addhook("kill","killmsg")
function killmsg(id,killer,victim,weapon,x,y)
name = player(victim,"name")
     hudtext2(id,9,'©255255255','You killed: "..name.."',1,415)
end

No error message, doesnt show up on screen?


It doesn't show up because for the id you are using "id", and it doesnt know what is id, for return the id you have to use "killer".

kill(killer,victim,weapon,x,y):
there isnt id

Well that was a fail on my part

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Yorty has written
addhook("kill","killmsg")
function killmsg(id,killer,victim,weapon,x,y)
name = player(victim,"name")
     hudtext2(id,9,'©255255255','You killed: "..name.."',1,415)
end

No error message, doesnt show up on screen?

Can you give us your hudtext2 function?
NBK is wrong, this should work anyways.

EDIT: Try this:
1
2
3
4
5
addhook("kill","killmsg")
function killmsg(id,killer,victim,weapon,x,y)
	local name = player(victim,"name")
	hudtext2(id,9,'©255255255','You killed: '..name,1,415)
end
edited 2×, last 21.11.09 09:24:13 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
playa slaya has written
okay thx but what is % and ^
also when should we use :

Check string formats.

You said you know how save works...
Then you should get how : is using.

old Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Quote
Kay, Ive got a system where you unlock moar weapons as you rank, and a menu(s) to choose from. The problem is this: I currently have it that when you select a weapon it strips you of that weapon category and gives it to you, which allows infi ammo and weapons pretty much. I want it that you select them, and get them when you spawn. Now ive tried this, but had errors.

Look at this:

function m4a1(id)
     stripprim(id)
     parse("equip "..id.." 32");
end

I want it something like this:

function m4a1(id)
     *set something (set primw to 32), but I have no idea how to do that.
end

How would I fix these?

Below is the spawn thingy.
addhook("spawn","mw2spawn")
function mw2spawn(id)
     wpnp = primw[id]
     return("..wpni..,(rest would be used for sec. weps)");
end
edited 1×, last 21.11.09 11:27:18 pm

old Hi all :D

_PzN_CrazyRus
User Off Offline

Quote
Pls, help me with this parameter:

addhook("say","spawn9")
function spawn9(id,txt)
     if(txt=="!polmav") then
freeimage(id)
parse("speedmod "..id.." 50")
parse("setmaxhealth "..id.." 75")
parse ("equip "..id.." 37")
id1=image("gfx/carscript/polmav.png",1,1,200+id)
id2=image("gfx/carscript/heliblade.png",1,1,200+id)
imagescale(id1,1,1)
imageblend(id1,0)
imagealpha(id1,1.0)
imagepos(id2,1,1,1)
if (player(id,"team") == 2) then
imagecolor(id1,255,255,255)

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



Image not rotate. Why?

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
playa slaya has written
okay thx but what is % and ^
also when should we use :


there are many uses of % and ^, traditionally the former acts as a binary operator for integer modulo division while the former is implemented on some systems as the de facto exponential operator. In string manipulation, % is usually the replacement signal for string formating (see printf) and both are used within regex level string handling.

the : operator is an uncommon (but very useful) feature unique to lua. To illustrate, look at the following example

>a = {}
>
>a.a = function(self) print(self.b) end
>
>a.b = "Hello World"
>
>a:a()
Hello World

So here, given a function inside the table, calling table:function would be the same as calling table.function(table)

It's much more useful when you go into simulating classes with lua's tables.

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
I am working on entangle roots ability for WC3TFT 2D but cannot get it to work. I want the entangled roots to be cast on enemy player but just once and the image must rotate continuesly while it's on. And then when entangled time (10 sec) runs out entangled should disappear.

This is the script. It keeps adding that same image... I don't know how to stop it from repeating itself.

Note: This is only a part of the actual WC3TFT 2D script.
Spoiler >

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
@KK

nesting scopes do not exist in Lua, variables declared within functions are global by default unless explicitly declared as local. In your case, each time that the entangleroots_on function is called, the global value of entangled that entangleroots_off function depends on is changed.

1
2
3
4
function entangleroots_off(i) 
	imagealpha([b]entangled[/b],0.0) 
	freeimage([b]entangled[/b]) 
end

I'm going to assume that you mean to freeimage the image passed in as i instead, thus the function should theoretically be

1
2
3
4
function entangleroots_off(i) 
	imagealpha([b]i[/b],0.0) 
	freeimage([b]i[/b]) 
end

more importantly

1
2
3
4
5
6
7
8
[b]_players = {}[/b]
function entangleroots_on(i)
	local entangled=image("gfx/wc3tft_2d/entangleroots1.png",0,0,200+i) 
	imagealpha(entangled,0.01) 
	imagescale(entangled,1.0,1.0) 
	imagepos(entangled,0,0,rot) 
	players[i] = entangled
end

Here, we have to cache the images independently since lua isn't persistent (in fact, what language is?) You need to map the image to the player, so just construct a table called _players

However, the root of your mistakes is that you can not differentiate between the image() and the imagepos() function. Repeated calling image() will only create new images, not rotate existing ones. Refer to info.txt for more details.

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
That gives me this error.
attempt to index global 'players' (a nil value)

Does that mean that I have to make a variable for a nil value or what?

Like this...
1
2
3
[spoiler]if (players[i]==nil) then
-- Do nothing!
end[/spoiler]
I can't make this script functional. Someone save me from this madness.

I need to remove all images not only one after the (10 sec) entangle roots ability runs out. I don't think that's possible as I tried to add freeimage(i) 10 times. It keeps adding by the (sec hook) like 9-10 entangle roots images to enemy player but then the images doesn't go away when the entangle roots time runs out.

Is that just a bug? I cannot remove all images of that imageid which I called "entangled" it just removes one, I want it to remove all.
edited 1×, last 22.11.09 12:16:34 pm
To the start Previous 1 296 97 98338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview