Jump to content

Error


Recommended Posts

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

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

This is organized Code :D

---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
This is organized Code :D
---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
Guest Guest4401
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
This is organized Code :D
---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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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