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 2333 334 335338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
@DannyDeth
I didn't say you can write the value nil...
I just said you can let it look like nil with a string, it's something completely different.
And to the last thing: lol.

@All
I've got a question.
How can I check if a tile between two positions is a wall?
I know that I can calculate how far they are away from each other with math.sqrt:
1
math.sqrt((y-player(id,"y"))^2 + (x-player(id,"x"))^2)
and that I can just turn a x value into a tilex value with math.floor:
1
2
x = 67
math.floor(x/32) -- 2
But how do I check every single tile without writing to much code?
Like this:
1
2
3
4
5
6
if rot1 < rot2 + 20 and rot1 > rot2 - 20 then
	if math.sqrt((y-player(id,"y"))^2 + (x-player(id,"x"))^2) < 300 then
		--check if wall is there
			--code
	end
end

old Re: Lua Scripts/Questions/Help

vilimonas
User Off Offline

Quote
can any of you help me how to use lua scripts plase i want to create a rp server on cs2d so plzzzz






thx a little





but do anybodie have a rp server and can i be a admin plss maby tere you can tell me more and plase i always wanted to be a admin
edited 3×, last 23.12.10 10:01:34 pm

old Re: Lua Scripts/Questions/Help

JONY
User Off Offline

Quote
@Yasday:
I guess there's no other way, other than what you said. Convert it from pixels to tiles(/32) and use tile(x,y,"wall").
Edit: btw, you dont really need to use math.floor, because it will round itself when you call tile(x,y,"wall") (not sure though) .

@DannyDeth:
to update (and display) hp of a player every 100ms is very inefficient. Just assign this to "hit" hook, because that's the only place where hp really changes. It will be more accurate and a little bit less lag
J.

old Re: Lua Scripts/Questions/Help

Simplest
User Off Offline

Quote
My lua script won't work
This is my first big script so the error might be very big...
Spoiler >

Its very long..

old Re: Lua Scripts/Questions/Help

Simplest
User Off Offline

Quote
alir292 has written
can anyone plz tell me how to become ct admin ( and also what do i do with RP ACHIVE plz tell me by PM plzplzplz


in the rp lua file, find the "admin={#####,}"
and replace the 5 numbers with your USGN ID

if your lua file doesnt have that then it might have a separate .TXT file, just replace the existing USGN with your USGN ID

old closed Re: Lua Scripts/Questions/Help

sixpack
User Off Offline

Quote
Dantes Inferno has written
can someone help me how do i put a picture in the signature box


OFF TOPIC!!!
Use [ img ] link [ /img ]
without the spaces.

old Re: Lua Scripts/Questions/Help

Rainoth
Moderator Off Offline

Quote
Quote
My lua script won't work
This is my first big script so the error might be very big...


Spoiler >


The error shouldnt be big. Everywhere you put too less "end" they are needed for "elseif" and function closing also for every "if" and everywhere there are 2,3 of them while should be ~8 count everything.

------------------------------------------------------

Now My part :

How do i check if player has enough points then...
1
points[id]=points[id]-1

and player get credits well i know that part but i want
to make -points instead of money
1
if (player(id,"money")>14999) --Here has to be points instead of money
edited 1×, last 24.12.10 11:27:15 am

old Re: Lua Scripts/Questions/Help

DannyDeth
User Off Offline

Quote
@Batlaizys:
Could you explain a little better what you want to do? It is coming across that you want a point system that gives them credits for each point or something like that...

old Re: Lua Scripts/Questions/Help

Rainoth
Moderator Off Offline

Quote
In my Bat Mod i have implemented streaks. If you get 30 streaks you get one mega point. you can exchange it into 200 credits or later buy special powers. I have made shop for money.
it checks if player id miney >14999 then he buys that and loses 15000 but this is money. How to do it for points ? i mean points[id]...

old Re: Lua Scripts/Questions/Help

DannyDeth
User Off Offline

Quote
You can't drop the wrench first place, lol.

@Batlaizys
Ok, so you have a table with each person's points, correct? So you want to know how to remove the credits when they spend in a shop? I will give you an example:
1
2
3
4
function trade(player_id, item_id)
	price = item_price[item_id]
	credits[player_id] = credits[player_id] - price
end
This function will remove the credits from the dude's "bank account" according to the price of the item in item_price[] table.

old Re: Lua Scripts/Questions/Help

Rainoth
Moderator Off Offline

Quote
no no no. We talk about Buying credits for MEGA POINTS i want to know how to check if player has more than 0 mega points. but dont know how cause points have id like if player points[id] > 0 ,then
credits[id]=credits[id]+200. Somthing like that, i dont know if this is right...

old Re: Lua Scripts/Questions/Help

DannyDeth
User Off Offline

Quote
Okay! I get it now! So you want to check if the player has Megapoints, and then exchange them for credits, you would have to have 2 tables: one called credits[] and one called mpoints[]. So this is what you do, in a function:
1
2
3
4
5
6
7
function exchange_mpoints_for_credits(id)
	if (mpoints[id] > 0) then
		credits[id] = credits[id] + ( mpoints[id] * 200 )
	else
		msg(copyright.."2550000You have no MegaPoints to exchange for credits!")
	end
end

old Re: Lua Scripts/Questions/Help

brk951753
User Off Offline

Quote
i need help
i dont know how to make save system :S
i will save licences

pls use minute function

if rp_hplicence[id]== true or rp_hitlicence[id]== true or rp_buldlicence[id]== true or rp_license[id]==true or yourmon[id] >= 1 then


save =>>rp_hplicence[id]
save =>>rp_hitlicence[id]
save =>>rp_buldlicence[id]
save =>>yourmon[id]
save =>>rp_license[id]


pls help me...
To the start Previous 1 2333 334 335338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview