Sign in to follow this  
Followers 0
HAN-105

Script Help

could someone help me to figure it out, how to put the custom area from area.txt (what i mean is the area name to put it in this lua) ? so my plan : make a block script for if player trying go out from the base/arena, they will get something like counting time before player died. just like what halo reach game did. ? the message "Return to battle field....". so it mean, human only survive in that base, and survive until time over.

 

so hopefully if someone know/tutorial things, u can pm me. because i guess, this thread telling about request, not tutorial. so thanks

 

anyway i scripted like this. not sure if that's correctly

api_version = "1.9.0.0"
inarea = {}
inareatime = {}

function OnScriptLoad()
	register_callback(cb['EVENT_AREA_ENTER'], "OnAreaEnter")
	register_callback(cb['EVENT_AREA_EXIT'], "OnAreaExit")
        if(get_var(1,"$map") ~= "covetorn") then return end
	timer(1000, "areatimer")
end

function OnAreaEnter(PlayerIndex, AreaName)
	if PlayerIndex ~= "-1" then
		inarea[PlayerIndex] = true
	end
end

function OnAreaExit(PlayerIndex, AreaName)
	if PlayerIndex ~= "-1" then
		inarea[PlayerIndex] = false
	end
end

function areatimer()............

Share this post


Link to post
Share on other sites

Tiddy-bits:

PlayerIndex will definitely never be a string, and I don't think it can be -1. In fact, it shouldn't even trigger for non-player objects. If you're worried that it may, though, then you should do player_present(PlayerIndex).

Share this post


Link to post
Share on other sites

something like this ?

function OnAreaEnter(PlayerIndex, AreaName)
	if player_present(PlayerIndex) then
                inarea[PlayerIndex] = true
        end
end

function OnAreaExit(PlayerIndex, AreaName)
	if player_present(PlayerIndex) then
		inarea[PlayerIndex] = false
	end
end

i am really sorry, in fact. i am still beginner, so i need some help from anyone. but anyway, if this script code true. then any idea how to put area name from area.txt ? can you post some instruction or maybe guide or even the function of code work

Share this post


Link to post
Share on other sites

You could check the value of AreaName before the "if player_present..." code:

function OnAreaExit(PlayerIndex, AreaName)
    if AreaName ~= "nameofarea" then return end
    if player_present(PlayerIndex) then
        inarea[PlayerIndex] = false
    end
end

As a word of advice, you should really learn Lua if you want to be making scripts.

NeX and HAN-105 like this

Share this post


Link to post
Share on other sites

sure,i am going to learn lua as best as i can. i just seeing tutorial from your lua info :)

oh thanks, i guess, i didn't notice that parameters. i thought they are just the syntax that it must place. so i think, this similar to any other programming language like java, vb

 

function OnAreaExit(PlayerIndex, AreaName)

my bad, i didnt read it. sorry

Edited by HAN-105

Share this post


Link to post
Share on other sites

As a word of advice, you should really learn Lua if you want to be making scripts.

 

Doubling up on this. My LUA is nasty and rusty, and I spend more time quickly googling syntax than I do actually writing any code.

HAN-105 likes this

KsqHutE.png

Share this post


Link to post
Share on other sites

Doubling up on this. My LUA is nasty and rusty, and I spend more time quickly googling syntax than I do actually writing any code.

i agreed, there's completed documentation/guides/tutorial on everywhere. but the only i need is for sapp lua script, there's no completed guides even syntaxes. only function/event/ how it works. so i guess, learn from someone is really need, but its really hard to find the guy who have free times to make tutorial or syntaxes. like scripting syntax for coordinate so that we can define it like as block area or more, and etc

Edited by HAN-105

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0
  • Recently Browsing   0 members

    No registered users viewing this page.