Jump to content

Error


Recommended Posts

Posted

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

F4MZM4.gif

Posted

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 !

Posted
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

F4MZM4.gif

Posted

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.

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

Posted

Serverside script isn't working, debug it.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

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) 

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

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

"[...] 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

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

Posted
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

"[...] 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

Posted

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%

Guest Guest4401
Posted

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.

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