Tete omar Posted June 9, 2012 Posted June 9, 2012 server side addEvent('onDkhl', true) addEventHandler('onDkhl', root, dkhl) function dkhl() spawnPlayer(source, 548.66711425781, -14 27.5430908203, 16.1328125) outputChatBox('You have been warped to dkhl area',source,0,255,0) end client side function dkhl() if ( source == GUIEditor_Button[12] ) then triggerServerEvent('onDkhl', localPlayer) end end addEventHandler('onClientGUIClick', root, dkhl) debugscript says: ERROR: Client triggered serverside event onDkhl, but event is not added serverside
Wei Posted June 9, 2012 Posted June 9, 2012 server side addEvent('onDkhl', true) function dkhl() setElementPosition(source, 548.66711425781, -14 27.5430908203, 16.1328125) outputChatBox('You have been warped to dkhl area',source,0,255,0) end addEventHandler("onDkhl", getRootElement(), dkhl ) client side function dkhl() if ( source == GUIEditor_Button[12] ) then triggerServerEvent('onDkhl', localPlayer) end end addEventHandler('onClientGUIClick', guiRoot, dkhl)
Tete omar Posted June 9, 2012 Author Posted June 9, 2012 server side addEvent('onDkhl', true) function dkhl() setElementPosition(source, 548.66711425781, -14 27.5430908203, 16.1328125) outputChatBox('You have been warped to dkhl area',source,0,255,0) end addEventHandler("onDkhl", getRootElement(), dkhl ) client side function dkhl() if ( source == GUIEditor_Button[12] ) then triggerServerEvent('onDkhl', localPlayer) end end addEventHandler('onClientGUIClick', guiRoot, dkhl) The same error blazy
Wei Posted June 9, 2012 Posted June 9, 2012 addEvent('onDkhl', true) function dkhl() spawnPlayer(source, 548.66711425781, -1427.5430908203, 16.1328125) outputChatBox('You have been warped to dkhl area',source,0,255,0) end addEventHandler('onDkhl', root, dkhl) function dkhl() if ( source == GUIEditor_Button[12]) then triggerServerEvent('onDkhl', localPlayer) end end addEventHandler('onClientGUIClick', guiRoot, dkhl, true) Tested and it works
X-SHADOW Posted June 10, 2012 Posted June 10, 2012 This is organized Code ---serverSide addEvent('onDkh1', true) addEventHandler('onDkh1', root, function() spawnPlayer (localPlayer, 548.66711425781, -1427.5430908203, 16.1328125) outputChatBox('You have been warped to dkhl area',source,0,255,0) end) --clientSide addEventHandler('onClientGUIClick' ,root, function() if ( localPlayer == GUIEditor_Button[12] ) then triggerServerEvent('onDkhl', localPlayer) end end)
Anderl Posted June 10, 2012 Posted June 10, 2012 This is organized Code ---serverSide addEvent('onDkh1', true) addEventHandler('onDkh1', root, function() spawnPlayer (localPlayer, 548.66711425781, -1427.5430908203, 16.1328125) outputChatBox('You have been warped to dkhl area',source,0,255,0) end) --clientSide addEventHandler('onClientGUIClick' ,root, function() if ( localPlayer == GUIEditor_Button[12] ) then triggerServerEvent('onDkhl', localPlayer) end end) Do you call this organized code? You didn't even tabulate it. Also, this code is totally wrong. Right code below. Client-side: addEventHandler ( 'onClientGUIClick', root, function ( ) if ( source == GUIEditor_Button[12] ) then triggerServerEvent ( 'onDkhl', localPlayer ); end end ) Server-side: addEvent ( 'onDkh1', true ); addEventHandler ( 'onDkh1', root, function ( ) spawnPlayer ( source, 548.66711425781, -1427.5430908203, 16.1328125 ); outputChatBox ( 'You have been warped to DKHL area!', source, 0, 255, 0, false ); end )
Alex. Posted June 10, 2012 Posted June 10, 2012 Do you call this organized code? You didn't even tabulate it. I would not call embedded functions organized.
X-SHADOW Posted June 10, 2012 Posted June 10, 2012 Darken your code is nice and orgnized but can you show me my errors ?
Guest Guest4401 Posted June 10, 2012 Posted June 10, 2012 spawnPlayer (localPlayer, 548.66711425781, -1427.5430908203, 16.1328125) should be source instead of localPlayer. By the way, if the player is alive, then you can just use setElementPosition to teleport the player. spawnPlayer & triggering is not something i'd prefer.
Anderl Posted June 10, 2012 Posted June 10, 2012 This is organized Code ---serverSide addEvent('onDkh1', true) addEventHandler('onDkh1', root, function() spawnPlayer (localPlayer, 548.66711425781, -1427.5430908203, 16.1328125) outputChatBox('You have been warped to dkhl area',source,0,255,0) end) --clientSide addEventHandler('onClientGUIClick' ,root, function() if ( localPlayer == GUIEditor_Button[12] ) then triggerServerEvent('onDkhl', localPlayer) end end) spawnPlayer (localPlayer, 548.66711425781, -1427.5430908203, 16.1328125) if ( localPlayer == GUIEditor_Button[12] ) then
X-SHADOW Posted June 10, 2012 Posted June 10, 2012 if i put source soldsnake say source not defined if i put localPlayer you say use source insted i dont get
JR10 Posted June 10, 2012 Posted June 10, 2012 And you're just blindly, without operating your mind do the same on all situations? There is events with a 'source' that you can use. How can a localPlayer be compared to a button? And how are you using localPlayer server side?
Guest Guest4401 Posted June 10, 2012 Posted June 10, 2012 You can use localPlayer only clientside. localPlayer is a predefined variable for getLocalPlayer(). Depending upon the events, the source differs. It not necessarily be a player element always. You can always see what the source of each event is, on it's respective wiki page. onClientGUIClick - source is the GUI Element that was clicked So you see, we compare to check if source (the button clicked) is the button which was supposed to be clicked or not. So if you compare a GUI Element with localPlayer, it's meaningless.
Tete omar Posted June 10, 2012 Author Posted June 10, 2012 Thanks for all of you guys i found the solve and it's setElementPosition in client side Instead of spawnPlayer thanks
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now