Jump to content

Problem with triggerServerEvent


hemen

Recommended Posts

I cannot get the variable in client-side script, who (the variable) is returned by server-side function.

--Client-side
triggerServerEvent ( "createTeam1", getRootElement(), text,GangInfo.RColor[AllGangs],GangInfo.GColor[AllGangs],GangInfo.BColor[AllGangs],GangInfo.TeamID[AllGangs])

--Server-side
function createTeam1 ( name,r,g,b,var1 )
local var1 = createTeam(name,r,g,b)
end
 
addEvent( "createTeam1", true )
addEventHandler( "createTeam1", getRootElement(), createTeam1 )

Edit by varez: Changed code tags to lua tags. Use them next time :) And comment lines in lua start with -- (double dash) not // (double slash)

Link to comment
I cannot get the variable in client-side script, who (the variable) is returned by server-side function.

umm, your script suggest you want to get variable in server side from client-side o_O

any errors?

outputDebugString(GangInfo.RColor[AllGangs].."--"..GangInfo.GColor[AllGangs].."--"..GangInfo.BColor[AllGangs].."--"..GangInfo.TeamID[AllGangs])
triggerServerEvent ("createTeam1", getRootElement(), text, GangInfo.RColor[AllGangs],GangInfo.GColor[AllGangs],GangInfo.BColor[AllGangs],GangInfo.TeamID[AllGangs])

function createTeam1 ( name,r,g,b,var1 )
outputDebugString("srv: "..name.."--"..r.."--"..g.."--"..b)
local var1 = createTeam(name,r,g,b)
end
 
addEvent( "createTeam1", true )
addEventHandler( "createTeam1", getRootElement(), createTeam1 )

now ingame enter in console "debugscript 3"

and see what it outputs..

Link to comment
[2010-08-17 21:52:31] ERROR: [string "gang\gang_client.lua"]:309: attempt to concatenate field '?' (a nil value)
outputChatBox(""..GangInfo.RColor[AllGangs].."")--308
outputChatBox(""..GangInfo.TeamID[AllGangs].."")--309

Edit by varez: Changed code tags to lua tags.

Link to comment

this says all, your GangInfo.TeamID[AllGangs] is nil == not set.

Need more script to tell you more.. Or maybe you know now whats wrong?

and

-- WHY?
outputChatBox(""..GangInfo.TeamID[AllGangs].."")
 
-- WHEN YOU CAN JUST DO
outputChatBox(GangInfo.TeamID[AllGangs])

And once again

Use [lua][/lua] tags instead of [code][/code]

Link to comment

Ok. I didn't fixed my trouble, i simply delete code with Team. It's not very important function :)

But i found new trouble - function doesn't work.

--client-side
triggerServerEvent("outputChatBox1","Join the gang - /gangjoin",player,0,175,0)

--server-side
function outputChatBox1Func (text,player,r,g,b)
outputChatBox(text,player,r,g,b)
end
 
addEvent( "outputChatBox1", true )
addEventHandler( "outputChatBox1", getRootElement(), outputChatBox1Func )

And other function with player works.

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...