Lua question (FAQ)

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

User avatar
Eagle Eye
First Lance Corporal
First Lance Corporal
Posts: 129
Joined: Thu Nov 01, 2007 12:44 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Belgium
Contact:

Re: Lua question

Post by Eagle Eye »

I used this script and it doesn't work! :( I just respawn on the normal way and not anymore in the vehicle...

Code: Select all

OnCharacterSpawn(
function(player)
if GetCharacterTeam(player) ==  2 and IsCharacterInRegion(player, "forcevehiclereg") then
ActivateRegion("forcevehiclereg")
EnterVehicle(player, "Vehspawn1")
end
end
)
EDIT: after placed the region in ZE, do i need to update a file or is just saving fine?
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Lua question

Post by Maveritchell »

Does the BF2log spit out anything about either of those callbacks being bad?
User avatar
Eagle Eye
First Lance Corporal
First Lance Corporal
Posts: 129
Joined: Thu Nov 01, 2007 12:44 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Belgium
Contact:

Re: Lua question

Post by Eagle Eye »

yes here is my whole BF2log:
Hidden/Spoiler:
Opened logfile BFront2.log 2008-01-04 1205
ingame stream movies\crawl.mvs

Message Severity: 3
.\Source\LuaCallbacks_Mission.cpp(857)
Lua ReadDataFile: Could not open sound\shell.lvl
prev = none iLastPage = nil
prev = texture iLastPage = 1
prev = texture iLastPage = 2
prev = texture iLastPage = 3
ifs_legal.Exit
ifs_autonet dedicated
AutoNet Main
AutoNet Multi
AutoNet Gamespy
AutoNet multi main
AutoNet Server
AutoNet Game Options
Updating Lobby and attempting to Launch

Message Severity: 2
.\Source\HUDElementBitmap.cpp(380)
HUD BitmapElement unable to find texture hud_target_hint_offscreen

Message Severity: 2
.\Source\HUDElementBitmap.cpp(380)
HUD BitmapElement unable to find texture hud_target_hint_offscreen

Message Severity: 2
.\Source\HUDElementBitmap.cpp(380)
HUD BitmapElement unable to find texture btn_directional_pad_LR

Message Severity: 3
.\Source\LuaCallbacks_Mission.cpp(857)
Lua ReadDataFile: Could not open sound\spa.lvl;spa2cw

Message Severity: 2
.\Source\EntityGeometry.cpp(1058)
Entity "com_weap_veh_fly_guided_rocket_" unknown terrain collision "p_front_sphere"

Message Severity: 2
.\Source\EntityGeometry.cpp(1073)
Entity "com_weap_veh_fly_guided_rocket_" unknown vehicle collision "p_front_sphere"

Message Severity: 2
.\Source\EntityGeometry.cpp(1065)
Entity "com_weap_veh_fly_guided_rocket_" unknown building collision "p_front_sphere"

Message Severity: 2
.\Source\EntityGeometry.cpp(1051)
Entity "com_weap_veh_fly_guided_rocket_" unknown targetable collision "CollisionMesh"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_hostile_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_bacta_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_mechanic_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_ammo_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_transport_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_backup_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_clear_area_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_defend_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\FLEffect.cpp(214)
FLEffect::Read: duplicate effect class name (787b2928)!

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_hostile_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_bacta_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_mechanic_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_ammo_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_transport_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_backup_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_clear_area_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_defend_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\FLEffect.cpp(214)
FLEffect::Read: duplicate effect class name (5f518933)!

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_hostile_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_bacta_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_mechanic_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_ammo_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_transport_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_backup_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_clear_area_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_defend_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\EntityBuilding.cpp(695)
Building missing explosion "cis_bldg_boxturret_exp"

Message Severity: 2
.\Source\EntityBuilding.cpp(695)
Building missing explosion "cis_bldg_boxturret_exp"

Message Severity: 2
.\Source\EntityBuilding.cpp(695)
Building missing explosion "rep_bldg_boxturret_exp"

Message Severity: 2
.\Source\EntityBuilding.cpp(695)
Building missing explosion "rep_bldg_boxturret_exp"

