Function doesn't get loaded at all...

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

Post Reply
Aman/Pinguin
Jedi
Jedi
Posts: 1104
Joined: Tue Jan 30, 2007 6:04 am
Projects :: Inactive
Location: Germany

Function doesn't get loaded at all...

Post by Aman/Pinguin »

Okay short story, I made 3 functions which do nearly the same and use the same method, my problem is that the second and third function don't get used at all. I tested it by putting print commands in...they don't get printed.
I have no idea why, and hope somebody knows a solution.
I made the working part in big letters.

Hidden/Spoiler:
OnCharacterSpawn(
function(character)
if uf_processPlayers then

--a function to kill Roan, the function takes a single table 'players' as an argument/parameter
local KillRoan = function( players )
--can't do anything if the player data table is missing
if not players then return end
--for each player ingame,
local i
for i=1,table.getn(players) do
--search for the player
if (players.namestr == "=][Legend][=Silverstar™=GER=") or
(players.namestr == "=][Legend][=Roan=GER=") or
(players.namestr == "=][Legend][=Roan") or
(players.namestr == "=][Legend][=Roan™") or
(players.namestr == "=][Legend][=RoanShryne=GER=") or
(players.namestr == "=][Legend][=Roan™=GER=") or
(players.namestr == "=][Legend][=RoanShryne™=GER=") or
(players.namestr == "=][Legend][=Silverstar=GER=") or
(players.namestr == "=][Legend][=Silverstar") or
(players.namestr == "=][Legend][=Silverstar™") then

--get Roan's unit
local unit = GetCharacterUnit(players[i].indexstr)
if not unit then return end --Roan is already dead, so there is nothing more for us to do

--kill Roan's Unit
KillObject( unit )

return end
end
end







-- THE FUNCTIONS BELOW DONT GET LOADED AT ALL! the first print there ("user_script_1: Entered Gaman function") doesn't get printed when I spawn!







local Gaman = function( players )
print("user_script_1: Entered Gaman function")
--can't do anything if the player data table is missing
if not players then return end
--for each player ingame,
local i
for i=1,table.getn(players) do
print("user_script_1: 'for i=1,table.getn(players) do' has been reached")
--search for the player
if (players[i].namestr == "=ro[D]Pinguin/Gaman") then
print("user_script_1: Player is Pinguin")
if __thisMapsMode__ == "tat3_con" and JustSpawned == 0 then
print("user_script_1: -SpawnAsGammo- Jabba's Palace has been detected")
local Pingunit = GetCharacterUnit(players[i].indexstr)
if not unit then return end
KillObject( Pingunit )
if GetCharacterTeam(players[i].indexstr) == 1 then
AddReinforcements(1, 1 )
elseif GetCharacterTeam(players[i].indexstr) == 2 then
AddReinforcements(2, 1 )
end
if UserDeathGamPinguin == 1 then
UserDeathGam = 2
elseif UserDeathGamPinguin == 0 then
UserDeathGam = 1
end

if UserDeathGamPinguin == 2 then
JustSpawned = 1
Pinggammo_timer = CreateTimer("Pinggammo_timer")
SetTimerValue(Pinggammo_timer, 5)
StartTimer(Pinggammo_timer)
OnTimerElapse(
function(timer)
JustSpawned = 0
UserDeathGamPinguin = 0
DestroyTimer(timer)
end,
Pinggammo_timer)
end
if GetCharacterTeam(players[i].indexstr) == 1 then
SelectCharacterClass(players[i].indexstr, "gam_inf_gamorreanguard")
SpawnCharacter(players[i].indexstr, GetPathPoint("CP1SPAWN", 0))
end

if GetCharacterTeam(players[i].indexstr) == 2 then
SelectCharacterClass(players[i].indexstr, "gam_inf_gamorreanguard")
SpawnCharacter(players[i].indexstr, GetPathPoint("CP4Spawn", 0))
end

end

return end
end
end

local Smuff = function( players )
--can't do anything if the player data table is missing
if not players then return end
--for each player ingame,
local i
for i=1,table.getn(players) do
--search for the player
if (players[i].namestr == "=ro[D]smuff") then
print("user_script_1: Player is Smove")
if __thisMapsMode__ == "tat3_con" and JustSpawned == 0 then
print("user_script_1: -SpawnAsGammo- Jabba's Palace has been detected")
local Smuffunit = GetCharacterUnit(players[i].indexstr)
if not unit then return end
KillObject( Smuffunit )
if GetCharacterTeam(players[i].indexstr) == 1 then
AddReinforcements(1, 1 )
elseif GetCharacterTeam(players[i].indexstr) == 2 then
AddReinforcements(2, 1 )
end
if UserDeathGamSmove == 1 then
UserDeathGam = 2
elseif UserDeathGamSmove == 0 then
UserDeathGam = 1
end

if UserDeathGamSmove == 2 then
JustSpawned = 1
smuff_timer = CreateTimer("smuff_timer")
SetTimerValue(smuff_timer, 5)
StartTimer(smuff_timer)
OnTimerElapse(
function(timer)
JustSpawned = 0
UserDeathGamSmove = 0
DestroyTimer(timer)
end,
smuff_timer)
end
if GetCharacterTeam(players[i].indexstr) == 1 then
SelectCharacterClass(players[i].indexstr, "gam_inf_gamorreanguard")
SpawnCharacter(players[i].indexstr, GetPathPoint("CP1SPAWN", 0))
end

if GetCharacterTeam(players[i].indexstr) == 2 then
SelectCharacterClass(players[i].indexstr, "gam_inf_gamorreanguard")
SpawnCharacter(players[i].indexstr, GetPathPoint("CP4Spawn", 0))
end

end

return end
end
end
uf_processPlayers( Smuff )
uf_processPlayers( Gaman )
uf_processPlayers( KillRoan )
else
--of course, the player won't see this debug message, but it doesn't hurt to have it...
print("WARNING: Cannot Kill Roan / Spawn Player As Gammo: The uf_processPlayers function is missing. Please update your game to the latest UnOfficial v1.3 patch")
end
end
)


It's pretty hard to read it here in the forum, so here is a download for it in a file: http://files.filefront.com/half+working ... einfo.html


EDIT: Not sure if I explained it how everyone can understand it...it's late here and I'm tired.
If there are any questions fell free to ask I will answer them tomorrow...
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: Function doesn't get loaded at all...

Post by [RDH]Zerted »

I haven't gone over all your code to make sure it works, but you can only do one fc_processPlayers() at a time. That function stores a copy of the function you give it into a global variable. Then it jumps into player list screen and jumps back out. The v1.3 patch changed the player list screen. When you enter that screen, it checks to see if there is a function in the global variable. If there is, it calls the function with the player list then leaves the screen.

Since each call to fc_processPlayers() stores the function in the same variable, only the last one is really there when the exe gets around to displaying the player list screen (the Lua doesn't direcly change the screens, it asks the exe to do it. This asking finishes and the lua code keeps processing before the exe gets around to changing the screen).
Aman/Pinguin
Jedi
Jedi
Posts: 1104
Joined: Tue Jan 30, 2007 6:04 am
Projects :: Inactive
Location: Germany

Re: Function doesn't get loaded at all...

Post by Aman/Pinguin »

Okay, (I think) I understand.

But is there any way I could still do that stuff I tried?
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: Function doesn't get loaded at all...

Post by [RDH]Zerted »

You could put it all into one function instead of three. Or you can do one function, then have that function call the next one, then call the next one.

Also, I would recommend not checking all the names everytime someone spawned. I don't know how much effort the game requires to generate the player list.
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: Function doesn't get loaded at all...

Post by [RDH]Zerted »

Yeah, these custom user_scripts on dedicated servers are fun. Someone should make one that forces you to play as locals on all the maps...

Anyway, this topic was solved through XFire, so its done.
Post Reply