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) Diet with russian vodka, lose 3 days in one week !
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
DNL291 Posted June 9, 2012 Posted June 9, 2012 Check the file meta.xml. the error may be there. Please do not PM me with scripting related question nor support, use the forums instead.
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 Diet with russian vodka, lose 3 days in one week !
DNL291 Posted June 10, 2012 Posted June 10, 2012 Serverside script isn't working, debug it. Please do not PM me with scripting related question nor support, use the forums instead.
Wei Posted June 10, 2012 Posted June 10, 2012 Tested and it works Diet with russian vodka, lose 3 days in one week !
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) My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
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 ) "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
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 ? My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
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 "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
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 My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
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? Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
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.
X-SHADOW Posted June 10, 2012 Posted June 10, 2012 Thank's karthik_184 For Help =D My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
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