Jump to content

Problem with triggerServerEvent


hemen

Recommended Posts

Posted

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)

Posted
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..

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
[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.

Posted

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]

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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.

Posted

click on this:

triggerServerEvent

read about 2nd argument.

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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

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