Message Severity: 3
.\Source\Weapon.cpp(1719)
Weapon "imp_weap_fly_tiefighter_sc_cann" missing ordnance 0.000000 "imp_weap_fly_tiefighter_cannon_ord"

Message Severity: 2
.\Source\EntityGeometry.cpp(1058)
Entity "all_fly_n1" unknown terrain collision "collision_n1"

Message Severity: 2
.\Source\EntityGeometry.cpp(1073)
Entity "all_fly_n1" unknown vehicle collision "collision_n1"

Message Severity: 2
.\Source\EntityGeometry.cpp(1065)
Entity "all_fly_n1" unknown building collision "collision_n1"

Message Severity: 2
.\Source\GameObject.cpp(978)
Too many damage effects specified for gameobject [all_fly_n1]

Message Severity: 2
.\Source\GameObject.cpp(978)
Too many damage effects specified for gameobject [all_fly_n1]

Message Severity: 2
.\Source\GameObject.cpp(978)
Too many damage effects specified for gameobject [all_fly_n1]

Message Severity: 2
.\Memory\RedMemoryPool.cpp(317)
Memory pool "ParticleTransformer::SizeTransf" set item count after being allocated

Message Severity: 2
.\Memory\RedMemoryPool.cpp(317)
Memory pool "ParticleTransformer::ColorTrans" set item count after being allocated

Message Severity: 2
.\Memory\RedMemoryPool.cpp(317)
Memory pool "ParticleTransformer::PositionTr" set item count after being allocated

Message Severity: 2
.\Source\TriggerRegionManager.cpp(233)
Region deathregion3 not found

Message Severity: 2
.\Source\TriggerRegionManager.cpp(233)
Region deathregion4 not found

Message Severity: 2
.\Source\TriggerRegionManager.cpp(233)
Region rep-CP1Con not found

Message Severity: 2
.\Source\TriggerRegionManager.cpp(233)
Region cis-CP1Con not found

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active

