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 272 73 74338 339 Next To the start

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
i tried making a no reload and i got this :
1
2
3
4
5
6
7
8
9
addhook("hit","nr")
function nr(p,s,wpn,hp,dmg)
	if (hp>0) then
		parse("setweapon "..p.." " ..wpn)
	end
	if (dmg>0) then
		parse("setweapon "..p.." " ..wpn)
	end
end
but when i hit someone console says :
ERROR: setweapon - player does not have the item 32!(or wpn id)
and it sometimes give the weapon to the victim
edited 1×, last 29.10.09 01:45:26 am

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
-WiLSoN- has written
i tried making a no reload and i got this :
1
2
3
4
5
6
7
8
9
10
addhook("hit","nr")
function nr(p,s,wpn,hp,dmg)
	if (hp>0) then
		parse("setweapon "..p.." " ..wpn)
	end
	if (dmg>0) then
		parse("setweapon "..p.." " ..wpn)
		
	end
end
but when i hit someone console says :
ERROR: setweapon - player does not have the item 32!(or wpn id)
and it sometimes give the weapon to the victim


It's because you are setting victim's weapon to the attacker's weapon.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
@Wilson - You have to learn to figure out things by yourself. Consider the following

function hit_hook(victim, source, weapon, health, damage)

This would only be called when a victim (and here the victim, not the attacker) has been hit/injured by another player.

You want to create a function that whenever a player shoots, he will not have to bother with reloading.

Now ask yourself this question? Is the event of having to shoot and reload always occurring simultaneously with the event of hitting a victim?

The answer is no, if you buy an AK47 and shoot at the walls, you'll go through a clip of 30 bullets and you still will not have invoked the nr function. Therefore, the "hit" hook is not the right hook that you are looking for.

The only hook that occurs simultaneously with the event that you want is the hook that is invoked when you shoot your weapon. I'll leave this as an exercise for you to find out the answers to. (Hint - Look through info.txt within the lua directory)

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
playa slaya has written
so is no-clipping possible?




He's saying that when you shoot you won't get any ''infinite ammo'' unless you hit a player.

old Re: Lua Scripts/Questions/Help

BetaM
User Off Offline

Quote
Flacko has written
(...)
ideas are free and can't be patented by any means, what you can patent is what you have done.
(...)
Maybe he is talking about his script and not his idea?
(...)
Programmers can write good code in all the program and have no problems with it.
Or they can write bad code in all a program and have to rewrite lots of his code because he forgot some simple thing.


It's not an idea you know, it's a whole big script. I didn't patent it, I just said I didn't want anybody to try to figure out what was the script actually, because it would be too much spoiling (and there is more than achievements).

It was my idea (um...), and my script (a few my posts back, I asked for help and I got it, I added those people into credits ).

My mistake was rather a trial of my lua skills, which resulted in an error. (why? who knows...)("...value bug..." Really? I think that it was an id bug. The script had changed the team of the player and in the same time it wanted the id, and I think that was the error. Am I wrong?)

EDIT: I've fixed the error. It was like my post in the german section (always hook fail).

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@Mat5B,
Dont you think it was too offensive post?
That script which you used was weird
and 100% reminds of my old saving scripts (credits to leegao and flacko)
which wasn't comfortable for achivements save. (script which you posted).
As I said, it would be better to rescript it.

Please do not be offensive for your request feedbacks. We want only to help you.

old Re: Lua Scripts/Questions/Help

BetaM
User Off Offline

Quote
Blazzingxx has written
(...)We want only to help you.

Then please help me again

Spoiler >


After the second launch time of the script (when the file loaded) and I left the server, there was the error again:
"LUA ERROR: sys/lua/server1.lua:1482: attempt to concatenate field '?' (a nil value)"
So, it's the same again
(1482 line: " file:write(ac1[id]..' '..ac2[id]..' '..ac3[id]..' '..ac4[id]..' '..ac5[id]..' '..ac6[id]) ")

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
It happend much times for me.
Can you try restart your CS2D - server?
Sometimes it fixes it.

Anyway, right now I cant check scripts. Not at my current computer.

old Values Explained?

Toa Hero 92
User Off Offline

Quote
Hello for the script I'm making I need to understand these values:

From the hook "use" I need an explanation and examples (if available) of these functions :"event","data","x","y"

From the hook "select" I need an explanation and examples (if available) of these functions :"type","mode"

I need an explanation and examples (if available) of what the "item type"(s) & "building type"(s) & "weapon type"(s) & "source type"(s) are.

I need an explanation and examples (if available) of what the "item mode"(s) & "building mode"(s) are.

From the hook "drop" I need an explanation and examples (if available) of these functions :"ain" (more specifically the "item count" portion)

I have read and re-read the info.txt & gone over the samples countless times, so DON'T suggest I read them

