Tete omar Posted June 9, 2012 Share 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 Link to comment
Wei Posted June 9, 2012 Share 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) Link to comment
Tete omar Posted June 9, 2012 Author Share 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 Link to comment
DNL291 Posted June 9, 2012 Share Posted June 9, 2012 Check the file meta.xml. the error may be there. Link to comment
Wei Posted June 9, 2012 Share 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 Link to comment
DNL291 Posted June 10, 2012 Share Posted June 10, 2012 Serverside script isn't working, debug it. Link to comment
X-SHADOW Posted June 10, 2012 Share 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) Link to comment
Anderl Posted June 10, 2012 Share 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 ) Link to comment
Alex. Posted June 10, 2012 Share Posted June 10, 2012 Do you call this organized code? You didn't even tabulate it. I would not call embedded functions organized. Link to comment
X-SHADOW Posted June 10, 2012 Share Posted June 10, 2012 Darken your code is nice and orgnized but can you show me my errors ? Link to comment
Guest Guest4401 Posted June 10, 2012 Share 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. Link to comment
Anderl Posted June 10, 2012 Share 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 Link to comment
X-SHADOW Posted June 10, 2012 Share 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 Link to comment
JR10 Posted June 10, 2012 Share 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? Link to comment
Guest Guest4401 Posted June 10, 2012 Share 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. Link to comment
X-SHADOW Posted June 10, 2012 Share Posted June 10, 2012 Thank's karthik_184 For Help =D Link to comment
Tete omar Posted June 10, 2012 Author Share 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 Link to comment
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