Message Severity: 2
.\Source\ActiveRegion.cpp(262)
Region "forcevehiclereg" not active
I had to switch the team because of autoassign in multiplay (don't know how to change it to player select in the bat file)
so here is my new script: (and also i replaced the forcevehiclereg region from the one team to the other team's cp)

Code: Select all

OnCharacterSpawn(
function(player)
if GetCharacterTeam(player) ==  1 and IsCharacterInRegion(player, "forcevehiclereg") then
ActivateRegion("forcevehiclereg")
EnterVehicle(player, "Vehspawn4")
end
end
)
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Lua question

Post by Teancum »

I'd put ActivateRegion() in the scriptPostLoad() section of your mode lua, but that's just me. You're activating it after looking for it.
User avatar
Eagle Eye
First Lance Corporal
First Lance Corporal
Posts: 129
Joined: Thu Nov 01, 2007 12:44 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Belgium
Contact:

Re: Lua question

Post by Eagle Eye »

Thanks teancum,
this is the working script based on: if you enter region (i placed region at the cp spawn point) then you enter a vehicle. When the vehicle is used by an other player, you enter the next vehicle (example: vehspawn2) etc...
so i finaly find out how to fix my problem, thanks everyone for help!

Code: Select all

ActivateRegion("forcevehiclereg")
testfunction = OnEnterRegion(
function(region, player)
if IsCharacterInRegion(player, "forcevehiclereg") then
EnterVehicle(player, "Vehspawn1")
elseif VehspawnNum == 1 then
EnterVehicle(player, "Vehspawn2")
elseif VehspawnNum == 2 then
EnterVehicle(player, "Vehspawn3")
VehspawnNum = VehspawnNum + 1 
end
end,
"forcevehiclereg"
)
maybe this is usefull information for ppl who are looking for my question. And i hope ppl can use this.
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Lua question

Post by Teancum »

Eagle Eye wrote:
Hidden/Spoiler:
this is the working script based on: if you enter region (i placed region at the cp spawn point) then you enter a vehicle. When the vehicle is used by an other player, you enter the next vehicle (example: vehspawn2) etc...
so i finaly find out how to fix my problem, thanks everyone for help!

[code]ActivateRegion("forcevehiclereg")
testfunction = OnEnterRegion(
function(region, player)
if IsCharacterInRegion(player, "forcevehiclereg") then
EnterVehicle(player, "Vehspawn1")
elseif VehspawnNum == 1 then
EnterVehicle(player, "Vehspawn2")
elseif VehspawnNum == 2 then
EnterVehicle(player, "Vehspawn3")
VehspawnNum = VehspawnNum + 1
end
end,
"forcevehiclereg"
)[/code]
maybe this is usefull information for ppl who are looking for my question. And i hope ppl can use this.
It's super-useful. I'm going to bring back VH (Vehicle Only) mode with this!
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Lua question

Post by Maveritchell »

Unfortunately, it doesn't look like it has any sort of answer for what happens when you run out of vehiclespawns. You need to set up another conditional statement that backs you back to the first vehiclespawn if you get to your last one. Also, I think you can condense that code if you're going to use more vehiclespawns from:

Code: Select all

if IsCharacterInRegion(player, "forcevehiclereg") then
EnterVehicle(player, "Vehspawn1")
elseif VehspawnNum == 1 then
EnterVehicle(player, "Vehspawn2")
elseif VehspawnNum == 2 then
EnterVehicle(player, "Vehspawn3")
VehspawnNum = VehspawnNum + 1 
to simply:

Code: Select all

if IsCharacterInRegion(player, "forcevehiclereg") then
EnterVehicle(player, "Vehspawn" .. (VehspawnNum + 1))
VehspawnNum = VehspawnNum + 1 
That last code will make it so you don't have to set up a different condition for every different vehiclespawn, provided you keep using the naming convention "Vehspawn#" for your vehicle spawns.
User avatar
Eagle Eye
First Lance Corporal
First Lance Corporal
Posts: 129
Joined: Thu Nov 01, 2007 12:44 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Belgium
Contact:

Re: Lua question

Post by Eagle Eye »

Thanks Maveritchell! :shock: i thought my code worked, but i realise it doesn't work properly...
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Lua question

Post by [RDH]Zerted »

Yes, I have some questions about your code.
Should you make sure the vehicle is really spawned and that no one is already in it? What does EnterVehicle() do under those conditions?
Shouldn't the vehicle be moved back to its starting location?
Do you want everyone to enter the vehicle or just the team members of the CP?

Also, OnEnterRegion and IsCharacterInRegion is redundant.

I think it should be more:
OnCharacterSpawn
If IsCharacterInRegion
Then force a vehicle spawn and force the new unit into the new vehicle
Additional step for VH mode: Disable manually entering vehicles and kill unit+vehicle on vehicle exit
User avatar
Eagle Eye
First Lance Corporal
First Lance Corporal
Posts: 129
Joined: Thu Nov 01, 2007 12:44 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Belgium
Contact:

Re: Lua question

Post by Eagle Eye »

Hidden/Spoiler:
[quote="Maveritchell"]Unfortunately, it doesn't look like it has any sort of answer for what happens when you run out of vehiclespawns. You need to set up another conditional statement that backs you back to the first vehiclespawn if you get to your last one. Also, I think you can condense that code if you're going to use more vehiclespawns from:
[code]
if IsCharacterInRegion(player, "forcevehiclereg") then
EnterVehicle(player, "Vehspawn1")
elseif VehspawnNum == 1 then
EnterVehicle(player, "Vehspawn2")
elseif VehspawnNum == 2 then
EnterVehicle(player, "Vehspawn3")
VehspawnNum = VehspawnNum + 1
[/code]
to simply:
[code]
if IsCharacterInRegion(player, "forcevehiclereg") then
EnterVehicle(player, "Vehspawn" .. (VehspawnNum + 1))
VehspawnNum = VehspawnNum + 1
[/code]

That last code will make it so you don't have to set up a different condition for every different vehiclespawn, provided you keep using the naming convention "Vehspawn#" for your vehicle spawns.[/quote]
Um well i tested ur new code, but is doesn't work... Is there something wrong in the code?
The vehicles i use are named Vehspawn1; Vehspawn2; Vehspawn3 ecl...
When i respawn i just respawn on the normal way and not in the vehicle.
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Lua question

Post by Teancum »

VehspawnNum is never defined before the if statement, so the game doesn't know what the initial value is.
User avatar
Eagle Eye
First Lance Corporal
First Lance Corporal
Posts: 129
Joined: Thu Nov 01, 2007 12:44 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Belgium
Contact:

Re: Lua question

Post by Eagle Eye »

You mean something like this?
Hidden/Spoiler:
ActivateRegion("forcevehiclereg")
testfunction = OnEnterRegion(
function(region, player)
VehspawnNum = "Vehspawn" + number
if IsCharacterInRegion(player, "forcevehiclereg") then
EnterVehicle(player, "Vehspawn" .. (VehspawnNum + 1))
VehspawnNum = VehspawnNum + 1
end
end,
"forcevehiclereg"
)
This doesnt work, can someone tell me the right script to define the initial value?
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Lua question

Post by [RDH]Zerted »

This code should work. I'm not sure if you want the if num > maxNum then part or not.

Code: Select all

ActivateRegion("forcevehiclereg")
local VehspawnNum = 1
local VehspawnMaxNum = 4

testfunction = OnEnterRegionName(
	function(region, player)
		EnterVehicle(player, "Vehspawn" .. VehspawnNum)
		VehspawnNum = VehspawnNum + 1
		if VehspawnNum > VehspawnMaxNum then
		    VehspawnNum = 1
		end
	end,"forcevehiclereg"
)
User avatar
Eagle Eye
First Lance Corporal
First Lance Corporal
Posts: 129
Joined: Thu Nov 01, 2007 12:44 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Belgium
Contact:

Re: Lua question

Post by Eagle Eye »

Thanks [RDH]Zerted
But i had to change your script cause when i tryed ur script, it doesn't work...(problem = no units and didn't respawn in vehicle)

So i changed ur script to this: ( i know its against ur principes to use the OnEnterRegion and IscharacterInRegion but it works)

Code: Select all

ActivateRegion("forcevehiclereg")
local VehspawnNum = 1

testfunction = OnEnterRegion(
function(region, player)
if IsCharacterInRegion(player, "forcevehiclereg") then
EnterVehicle(player, "Vehspawn" .. VehspawnNum)
VehspawnNum = VehspawnNum + 1
end
end,"forcevehiclereg"
)
So now i respawn into a vehicle, and also the droids, whats not realy a problem (= i want that the droids respawn also in the vehicles like the players)
But the problem is when all vehicles used (by respawned droids and players), and a droid want to respawn, he cant respawn in a vehicle and the game crash.

So i used the VehspawnMaxNum:

Code: Select all

ActivateRegion("forcevehiclereg")
local VehspawnNum = 1
local VehspawnMaxNum = 11

testfunction = OnEnterRegion(
function(region, player)
if IsCharacterInRegion(player, "forcevehiclereg") then
EnterVehicle(player, "Vehspawn" .. VehspawnNum)
VehspawnNum = VehspawnNum + 1
if VehspawnNum > VehspawnMaxNum then
VehspawnNum = 1

end
end,"forcevehiclereg"
)
If the VehspawnNum gets higher then the VehspawnMaxNum, (so all 11 vehicles are used), the script say u to respawn into Vehspawn1 (if VehspawnNum > VehspawnMaxNum then VehspawnNum = 1). But if the Vehspawn1 already used (all vehicles are taken) the script cant find the vehicle for the droid wich want to spawn and result = crash.
So my question is now: is it possible to chance this line:
Hidden/Spoiler:
if VehspawnNum > VehspawnMaxNum then
VehspawnNum = 1
to something else, so if the VehspawnMaxNum reached, the droid, when he respawn, just wacht for a vehicle that will spawn soon and enter it by walking.
Also the 'Name' in OnEnterRegionName( not works and has to be OnEnterRegion(
I almost found it!
Thanks in advance
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Lua question

Post by [RDH]Zerted »

So when it reaches the max number, you want it to forever stop forcing players into vehicles?

Sorry about the OnEnterRegionName, I keep forgetting about that.
User avatar
Eagle Eye
First Lance Corporal
First Lance Corporal
Posts: 129
Joined: Thu Nov 01, 2007 12:44 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Belgium
Contact:

Re: Lua question

Post by Eagle Eye »

Yes, but not forever. Only untill a new vehicle appears

EDIT: Ok im a step farther:

Code: Select all

ActivateRegion("forcevehiclereg")
local VehspawnNum = 1
local VehspawnMaxNum = 11

testfunction = OnEnterRegion(
function(region, player)
if IsCharacterInRegion(player, "forcevehiclereg") and VehspawnNum <= VehspawnMaxNum then
EnterVehicle(player, "Vehspawn" .. VehspawnNum)
VehspawnNum = VehspawnNum + 1
end
end,"forcevehiclereg"
)
Its not 100% good, sometimes he crash...
The only strange thing left is that also AI respawns in the vehicles...
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Lua question

Post by [RDH]Zerted »

If you don't want the AI to be forced into vehicles, thats easy. Its

Code: Select all

IsCharacterHuman( player )
User avatar
Eagle Eye
First Lance Corporal
First Lance Corporal
Posts: 129
Joined: Thu Nov 01, 2007 12:44 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Belgium
Contact:

Re: Lua question

Post by Eagle Eye »

Thanks Zerted
What can be wrong in this script? i realy cant find out why the game crash sometimes..

Code: Select all

ActivateRegion("forcevehiclereg")
local VehspawnNum = 1
local VehspawnMaxNum = 11

testfunction = OnEnterRegion(
function(region, player)
if IsCharacterInRegion(player, "forcevehiclereg") and VehspawnNum <= VehspawnMaxNum then
EnterVehicle(player, "Vehspawn" .. VehspawnNum)
VehspawnNum = VehspawnNum + 1
end
end,"forcevehiclereg"
)
Look i found a problem:
I spawned a few times into a vehicle and died. After like 3 times, i spawn on the normal way when there are no vehicles anymore(= normal) So i wacht for a vehicle and when i saw one i repawned myself and tryed to spawn again into a vehicle but it doesn't works anymore (also not for the droids).

So when the VehspawnMaxNum reached (all 11 vehicles) i cant spawn into a vehicle anymore
By the way, the script stay adding numbers, also higher then 11 (also when the vehspawnmaxnum reached):
VehspawnNum = VehspawnNum + 1
So there must be a way, when the VehspawnMaxNum reached that the script repeat again to 1 (and not +1) only if there are new vehicles, if there not, you have to spawn on the normal way.
Soz for the bad english :D
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Lua question

Post by Maveritchell »

You could save the work of having to make sure there was a vehicle available by using CreateEntity:

Code: Select all

CreateEntity(ODFname, optionalMatrix, optionalNameForVehicle) 
You'd just use:

Code: Select all

EnterVehicle(player, CreateEntity("veh_walk_veh", "vehiclespawnnode"))
Not sure if that's the right way to call that matrix, but you get the gist.
User avatar
Eagle Eye
First Lance Corporal
First Lance Corporal
Posts: 129
Joined: Thu Nov 01, 2007 12:44 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Belgium
Contact:

Re: Lua question

Post by Eagle Eye »

I dont now... I think i just should give up my project, i searched to long for this
This is my script now: i know the problem in game but dont now how to fix it in script
Hidden/Spoiler:
ActivateRegion("forcevehiclereg")
local VehspawnNum = 1
local VehspawnMaxNum = 11

testfunction = OnEnterRegion(
function(region, player)
if IsCharacterInRegion(player, "forcevehiclereg") and VehspawnNum <= VehspawnMaxNum then
EnterVehicle(player, "Vehspawn" .. VehspawnNum)
VehspawnNum = VehspawnNum + 1
end
if IsCharacterInRegion(player, "forcevehiclereg") and VehspawnNum > VehspawnMaxNum then
VehspawnNum - VehspawnMaxNum
EnterVehicle(player, "Vehspawn" .. VehspawnNum)
VehspawnNum = VehspawnNum + 1
end
end,"forcevehiclereg"
)
Post Reply