I have a list of the item id numbers (laser = 45) that the game uses for commands such as "equip" & "strip", so don't tell me to go into editor. (unless that it is to what these are referencing)

I also have a list building id numbers (12 = triple turret) that the game uses for such commands as "spawnobject" & "killobject", so don't tell me to go into editor. (unless that it is to what these are referencing)

And don't refer me to http://www.cs2d.com/help.php, because I have also pored over these endlessly, so unless they've updated recently then don't.

I will keep asking these questions if answers aren't provided, in the hope that they will be.

I have been short with you all because I know that a serious question can get halted in it's tracks by the stupid questions it can raise, & so I've attempted to make my questions as short and concise as I can. I've also been short to avoid draw out conversations.

All & Any help will be appreciated.

Thank you.

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Hmm... I never used the "use" hook, so I can't tell you much about it.

For the select hook:
Type: Item type (Ie: If the player selects the laser, the Type variable will be 45)
Mode: Firing mode of the weapon (Ie: Single fire is 1 (I think) and burst fire is 2, you can also apply this to laser colors)

For the drop hook:
Ain returns the ammo into the gun you dropped (Ie: You have an Ak-47 with it's clip full of ammo, you shoot 3 times and drop it, ain would be 27)
In case you have 10 snowballs, throw 4, then you drop them ain will be 6 (This is the item count part)

Item type: Item types aren't the same thing as Item Id in scripting. Item type is the "base" item, and the item id will get it's propieties from this base item (Damage, firing rate, accuarcy, max ammo), but it will independently have it's own values like ammo, position and holding player. The item type numbers are the same as in the map editor, for example, an Item ID that has the type 45 is a laser.

Building types: Same as weapons but with buildings.

Weapon type: Same as item type, but weapon type doesn't exists, it's just another way of saying item type

Source type: No idea. Maybe it has different values when the source is a "worldspawn" entity, like a hurt entity in the editor, a deadly tile or the player wrote "kill" in console.

Item mode: The burst fire, single fire and laser color things I told you before.

Building mode: The only building that seems to support this is the supply, different building modes will make the dispenser give different items.

old No Reload Script (working)

Toa Hero 92
User Off Offline

Quote
Hello I just came on to say thanks to Flacko for his help and to put this code up for everyone to use:

1
2
3
4
5
6
7
8
9
10
11
addhook ("attack","noreloadtoaa1")
	function noreloadtoaa1(id)
	
	wepid = {1,2,3,4,5,6,10,11,20,21,22,23,24,30,31,32,33,34,35,36,37,38,39,40,45,46,47,48,49,51,52,53,54,72,73,75,76,77,87}
	
	for i = 1,#wepid do
		if (player(id,"weapontype") == wepid[i]) then
		parse("equip "..id.." "..player(id,"weapontype").."")
		end
	end
	end

this is a working no-reload script

A few things though about it..

1) It doesn't work with weapons that have only 1 shot/ammo to begin with. (e.g. HE)



Also could someone help me with this...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("spawn","adminspawn")
function adminspawn(id)

adminid = {usgnidnum} -- USGN ids list

	
   for i = 1,#adminid do
     if (player(id, "usgn") == adminid[i]) then
          parse("speedmod "..id.." 10; equip "..id.." 88; equip "..id.." 80; equip "..id.." 74; equip "..id.." 45")
          parse("setmaxhealth "..id.." 250; sethealth "..id.." 250")
          msg("©135013208 "..player(id,"name").." is an Administrator for this Server! @C")
     end
end 
end

This works perfectly; but, when I add this line..

1
parse("hudtxt2 "..id.." 1 "the message" 200 300 1")
It will stop processing the string's variables at this point :parse("hudtxt2 "..id.." 1 "the message" 200 300 1")

And will display the hud text as "the message 200 300 1" in the very upper right corner of the screen.

I want it to display it 1/4 down the screen at the center.
What is wrong?

I've tried all sorts of combinations of quotation marks and parenthesis's, so unless you know it is guaranteed to work then don't tell me.

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
you wasted allot of time with your weapon varible you should have done this
1
2
local wpnid
for wpnid=1,88 do
that would have been alot easier

@ Flacko
(
I did not mean the clip in a gun i meant walking through walls)

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
playa slaya has written
you wasted allot of time with your weapon varible you should have done this
1
2
local wpnid
for wpnid=1,88 do
that would have been alot easier

@ Flacko
(
I did not mean the clip in a gun i meant walking through walls)


Oh, i thought you were talking about wilson's script

old Re: Lua Scripts/Questions/Help

BetaM
User Off Offline

Quote
Is it only by me, or does the radio hook executes only in 3 messages? (Roger that,Need Backup,Get out of there it's gonna blow)
To the start Previous 1 272 73 74338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview